little help here with keys - 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)
+--- Thread: little help here with keys (
/showthread.php?tid=320130)
little help here with keys -
Jay. - 21.02.2012
hey can someone explain to me why this isnt working and maybe
give me a fix?
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{ if((newkeys == KEY_SUBMISSION) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new Float:va,Float:vx,Float:vy,Float:vz,vehid;
vehid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehid,vx,vy,vz);
SetVehiclePos(vehid,vx,vy,vz+10);
GetVehicleZAngle(GetPlayerVehicleID(playerid),va);
SetVehicleZAngle(GetPlayerVehicleID(playerid),va);
GameTextForPlayer(playerid,"~Y~Vehicle flipped",3000,5);
PlayerPlaySound(playerid,1137,0.0,0.0,0.0);
RepairVehicle(vehid);
}
if((newkeys == KEY_JUMP) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new Float:X,Float:Y,Float:Z, vehid;
vehid = GetPlayerVehicleID(playerid);
GetVehiclePos(vehid,X,Y,Z);
SetVehiclePos(vehid,Y,X,Z+60);
CreateExplosion(X, Y, Z, 8, 10.0);
GameTextForPlayer(playerid,"~G~ENJOY YOUR SUPRISE!~N~~N~~N~~W~SUPRISE:~W~ JUMP + BOOOOM!~n~Unlucky!",3000,5);
}
return 1;
}
The first is working the carjump + flip
but the second one, suprise isn't.
Thanks
Re: little help here with keys -
Boooth - 21.02.2012
Well first off you should not be doing if(newkeys == KEY_JUMP), its should be if(newkeys & KEY_JUMP).
(Will edit)
Re: little help here with keys -
JhnzRep - 22.02.2012
Use SetVehicleVelocity/GetVehicleVelocity for the jump.