Useful Functions

Whatever... You're all like a little kid. Stop being an asshole and just try to talk like a normal human. Just say there are other ways to do it, why swearing and call each other retards etc?
Reply

Lol'd, why the fuck did I say 0xFFFF equals to -1 (but I thought it was), I'll just stfu next time, so Calgon won't come here and start flaming
Reply

Quote:
Originally Posted by Luka P.
Посмотреть сообщение
Lol'd, why the fuck did I say 0xFFFF equals to -1 (but I thought it was), I'll just stfu next time, so Calgon won't come here and start flaming
You only need to add 4 F's than you are right (if you are using 32 bit)
Reply

Page 128, yeah!


This works in my script, and I find it "quite" useful:

pawn Код:
stock GetPlayerInt(playerid, &interior)
    interior = GetPlayerInterior(playerid);
I believe a macro version would work too, but I'm not too sure, so I won't mess with it.
Reply

Where are you using that function? I think you have to write "more" code for that.

pawn Код:
// normal
new int = GetPlayerInterior(playerid);

// your function
new int;
GetPlayerInt(playerid, int);
Reply

Quote:
Originally Posted by Luka P.
Посмотреть сообщение
Where are you using that function? I think you have to write "more" code for that.

pawn Код:
// normal
new int = GetPlayerInterior(playerid);

// your function
new int;
GetPlayerInt(playerid, int);
He's using '&' before the variable so he can assign it in his variable he creates outside the function.
Reply

I know - it's variable reference. Still, you can use the normal method.

pawn Код:
new myVar;

public something()
{
        myVar = GetPlayerInterior(playerid);
}

// His method
new myVar;

public something()
{
        GetPlayerInt(playerid, myVar);
}
Reply

I know that, but I'm more comfortable with using functions than assigning variables to function manually.
Reply

life life

pawn Код:
stock LIFE(playerid, &Float:lifelife)
    return GetPlayerHealth(playerid, lifelife);
feel confortable
Reply

Quote:
Originally Posted by DarK TeaM PT
Посмотреть сообщение
life life

pawn Код:
stock LIFE(playerid, &lifelife)
    lifelife = GetPlayerLife(playerid);
feel confortable
GetPlayerLife? What lol?
Reply

Quote:
Originally Posted by RobinOwnz
Посмотреть сообщение
GetPlayerLife? What lol?
LMAO FAkeandgaysh*tnoob FAILED

Код:
stock GetPlayerLife(playerid,Float:life)
{
      GetPlayerHealth(playerid,life);
      return life;
}
Reply

Quote:
Originally Posted by GaGlets®
Посмотреть сообщение
LMAO FAkeandgaysh*tnoob FAILED

Код:
stock GetPlayerLife(playerid,Float:life)
{
      GetPlayerHealth(playerid,life);
      return life;
}
and its me the noob? super desoptimized XD i was thinking just in life XD
Reply

This "life" would be better "wife"
Reply

haha yes
Reply

Creating Deathzones with the Z Float:

On top of your script:
pawn Код:
#define MAX_DEAD_ARENAS 5
new ArenaEnabled[MAX_DEAD_ARENAS];
Functions:
pawn Код:
SwitchDeathCheck(daid, amount) //amount: 0 = disabled, 1 = enabled
{
    ArenaEnabled[daid] = amount;
    if(amount > 2)
    {
        printf("[VDA]Deatharena id: %d has an outstanding parameter (%d), please fix this...", daid, amount);
        SendRconCommand("exit"); //Closes the server safely
    }
}

SetDeathCheck(daid, playerid, Float: z)
{
    new Float: x, Float: y, Float: pz;
    if(ArenaEnabled[daid] == 1)
    {
        GetPlayerPos(playerid, x, y, pz);
        if(pz < z-0.1) //Check player if is under our general float z.
        {
            SetPlayerHealth(playerid, 0.0); //Killing the player who is lower then the general float z.
        }
    }
}
Example:
pawn Код:
public OnFilterScriptInit()
{
    print("\n- Create-A-Death-Arena script by Vandooz");
    SwitchDeathCheck(0, 1); //Death Arena nr.1 is now enabled
    return 1;
}

