OnPlayerStateChange problem - 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: OnPlayerStateChange problem (
/showthread.php?tid=254847)
OnPlayerStateChange problem -
grand.Theft.Otto - 13.05.2011
I have a kart deathmatch where you drive a kart and driveby on the top of four dragons casino. I'm trying to make it respawn the player who exits the vehicle and say you have been disqualified, but it is not working, here is the code:
pawn Код:
// under onplayerstatechange
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
if(GetPlayerVehicleID(playerid),571)
{
SpawnPlayer(playerid);
SendClientMessage(playerid, red, "You Have Been Disqualified From Kart DM. Reason: Vehicle Exited.");
GameTextForPlayer(playerid,"~p~disqualified ~n~~w~reason: ~b~exited vehicle",5000,3);
return 1;
}
}
Anyone know why?
Re: OnPlayerStateChange problem -
ViperSniper - 13.05.2011
// under onplayerstatechange
if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
i
f(GetPlayerVehicleID(playerid),571)
{
SpawnPlayer(playerid);
SendClientMessage(playerid, red, "You Have Been Disqualified From Kart DM. Reason: Vehicle Exited.");
GameTextForPlayer(playerid,"~p~disqualified ~n~~w~reason: ~b~exited vehicle",5000,3);
return 1;
}
}
The player has exited the vehicle way before that is called.
Do this instead:
Код:
public OnPlayerExitVehicle(playerid)
{
if(GetPlayerVehicleID(playerid) == 571)
{
SpawnPlayer(playerid);
SendClientMessage(playerid, red, "You Have Been Disqualified From Kart DM. Reason: Vehicle Exited.");
GameTextForPlayer(playerid,"~p~disqualified ~n~~w~reason: ~b~exited vehicle",5000,3);
return 1;
}
return 1;
}
Re: OnPlayerStateChange problem -
Donya - 13.05.2011
wrong still..
if(GetPlayerVehicleID(playerid),571)
pawn Код:
if(GetPlayerVehicleID(playerid) == 571)
but for state changes, you'll have to store there last vehicleid in a variable
Re: OnPlayerStateChange problem -
Infamous - 13.05.2011
Quote:
Originally Posted by Donya
wrong still.. if(GetPlayerVehicleID(playerid),571)
pawn Код:
if(GetPlayerVehicleID(playerid) == 571)
but for state changes, you'll have to store there last vehicleid in a variable
|
That is the vehicle model rather than the script ID for the vehicle.
This would be better practice if you wish to get the vehicle model:
pawn Код:
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 598 )
@grand.Theft.Otto, rather than respawning the player why don't you set their position after they have been disqualified?
Re: OnPlayerStateChange problem -
ViperSniper - 13.05.2011
Quote:
Originally Posted by Infamous
That is the vehicle model rather than the script ID for the vehicle.
This would be better practice if you wish to get the vehicle model:
pawn Код:
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 598 )
@grand.Theft.Otto, rather than respawning the player why don't you set their position after they have been disqualified?
|
Yes, you are right, I blanked the fact he was trying to use the Vehicle Slot as Vehicle Model and fixed the main problem, thanks for pointing this out.
I believe calling SpawnPlayer(playerid) takes them back to where they would go on death or login.