getplayerstate bug
#1

hey guys, i've been trying to make it on my server that if you exit a vehicle during a race, you get kicked out of the race.

The way i've done this was by setting a timer whenever the player joins a race to check if the players state is PLAYER_STATE_ONFOOT every 3 seconds, and if it was ONFOOT then it should kick the player from the race.

well, not so much. instead, it doesn't kick the player when they exit their vehicle. here is my coding

(note: I've tried it as a function and a public, i just get a massive spam of "You exited your vehicle..." in return)

PHP код:
forward ExitVehicleRace(playerid);
stock ExitVehicleRace(playerid)
{
    if(
GetPlayerState(playerid == PLAYER_STATE_ONFOOT))
    {
    
JoinCount--;
    
Joined[playerid] = false;
    
DestroyVehicle(CreatedRaceVeh[playerid]);
    
DisablePlayerRaceCheckpoint(playerid);
    
TextDrawHideForPlayer(playeridRaceInfo[playerid]);
    
CPProgess[playerid] = 0;
    
KillTimer(InfoTimer[playerid]);
    
TogglePlayerControllable(playeridtrue);
    
SetCameraBehindPlayer(playerid);
    
TeleportAllowed[playerid] = 1;
    
SetPlayerPos(playeridposX[playerid], posY[playerid], posZ[playerid]);//
    
SetPlayerFacingAngle(playeridposA[playerid]);                        // savepos and loadpos
    
SetPlayerInterior(playeridInterior[playerid]);                       //
    
SetPlayerVirtualWorld(playeridVirtualWorld[playerid]);//-------------//
    
pInfo[playerid][pRaceExits]++;
    
SendClientMessage(playeridRED,  "You Exited your Vehicle, therefore Disqualifying you from the Race!");
    
KillTimer(ExitVehicleRace(playerid));
    }
    return 
1;

Reply
#2

That's so stupid to have a timer here. You can just use OnPlayerStateChange and check if the oldstate was PLAYER_...._DRIVER, and the newstate is PLAYER_..._ONFOOT. And inside it check if the player is in race. Example:

pawn Код:
public OnPlayerStateChange(..........)
{
      if(oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
      {
               if(Joined[playerid] == true)
               {
                     // Reset their vars and send the message here.
               }
       }
       return 1;
}
Reply
#3

thanks alot for that

sometimes, i feel like an idiot but i do need the help, it's how i learn

problem solved +repped
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)