public OnPlayerUpdate(playerid) //Doesnt have to be onplayerupdate, just call in a 1 sec timer
{
    SetDeathCheck(0, playerid, 1000.0); //DONT DO GETPLAYERPOS, because its a general float for checks only.
    return 1;
}
Note: succesfully tested.
Reply

Info (sortWords)
Sorts words in an array according the option. (0: Z to A || 1: A to Z)

Code
pawn Код:
stock sortWords(words[][], A_to_Z, size = sizeof(words))
{
    for(new x; x != size - 1; ++x)
    {
        for(new y = x; y != size; ++y)
        {
            if((!A_to_Z) ? (strcmp(words[x], words[y]) < 0) : (strcmp(words[x], words[y]) > 0))
            {
                new
                    string[16]
                ;
                format(string, sizeof(string), words[x]);
                format(words[x], sizeof(string), words[y]);
                format(words[y], sizeof(string), string);
            }
        }
    }
    return 1;
}
Examples
Example, sorting some names from A to Z:
pawn Код:
new
    names[][16] =
    {
        "Benjamin",
        "Andreas",
        "Ryan",
        "Jason",
        "Michael",
        "Brad",
        "Dean",
        "Thomas",
        "Alex",
        "Ashley",
        "Lovely",
        "Carl",
        "Johnattan",
        "Macy",
        "Vanessa",
        "Eddy",
        "Curtis",
        "Alan",
        "Lacy",
        "Faith",
        "Dianna",
        "Esmee",
        "Glenn",
        "Jordy",
        "Yasmin",
        "Tracy",
        "Zena",
        "Wendy"
      }
;
sortWords(names, 1);
   
for(new i; i != sizeof(names); ++i)
{
    printf("%s", names[i]);
}
Will sort the array like:
pawn Код:
Alan
Alex
Andreas
Ashley
Benjamin
Brad
Carl
Curtis
Dean
Dianna
Eddy
Esmee
Faith
Glenn
Jason
Johnattan
Jordy
Lacy
Lovely
Macy
Michael
Ryan
Thomas
Tracy
Vanessa
Wendy
Yasmin
Zena
Otherwise if we use the same but then as setting 0 for A_to_Z. Then it will sort from Z to A, so:
pawn Код:
Zena
Yasmin
Wendy
Vanessa
Tracy
Thomas
Ryan
Michael
Macy
Lovely
Lacy
Jordy
Johnattan
Jason
Glenn
Faith
Esmee
Eddy
Dianna
Dean
Curtis
Carl
Brad
Benjamin
Ashley
Andreas
Alex
Alan
NOTE: Please note that you can increase the value of the array size if need. But keep in mind, it's recommended to keep it as low as possible.
Reply

Find IP:

Код:
stock IsIP(const str[], bool:port = false) // By LeePL
{
    for(new cIP[2]; cIP[0] != strlen(str); cIP[0]++)
    {
        switch(str[cIP[0]])
        {
            case '.', ' ', ':', ',', '*', '/', ';', '\\', '|' : continue;
            case '0' .. '9': cIP[1]++;
            default: cIP[1] = 0;
        }

        if((port == false) && (cIP[1] == 8))
        {
            new strex[8];
            strmid(strex, str, cIP[0] - 7, cIP[0]);
            if(IsNumeric(strex))
                return 0;

            return 1;
        }

        if((port == true) && (cIP[1] == 12))
        {
            new strex[12];
            strmid(strex, str, cIP[0] - 11, cIP[0]);
            if(IsNumeric(strex))
                return 0;

            return 1;
        }
    }
    return 0;
}
Reply

At IsPlayerAlive, why not just GetPlayerHealth?
Reply

i don't know but it isn't made by me so...
Reply

@Dark Team PT:
This should be enough:
pawn Код:
stock IsPlayerAlive(playerid)
        return GetPVarInt(playerid, "Alive");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)