25.02.2013, 16:35
(
Last edited by paul988; 03/03/2013 at 01:27 PM.
)
Vehicle Boost & Jump
(My First Tutorial so be nice)
Needed for the command!
Get zcmd by Zeex here! https://sampforum.blast.hk/showthread.php?tid=91354
First we need to include zcmd!
This is for the commad we will make, If you havent, download zcmd by Zeex above and drop it into
pawno/includes!
pawn Code:
#include <zcmd>
This is to detect if player wants to use boost or not!
pawn Code:
new VehicleBoost[MAX_PLAYERS];
here we are adding the boost and the jump hotkeys, KEY_FIRE = LMB(Left Mouse Button)
and KEY_CROUCH = H or CAPS LOCK button!
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if(newkeys & KEY_FIRE)
{
if(VehicleBoost[playerid] == 1)
{
new Float:vx,Float:vy,Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid),vx,vy,vz);
SetVehicleVelocity(GetPlayerVehicleID(playerid), vx * 1.8, vy *1.8, vz * 1.8);
}
}
}
if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
if (newkeys & KEY_CROUCH)
{
new Float:x, Float:y, Float:z;
GetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z);
SetVehicleVelocity(GetPlayerVehicleID(playerid),x,y,z+0.3);
}
}
return 1;
}
If boost is already activated it will be deactivated but if its deactivated
it will activate the boost!
pawn Code:
CMD:boost(playerid, params[])
{
if(VehicleBoost[playerid] == 1)
{
SendClientMessage(playerid, -1, "[!] Boost deactivated. ");
VehicleBoost[playerid] = 0;
}
else
{
SendClientMessage(playerid, -1, "[!] Boost activated! ");
VehicleBoost[playerid] = 1;
}
return 1;
}
This is to deactivate boost when player spawns!
pawn Code:
public OnPlayerSpawn(playerid)
{
VehicleBoost[playerid] = 0;
return 1;
}
This is to deactivate boost on player disconnect
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
VehicleBoost[playerid] = 0;
return 1;
}
If command /boost is activated
Then LMB or CTRL to boost!
Credits:
Edit: Changed the [code] into [pawn]!