Vehicle Boost and Jump! -
paul988 - 25.02.2013
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!
Now we need to make an global array!
This is to detect if player wants to use boost or not!
pawn Code:
new VehicleBoost[MAX_PLAYERS];
We need to add this to OnPlayerKeyStateChange!
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;
}
Then we need to add a /boost command!
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;
}
OnPlayerSpawn we need to add!
This is to deactivate boost when player spawns!
pawn Code:
public OnPlayerSpawn(playerid)
{
VehicleBoost[playerid] = 0;
return 1;
}
And on OnPlayerDisconnect we need to add!
This is to deactivate boost on player disconnect
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
VehicleBoost[playerid] = 0;
return 1;
}
Hotkey H or CAPS to Jump!
If command /boost is activated
Then LMB or CTRL to boost!
Credits:
Edit: Changed the [code] into [pawn]!
Re: Vehicle Boost and Jump! -
Ryan_Bowe - 25.02.2013
Nice tutorial mate, Rep +
Re: Vehicle Boost and Jump! -
ejb - 25.02.2013
Did you copy
this and just changed a few things? If so give credit to Aloushi.
Re: Vehicle Boost and Jump! -
RenSoprano - 26.02.2013
This is not tutorial, read
this please
Re: Vehicle Boost and Jump! -
paul988 - 26.02.2013
Quote:
Originally Posted by ejb
Did you copy this and just changed a few things? If so give credit to Aloushi.
|
Credits added!
Re: Vehicle Boost and Jump! -
Vince - 26.02.2013
Add this, add this, add this. Nothing explained, so not a tutorial.
Re: Vehicle Boost and Jump! -
paul988 - 28.02.2013
Quote:
Originally Posted by Vince
Add this, add this, add this. Nothing explained, so not a tutorial.
|
Not the best explainer but tried to explain abit more, better?
Re: Vehicle Boost and Jump! -
Immortal_LTU - 28.02.2013
maybe sctrmp version ?
p.s don't write that zcmd is better and etc . I just need a sctrmp version.
Re: Vehicle Boost and Jump! -
paul988 - 28.02.2013
Quote:
Originally Posted by Immortal_LTU
maybe sctrmp version ?
p.s don't write that zcmd is better and etc . I just need a sctrmp version.
|
pawn Code:
if(!strcmp(cmdtext, "/boost", true))
{
if(VehicleBoost[playerid] == 1)
{
SendClientMessage(playerid, -1, "[!] Boost deactivated. ");
VehicleBoost[playerid] = 0;
}
else
{
SendClientMessage(playerid, -1, "[!] Boost activated! ");
VehicleBoost[playerid] = 1;
}
return 1;
}
Think this should work
Edit: Havent tested it tho!
Re: Vehicle Boost and Jump! -
insp3ctor - 30.06.2014
Code:
if(strcmp(cmdtext, "/boost", true) == 0)
{
if(VehicleBoost[playerid] == 1)
{
SendClientMessage(playerid, -1, "[!] Boost deactivated. ");
VehicleBoost[playerid] = 0;
}
else
{
SendClientMessage(playerid, -1, "[!] Boost activated! ");
VehicleBoost[playerid] = 1;
}
return 1;
}
tested