OnPlayerExitVehicle not being called correctly? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: OnPlayerExitVehicle not being called correctly? (
/showthread.php?tid=166744)
OnPlayerExitVehicle not being called correctly? -
(.Aztec); - 09.08.2010
Well, I have this code as my OnPlayerEnterVehicle:
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(PoliceCar(vehicleid))
{
if(!ispassenger)
{
if(File[playerid][Faction] != 1)
{
new vehid = GetPlayerVehicleID(playerid);
new string[35];
format(string, sizeof(string), "[ALERT] Cruiser %d has been stolen!", vehid);
SendFactionMessage(1, orange, string);
StolePDCar[playerid] = 1;
SendClientMessage(playerid, orange, "[ALERT] You hear a slight beeping coming from inside the engine.");
//if(File[playerid][Achievement1] == 0) { File[playerid][Achievement1] = 1; SendClientMessage(playerid, orange, "[INFO] Achievement Unlocked! (Steal your first Police Car!)"); }
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(File[i][Faction] == 1)
{
SetPlayerMarkerForPlayer(i, playerid, red);
SetPlayerColor(playerid, white);
SetTimerEx("PDDetect", 2000, 1, "i", playerid);
}
}
}
}
}
return 1;
}
This calls correctly, and works fine. The problem lies in OnPlayerExitVehicle:
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
if(PoliceCar(vehicleid))
{
if(StolePDCar[playerid] == 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
SetPlayerMarkerForPlayer(i, playerid, 0xFFFFFF00);
SetPlayerColor(playerid, white);
StolePDCar[playerid] = 0;
}
}
}
return 1;
}
Why the hell won't it set the marker invisible again? To make sure it wasn't just the function, I even added a variable (StolePDCar[MAX_PLAYERS]) and tested it in OnPlayerStreamIn, and it still doesn't do what it's meant to do.
OnPlayerStreamIn:
pawn Код:
public OnPlayerStreamIn(playerid, forplayerid)
{
if(StolePDCar[playerid] == 0)
{
SetPlayerMarkerForPlayer(forplayerid, playerid, 0xFFFFFF00);
}
else if(StolePDCar[playerid] == 1)
{
SetPlayerMarkerForPlayer(forplayerid, playerid, red);
SetPlayerColor(playerid, white);
}
return 1;
}
Re: OnPlayerExitVehicle not being called correctly? -
Matthias_ - 09.08.2010
Try sending a debug message so you're sure SetPlayerMarkerForPlayer is the problem. I've got some bad experience with that function.