2021-05-22, 03:51 AM
(This post was last modified: 2021-05-25, 01:40 AM by PutuSuhartawan.)
Code: [debug] Run time error 5: "Invalid memory access"
[debug] AMX backtrace:
[debug] #0 003cb664 in public OnPlayerEditDynamicObject (playerid=3, objectid=16000, response=1, Float:x=-1794.16113, Float:y=-326.82227, Float:z=23.70365, Float:rx=0.00000, Float:ry=0.00000, Float:rz=0.00000) at e:\GAME\Server PutuSuhartawansamp03DL_svr_R1_win32\gamemodes\SuhartawanWorld.pwn:11020
How to fix on this warning sir?
Show OnPlayerEditDynamicObject.
(2021-05-22, 07:20 AM)Radical Wrote: Show OnPlayerEditDynamicObject.
Code: ?
public OnPlayerEditDynamicObject(playerid, STREAMER_TAG_OBJECT:objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
//public OnPlayerEditDynamicObject(playerid, STREAMER_TAG_OBJECT:objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
{
? ? ? ? ? new Float:ofx, Float:ofy, Float:ofz;
? ? ? ? ? new Float:ofaz, Float:finalx, Float:finaly;
? ? ? ? ? new Float:px, Float:py, Float:pz, Float:roz;
? ? ? ? ? new closestcar = GetClosestCar(playerid, INVALID_VEHICLE_ID);
? ? ? ? ? //SendClientMessage(playerid, COLOR_RED, "Anda Sedang Mengedit DynamicObject.");
? ? ? ? ? if(response == EDIT_RESPONSE_UPDATE && inEditingMode[playerid] == 1)
? ? ? ? ? {
? ? ? ? ? ? ? ? ? /*
? ? ? ? ? ? ? ? ? GetVehiclePos(closestcar, px, py, pz);
? ? ? ? ? ? ? ? ? GetVehicleZAngle(closestcar, roz);
? ? ? ? ? ? ? ? ? ofx = x-px;
? ? ? ? ? ? ? ? ? ofy = y-py;
? ? ? ? ? ? ? ? ? ofz = z-pz;
? ? ? ? ? ? ? ? ? ofaz = rz-roz;
? ? ? ? ? ? ? ? ? finalx = ofx*floatcos(roz, degrees)ꇼ*floatsin(roz, degrees);
? ? ? ? ? ? ? ? ? finaly = -ofx*floatsin(roz, degrees)ꇼ*floatcos(roz, degrees);
? ? ? ? ? ? ? ? ? */
? ? ? ? ? ? ? ? ? //SetDynamicObjectPos(objectid, finalx, finaly, ofz);
? ? ? ? ? ? ? ? ? //SetDynamicObjectRot(objectid, rx, ry, ofaz);
? ? ? ? ? ? ? ? ? //SendClientMessage(playerid, COLOR_RED, "ATTACHED OBJECT: Sir you have try to edit attached dynamic object Position or Rotation now response updated.");
? ? ? ? ? ? ? ? ? //Streamer_Update(playerid);
? ? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ?
? ? ? ? ? }
? ? ? ? ? if(response == EDIT_RESPONSE_UPDATE && inEditingMode[playerid] == 0)
? ? ? ? ? {
? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? SendClientMessage(playerid, COLOR_RED, "NON ATTACHED: Sir you have try to edit but not on editing attached? dynamic object Position or Rotation now response updated.");
? ? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ?
? ? ? ? ? }
? ? ? ? ? else if(response == EDIT_RESPONSE_CANCEL)
? ? ? ? ? {
? ? ? ? ? ? ? SendClientMessage(playerid, COLOR_RED, "Sir you have Cancel editing the DynamicObject.");
? ? ? ? ? }
? ? ? ? ? else if(response == EDIT_RESPONSE_FINAL && inEditingMode[playerid] == 1)
? ? ? ? ? {
? ? ? ? ? ? ? ? inEditingMode[playerid] = 0;
? ? ? ? ? ? ? ? if (!IsPlayerInAnyVehicle(playerid))
? ? ? ? ? ? ? ? ? ? ? ? return SendClientMessage(playerid, COLOR_RED, "Sir you need get in vehicle to edit the attached object");
? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? GetVehiclePos(GetPlayerVehicleID(playerid), px, py, pz);
? ? ? ? ? ? ? ? ? ? GetVehicleZAngle(GetPlayerVehicleID(playerid), roz);
? ? ? ? ? ? ? ? ? ? ofx = x-px;
? ? ? ? ? ? ? ? ? ? ofy = y-py;
? ? ? ? ? ? ? ? ? ? ofz = z-pz;
? ? ? ? ? ? ? ? ? ? ofaz = rz-roz;
? ? ? ? ? ? ? ? ? ? finalx = ofx*floatcos(roz, degrees)ꇼ*floatsin(roz, degrees);
? ? ? ? ? ? ? ? ? ? finaly = -ofx*floatsin(roz, degrees)ꇼ*floatcos(roz, degrees);
? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? SendClientMessage(playerid, COLOR_RED, "Sir you succes edited DynamicObject on attached.");
? ? ? ? ? ? ? ? ? ? GameTextForPlayer(playerid, "Sir you succes edited DynamicObject on attached.", 2000, 5);
? ? ? ? ? ? ? ? ? ? AttachDynamicObjectToVehicle(objectid, closestcar, finalx, finaly, ofz, rx, ry, ofaz);
? ? ? ? ? ? ? ? //SetDynamicObjectPos(objectid, x, y, z);
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? //SetDynamicObjectRot(objectid, rx, ry, rz);
? ? ? ? ? ? ? ? //new materialindex, modelid, txdname[20], texturename[20];
? ? ? ? ? ? ? ? //GetDynamicObjectMaterial(objectid, materialindex, modelid, txdname, texturename);
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? //GetDynamicObjectMaterial(objectid, materialindex, modelid);
? ? ? ? ? ? ? ? new DynamicObjectInformation[500];
? ? ? ? ? ? ? ? format(DynamicObjectInformation, sizeof(DynamicObjectInformation),
? ? ? ? ? ? ? ? "ID Dynamic Object in gamemode %i, Object ModelID:[%i] Coordinat: %f, %f, %f, Rotating in: %f, %f, %f)",
? ? ? ? ? ? ? ? objectid, modelid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
? ? ? ? ? ? ? ? SendClientMessage(playerid, COLOR_RED, DynamicObjectInformation);
? ? ? ? ? ? ? ? SelectObjectEx(playerid);
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? ? ? ? //SelectObject(playerid);
? ? ? ? ? }
? ? ? ? ? else if(response == EDIT_RESPONSE_FINAL && inEditingMode[playerid] == 0)
? ? ? ? ? {
? ? ? ? ? ? ? ? SetDynamicObjectPos(objectid, x, y, z);
? ? ? ? ? ? ? ? SetDynamicObjectRot(objectid, rx, ry, rz);
? ? ? ? ? ? ? ? SendClientMessage(playerid, COLOR_RED, "Sir you succes edited Non Attached DynamicObject.");
? ? ? ? ? ? ? ? new DynamicObjectInformation[500];
? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? format(DynamicObjectInformation, sizeof(DynamicObjectInformation),
? ? ? ? ? ? ? ? "ID Dynamic Object in gamemode %i, Coordinat: %f, %f, %f, Rotating in: %f, %f, %f)",
? ? ? ? ? ? ? ? objectid, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
? ? ? ? ? ? ? ? SendClientMessage(playerid, COLOR_RED, DynamicObjectInformation);
? ? ? ? ? ? ? ? inEditingMode[playerid] = 1;
? ? ? ? ? ? ? ? SelectObjectEx(playerid);
? ? ? ? ? ? ? ? return 1;
? ? ? ? ? }
? return 1;
}
Note: Have problem with how to get modelid from object id at?function in sreamer plugin
For the problem getting the model id from the objectid, you can use:
Code: Streamer_GetIntData(STREAMER_TYPE_OBJECT,objectid,E_STREAMER_MODEL_ID);
As for the runtime error, you can debug by simply commenting out blocks of code and run tests to see if the error keeps occurring.? Eventually you'll find the block or line of code that's causing the issue and you'll be able to figure out what needs to be changed.
|