OnPlayerStateChange problem
#1

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?
Reply
#2

// 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;
}
}

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;
}
Reply
#3

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
Reply
#4

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?
Reply
#5

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)