SA-MP Forums Archive
RemoveBuildingForPlayer isn't working. Why? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: RemoveBuildingForPlayer isn't working. Why? (/showthread.php?tid=379813)



RemoveBuildingForPlayer isn't working. Why? - ShawtyyMacJunior - 23.09.2012

Alright, so heres the code :

Код:
public OnGameModeInit()
{
	new playerid;
	RemoveBuildingForPlayer(playerid, 5930, 1134.2500, -1338.0781, 23.1563, 0.25);
	RemoveBuildingForPlayer(playerid, 5931, 1114.3125, -1348.1016, 17.9844, 0.25);
	RemoveBuildingForPlayer(playerid, 5935, 1120.1563, -1303.4531, 18.5703, 0.25);
	RemoveBuildingForPlayer(playerid, 5936, 1090.0547, -1310.5313, 17.5469, 0.25);
	RemoveBuildingForPlayer(playerid, 5787, 1090.0547, -1310.5313, 17.5469, 0.25);
	RemoveBuildingForPlayer(playerid, 1297, 1112.6172, -1389.8672, 15.6719, 0.25);
	RemoveBuildingForPlayer(playerid, 5810, 1114.3125, -1348.1016, 17.9844, 0.25);
	RemoveBuildingForPlayer(playerid, 5811, 1131.1953, -1380.4219, 17.0703, 0.25);
	RemoveBuildingForPlayer(playerid, 5708, 1134.2500, -1338.0781, 23.1563, 0.25);
	RemoveBuildingForPlayer(playerid, 1440, 1148.6797, -1385.1875, 13.2656, 0.25);
	RemoveBuildingForPlayer(playerid, 1297, 1161.1563, -1390.1172, 15.6406, 0.25);
	RemoveBuildingForPlayer(playerid, 617, 1178.6016, -1332.0703, 12.8906, 0.25);
	RemoveBuildingForPlayer(playerid, 620, 1184.0078, -1353.5000, 12.5781, 0.25);
	RemoveBuildingForPlayer(playerid, 620, 1184.0078, -1343.2656, 12.5781, 0.25);
	RemoveBuildingForPlayer(playerid, 5737, 1120.1563, -1303.4531, 18.5703, 0.25);
	RemoveBuildingForPlayer(playerid, 618, 1177.7344, -1315.6641, 13.2969, 0.25);
	RemoveBuildingForPlayer(playerid, 620, 1184.8125, -1292.9141, 12.5781, 0.25);
	RemoveBuildingForPlayer(playerid, 620, 1184.8125, -1303.1484, 12.5781, 0.25);
	RemoveBuildingForPlayer(playerid, 1283, 1190.3047, -1389.8047, 15.5000, 0.25);
	RemoveBuildingForPlayer(playerid, 1297, 1190.7734, -1299.7422, 15.9453, 0.25);
	return 1;
}
I am familiar with scripting, but I just dont understand why these building arent going away.. Please help me
EDIT : It compiles, but it doesn't work.


Re: RemoveBuildingForPlayer isn't working. Why? - Psymetrix - 23.09.2012

RemoveBuildingForPlayer is normally used under OnPlayerConnect as the players ID is passed to that callback.

Using RemoveBuildingForPlayer under OnGameModeInit won't work because no players will be connected and we have no way of finding out what player to remove the buildings for.

pawn Код:
public OnPlayerConnect(playerid)
{
    RemoveBuildingForPlayer(playerid, 5930, 1134.2500, -1338.0781, 23.1563, 0.25);
    // [...]
    return 1;
}
The reason new playerid; did not work is because it's value defaults to 0 (zero) and no player with the ID 0 is connected.