Removing PlayerObjects
#1

Basically, I wanted to make a function which makes some objects for a certain person, and then a function that removes it.

Код:
#define MAX_PLAYER_EXAM_OBJECTS 200
new pExamObjects[MAX_PLAYERS][MAX_PLAYER_EXAM_OBJECTS];
Then

Код:
forward CreatePlayerExamObjects(playerid, examid);
public CreatePlayerExamObjects(playerid, examid)
{
	if(IsPlayerConnected(playerid))
	{
	    pIsOnExam[playerid] = 1;
	    if(examid == 1)
	    {
		    pExamObjects[playerid][1] = CreatePlayerObject(playerid, 3009, 1928.0999755859, -1437.0999755859, 12.60000038147, 0, 0, 0);
			pExamObjects[playerid][2] = CreatePlayerObject(playerid, 3092, 1920.1999511719, -1425.9000244141, 9.5900001525879, 90, 90, 320);
			pExamObjects[playerid][3] = CreatePlayerObject(playerid, 8659, 1926.9000244141, -1423.4000244141, 10.5, 0, 0, 80);
			pExamObjects[playerid][4] = CreatePlayerObject(playerid, 8659, 1927.5, -1419.9000244141, 12.300000190735, 0, 180, 79.996948242188);
			pExamObjects[playerid][5] = CreatePlayerObject(playerid, 8659, 1927.6999511719, -1418.8000488281, 14.300000190735, 0, 0, 79.991455078125);
			pExamObjects[playerid][6] = CreatePlayerObject(playerid, 8659, 1907.5, -1426.1999511719, 14.199999809265, 0, 0, 79.991455078125);
			pExamObjects[playerid][7] = CreatePlayerObject(playerid, 8659, 1906.5, -1432.3000488281, 12.199999809265, 0, 180, 79.991455078125);
			pExamObjects[playerid][8] = CreatePlayerObject(playerid, 8659, 1907.8000488281, -1424.8000488281, 10.39999961853, 0, 0, 79.991455078125);
			pExamObjects[playerid][9] = CreatePlayerObject(playerid, 981, 1914.6999511719, -1434.9000244141, 15.39999961853, 15, 0, 180);
			pExamObjects[playerid][9] = CreatePlayerObject(playerid, 981, 1917.5999755859, -1417.8000488281, 15.39999961853, 15, 0, 0);
			pExamObjects[playerid][10] = CreatePlayerObject(playerid, 1210, 1920.9000244141, -1427.0999755859, 9.5, 90, 0, 50);
			pExamObjects[playerid][11] = CreatePlayerObject(playerid, 3395, 1922.6999511719, -1426.0999755859, 8.4610004425049, 0, 0, 356);
			pExamObjects[playerid][12] = CreatePlayerObject(playerid, 2146, 1920, -1423.6999511719, 10, 0, 0, 280);
			pExamObjects[playerid][13] = CreatePlayerObject(playerid, 2173, 1913.5999755859, -1425.0999755859, 9.3999996185303, 0, 0, 270);
			pExamObjects[playerid][14] = CreatePlayerObject(playerid, 2173, 1913.5999755859, -1427.1999511719, 9.3999996185303, 0, 0, 270);
			pExamObjects[playerid][15] = CreatePlayerObject(playerid, 1714, 1912.4000244141, -1425.4000244141, 9.3999996185303, 0, 0, 78);
			pExamObjects[playerid][16] = CreatePlayerObject(playerid, 1714, 1912.4000244141, -1427.6999511719, 9.3999996185303, 0, 0, 89.997436523438);
	    }
	}
	return 1;
}

forward RemovePlayerExamObjects(playerid);
public RemovePlayerExamObjects(playerid)
{
    if(IsPlayerConnected(playerid))
	{
	    pIsOnExam[playerid] = 0;
	    for(new o=1;o<=MAX_PLAYER_EXAM_OBJECTS;o++)
	    {
	        DestroyPlayerObject(playerid, pExamObjects[playerid][o]);
	    }
	}
	SendClientMessage(playerid, COLOR_OTHER, "* Objects removed");
	return 1;
}
The CreatePlayerExamObjects works, but when I use RemovePlayerExamObjects, nothing happens, anybody knows where's the problem?
Thank you.
Reply
#2

Nobody? :/
Reply
#3

Isn't it this:
pawn Код:
for(new o=1;o<=MAX_PLAYER_EXAM_OBJECTS;o++)
Possible fix:
pawn Код:
for(new o = 0; o<=MAX_PLAYER_EXAM_OBJECTS;o++)
Reply
#4

Nope.
Reply
#5

pawn Код:
for( new o = 1; o< MAX_PLAYER_EXAM_OBJECTS; o++ )
?
Reply
#6

Are you both kidding me?
it's new o=1; because I defined the objects from 1, not from 0 (pExamObjects[playerid][1] = CreatePlaye..), and the o<MAX_PLAYER_EXAM_OBJECTS is almost the same as o<=, just yours won't include the object number 200, which was not even used.
Anybody else please?
Reply
#7

I also had some problems with deleting player objects, try using a streamer, or try use deleteobject
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)