Exit veh with F key
#1

Hey, I just came up with a idea to eject player from the vehicle if it's turned off engine (Then player is freezed)
I made this code

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
  if(newkeys == KEY_ACTION)
    {
      if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
          new VID = GetPlayerVehicleID(playerid);
            if(VehicleStarted[VID] == 0)
            {
              RemovePlayerFromVehicle(playerid);
                TogglePlayerControllable(playerid, 1);
            }
        }
    }
    return 1;
}
It doesn't seems to work. Anyone see a problem?
Reply
#2

Remember that you are expecting the player to press the action button to remove him (That is, press the TAB button).
Reply
#3

Oh lol..

My bad.. Okey what is the F button? If not allready defined, any plugins that defines it ?
Reply
#4

Quote:
Originally Posted by Blt950
Oh lol..

My bad.. Okey what is the F button? If not allready defined, any plugins that defines it ?
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new str[8];
    format(str,sizeof(str),"%i",newkeys);
    SendClientMessage(playerid,YOURCOLOr,str);
    return 1;
}
this should show the id of key thats pressed
might be that u need %d or %s for %i instead but im not sure
Reply
#5

Okey, and how to check if its pressed?

if(newkeys == <id>) ?
Reply
#6

┤ŞąiBЄЯҒПŋ├ has just gave you a code to know which id is which key. You would need to put that piece of code in your gamemode, press the F key, and then check the server console, it should show you the IDs of the keys you are pressing.
Reply
#7

Okey resolved. I got the ID 16 which is KEY_SECONDARY_ATTACK
at https://sampwiki.blast.hk/wiki/GetPlayerKeys

Thanks all
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)