[Tutorial] Vehicle Boost and Jump!
#1

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>
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]!
Reply
#2

Nice tutorial mate, Rep +
Reply
#3

Did you copy this and just changed a few things? If so give credit to Aloushi.
Reply
#4

This is not tutorial, read this please
Reply
#5

Quote:
Originally Posted by ejb
View Post
Did you copy this and just changed a few things? If so give credit to Aloushi.
Credits added!
Reply
#6

Add this, add this, add this. Nothing explained, so not a tutorial.
Reply
#7

Quote:
Originally Posted by Vince
View Post
Add this, add this, add this. Nothing explained, so not a tutorial.
Not the best explainer but tried to explain abit more, better?
Reply
#8

maybe sctrmp version ?

p.s don't write that zcmd is better and etc . I just need a sctrmp version.
Reply
#9

Quote:
Originally Posted by Immortal_LTU
View Post
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!
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)