Exit veh with F key - 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: Exit veh with F key (
/showthread.php?tid=113401)
Exit veh with F key -
Blt950 - 13.12.2009
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?
Re: Exit veh with F key -
Zamaroht - 13.12.2009
Remember that you are expecting the player to press the action button to remove him (That is, press the TAB button).
Re: Exit veh with F key -
Blt950 - 13.12.2009
Oh lol..
My bad.. Okey what is the F button? If not allready defined, any plugins that defines it ?
Re: Exit veh with F key -
saiberfun - 13.12.2009
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
Re: Exit veh with F key -
Blt950 - 13.12.2009
Okey, and how to check if its pressed?
if(newkeys == <id>) ?
Re: Exit veh with F key -
Zamaroht - 13.12.2009
┤Şą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.
Re: Exit veh with F key -
Blt950 - 13.12.2009
Okey resolved. I got the ID 16 which is KEY_SECONDARY_ATTACK
at
https://sampwiki.blast.hk/wiki/GetPlayerKeys
Thanks all