[Tutorial] How to make: Your own airbreak command for faster travelling!
#1

This only works on your own server, in your own script.
This isn't a hacking tool, merely a tool that will help you get around the world quicker.


Requirements for this setup to work:

An enum of pAdmin
ZCMD



pawn Код:
CMD:east(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5) {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x+13, y, z);
    }
    else
    {
        SendClientMessage(playerid, red, "Ha, you wish!");
    }
    return 1;
}

CMD:west(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5) {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x-13, y, z);
    }
    else
    {
        SendClientMessage(playerid, red, "Ha, you wish!");
    }
    return 1;
}

CMD:north(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5) {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x, y+13, z);
    }
    else
    {
        SendClientMessage(playerid, red, "Ha, you wish!");
    }
    return 1;
}

CMD:south(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5) {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x, y-13, z);
    }
    else
    {
        SendClientMessage(playerid, red, "Ha, you wish!");
    }
    return 1;
}

CMD:up(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5) {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x, y, z+13);
    }
    else
    {
        SendClientMessage(playerid, red, "Ha, you wish!");
    }
    return 1;
}

CMD:down(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] >= 5) {
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x, y, z-13);
    }
    else
    {
        SendClientMessage(playerid, red, "Ha, you wish!");
    }
    return 1;
}
Now, you're wondering what each of these commands does.

They all use the same principle:

if(PlayerInfo[playerid][pAdmin] >= 5)

- This baby here checks if you're an administrator level 5+ or not. How does it do that? Well there's this sweet thing I got from making a login & register system, and it was enumerators. Basically something that gets written inside of an .ini file(a type of text document) that the script uses and reads from. In that .ini, it says:

Admin: X
X = the number it was set to.
It's 0 if you aren't an admin, 1 to 999 if you are. I typically use 1-5.


new Float, Float:y, Float:z;

Defines the Float:X, y, z we want to use in SetPlayerPos.


GetPlayerPos(playerid, x, y, z);

This gets the current position of the player which executed the command. The X, The Y and the Z.

SetPlayerPos(playerid, x, y, z-13);

This sets the player position to his previous X and Y, but adds -13 to the Z.


This doesn't mean it'll set your position right from where you're looking at, or forwards.

It'll set your position from wherever you are to, according to the command, to either West, East, North, South. Or up and down in that case.


Y in a negative(-X) represents South
Y in a positive(+X) represents North
X in a negative(-X) represents West
X in a positive(+X) represents East
Z in a negative(-X) represents down.
Z in a positive(+X) represents up.


I figured you can stick these commands to an OnPlayerKeyStateChange, but for now I'm using the keybinds(Chaos AD keybinder).



If you don't have an enumerator system, or ZCMD, make sure to just copy these lines into your command and you're set:

pawn Код:
new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(playerid, x, y, z-13);

Edited the X, Y, Z to your own will.

This means, in the case above, changing the "-13" number.

How it can look:

x-1 or x+1
y-1 or y+1
z-1 or z+1
Reply
#2

First of all, you didn't defined pAdmin. Maybe other players have different enums. Anyway, this code it's very bad optimized.
This could be good by pressing keys, this it's more efficiently and works better.
To be more realistic you should put an Animation or a Special Action with parachute.

This code (you get idea) should be better:

pawn Код:
#include <a_samp>
#include <zcmd>
 
//------------------------------------------------------------------------------
 
new bool:SupermanActivated[MAX_PLAYERS];
 
//------------------------------------------------------------------------------
 
CMD:superman(playerid, params[])
{
    if(SupermanActivated[playerid] == false)
    {
        SupermanActivated[playerid] = true;
        SendClientMessage(playerid, -1, "{FF0000}[SUPERMAN]: {FFFFFF}You activated {FF0000}Superman's Mod.");
    }
    else if(SupermanActivated[playerid] == true)
    {
        SupermanActivated[playerid] = false;
        SendClientMessage(playerid, -1, "{FF0000}[SUPERMAN]: {FFFFFF}You dezactivated {FF0000}Superman's Mod.");
    }
    return 1;
}
 
//------------------------------------------------------------------------------
 
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    if(SupermanActivated[playerid] == true)
    {
        if(newkeys && KEY_SPRINT)
        {
            SetPlayerPos(playerid, X, Y, Z+10);
        }
        else if(newkeys && KEY_JUMP)
        {
            SetPlayerPos(playerid, X, Y, Z-10);
        }
        //(........)
    }
    return 1;
}
Codes:

- www.pastebin.com;
- Keys;
- OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
Reply
#3

He already stated you need to use your own enumators, and frankly I don't think he wants it to be key-based. You can even do this if you dont use enumators:

pawn Код:
#define PlayerInfo[%0][pAdmin] IsPlayerAdmin(%0)
Reply
#4

Quote:
Originally Posted by Abagail
Посмотреть сообщение
He already stated you need to use your own enumators, and frankly I don't think he wants it to be key-based.
Oh, I'm sorry. Didn't saw.
Actually, I think it's better to make this with keys.
If you want to fly you need everytime to type commands: /East, /West.
Reply
#5

Quote:
Originally Posted by HY
Посмотреть сообщение
Oh, I'm sorry. Didn't saw.
Actually, I think it's better to make this with keys.
If you want to fly you need everytime to type commands: /East, /West.
I also stated:
Quote:
Originally Posted by me
I figured you can stick these commands to an OnPlayerKeyStateChange, but for now I'm using the keybinds(Chaos AD keybinder).
Did you even read the entire topic or were you so focused to express your scripting prowess over me to ignore it?
Reply
#6

Just create one command that gives admins a jetpack, much easier to move around.
Or give the admin a fast vehicle.

Using one command to only move 13 metres in a specified direction is too slow to move around.
And what happens if you suddenly move into a building?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)