OnPlayerEditDynamicObject on CrashDetect
#1

Anyone know solution of this problem?

pawn Код:
[06:42:25] [debug] Run time error 4: "Array index out of bounds"
[06:42:25] [debug]  Accessing element at negative index -1
[06:42:25] [debug] AMX backtrace:
[06:42:25] [debug] #0 003e4ac0 in public Streamer_OnPlayerEditObject (0x00000000, 0x00000001, 0x000001cf, 0x00000000, 0x44b6eca0, 0xc4d6562e, 0x4158c006, 0x00000000, 0x00000000, 0x00000000) from script.amx
[06:42:25] [debug] #1 000007e4 in public OnPlayerEditObject (0x00000000, 0x00000001, 0x000001cf, 0x00000000, 0x44b6eca0, 0xc4d6562e, 0x4158c006, 0x00000000, 0x00000000, 0x00000000) from script.amx
pawn Код:
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
    if(oEdit[playerid] == 1)
    {
        idx = oEditID[playerid];
        if(response == EDIT_RESPONSE_UPDATE)
        {
            SetDynamicObjectPos(objectid, x, y, z);
            SetDynamicObjectRot(objectid, rx, ry, rz);
        }
        else if(response == EDIT_RESPONSE_CANCEL)
        {
            SetDynamicObjectPos(objectid, oPos[playerid][0], oPos[playerid][1], oPos[playerid][2]);
            SetDynamicObjectRot(objectid, oRot[playerid][0], oRot[playerid][1], oRot[playerid][2]);
            oPos[playerid][0] = 0; oPos[playerid][1] = 0; oPos[playerid][2] = 0;
            oRot[playerid][0] = 0; oRot[playerid][1] = 0; oRot[playerid][2] = 0;
            oEdit[playerid] = 0;
            oEditID[playerid] = 0;
            format(string, sizeof(string), " Cancelled Edit Object ID %d.", idx);
            SendClientMessage(playerid, COLOR_WHITE, string);
        }
        else if(response == EDIT_RESPONSE_FINAL)
        {
            SetDynamicObjectPos(objectid, x, y, z);
            SetDynamicObjectRot(objectid, rx, ry, rz);
            if(oEdit[playerid] == 1)
            {
                ObjectInfo[idx][oX] = x;
                ObjectInfo[idx][oY] = y;
                ObjectInfo[idx][oZ] = z;
                ObjectInfo[idx][oRX] = rx;
                ObjectInfo[idx][oRY] = ry;
                ObjectInfo[idx][oRZ] = rz;
                oEdit[playerid] = 0;
                oEditID[playerid] = 0;
                format(string, sizeof(string), "Finished Edit Object ID %d.", idx);
                SendClientMessage(playerid, COLOR_WHITE, string);
                SaveObj();
            }
        }
    }
        return 1;
}
Reply
#2

I think the playerid must somehow be -1. Those arrays don't support anything less than 0. But if this is the problem then how is the function being called?
Reply
#3

I guess it comes from the Streamer ,
which OnPlayerEditObject and different OnPlayerDynamicObject Arrays ,

This is arrays of OnPlayerEditObject

pawn Код:
forward OnPlayerEditObject( playerid, playerobject, objectid, response,
Float:fX, Float:fY, Float:fZ, Float:fRotX, Float:fRotY, Float:fRotZ );
While in streamer OnPlayerEditDynamicObject

pawn Код:
forward OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
The difference is in the array playerobject , which is not in Streamer .

It makes debug the crash appears .

But after I add it in include streamer .
It has no effect at all.

It still appears.

Any solutions?
Reply
#4

Код:
public OnPlayerEditDynamicObject(playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz)
{
	printf("Debug: playerid: %i, objectid: %i, response: %i, X: %f, Y: %f, Z: %f, rX: %f, rY: %f, rZ: %f", playerid, objectid, response, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz);
	if(oEdit[playerid] == 1)
	{
		idx = oEditID[playerid];
		if(response == EDIT_RESPONSE_UPDATE)
		{
		    SetDynamicObjectPos(objectid, x, y, z);
			SetDynamicObjectRot(objectid, rx, ry, rz);
		}
		else if(response == EDIT_RESPONSE_CANCEL)
		{
		    SetDynamicObjectPos(objectid, oPos[playerid][0], oPos[playerid][1], oPos[playerid][2]);
			SetDynamicObjectRot(objectid, oRot[playerid][0], oRot[playerid][1], oRot[playerid][2]);
			oPos[playerid][0] = 0; oPos[playerid][1] = 0; oPos[playerid][2] = 0;
			oRot[playerid][0] = 0; oRot[playerid][1] = 0; oRot[playerid][2] = 0;
			oEdit[playerid] = 0;
			oEditID[playerid] = 0;
			format(string, sizeof(string), " Cancelled Edit Object ID %d.", idx);
			SendClientMessage(playerid, COLOR_WHITE, string);
		}
		else if(response == EDIT_RESPONSE_FINAL)
		{
			SetDynamicObjectPos(objectid, x, y, z);
			SetDynamicObjectRot(objectid, rx, ry, rz);
			if(oEdit[playerid] == 1)
			{
			    ObjectInfo[idx][oX] = x;
				ObjectInfo[idx][oY] = y;
				ObjectInfo[idx][oZ] = z;
				ObjectInfo[idx][oRX] = rx;
				ObjectInfo[idx][oRY] = ry;
				ObjectInfo[idx][oRZ] = rz;
			    oEdit[playerid] = 0;
			    oEditID[playerid] = 0;
			    format(string, sizeof(string), "Finished Edit Object ID %d.", idx);
			    SendClientMessage(playerid, COLOR_WHITE, string);
				SaveObj();
			}
		}
	}
        return 1;
}
Use this instead and post here what it prints out in the server logs after the server crashes.
Reply
#5

Quote:
Originally Posted by qmnty
Посмотреть сообщение
The difference is in the array playerobject , which is not in Streamer.
It does not need that parameter because all 'dynamic' objects are actually just player objects.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)