Useful Functions

SendPlayerToHell(playerid)

pawn Код:
stock SendPlayerToHell(playerid)
{
     SetPlayerPos(playerid, 0, 0, 0);
     SetPlayerHealth(playerid, 1);
     SetPlayerInterior(playerid, 231);
     SetPlayerWeather(playerid, 555);
     ResetPlayerMoney(playerid);
     SetPlayerArmedWeapon(playerid, 0);
}
i just made this randomly for fun. idk if i misspelled anything. im 2 lazy 2 check. hehe.
Reply

That's not a function.
Reply

o. well sorry to spam? i guess.
Reply

@the_chaoz
I understand what Y_less mean, but he too exaggerated to the point of saying 'an error code'.
Both are wrong (i and Y_less)

Hey, i not am stubborn, only is my point view (and Y_Less either persuade me )
Reply

mmm no i think that u are wrong but that's just a personal opinion based on time of scripting.
Reply

@the_chaoz
Is my personal opinion and style of programmer, I believe that they must respect.

@Y_Less
Hey, i make a test superficial

pawn Код:
#define MaxSlots (500)
#define IsPlayerConnect(%0)             (Player1[%0])
#define LoopPlayers(%0)                  for(new %0,_%0; %0 != -1; %0 = Player2[_%0],++_%0)

new Player2[(MaxSlots + 1)] = -1;
new Player1[(MaxSlots + 1)] = false;

stock CallOnPlayerConnect()
{
    new i = 0;
    for ( new x; x < (sizeof Player1 - 1); x++)
    {
        if(!IsPlayerConnected(x)) continue;
        Player2[i] = x;
        Player1[x] = 10;
        i++;
    }
    return Player2[i++] = -1;
}

public OnPlayerConnect(playerid)
{
    CallOnPlayerConnect();
    return true;
}

public OnFilterScriptInit()
{
    new TickCount = 0;
    CallOnPlayerConnect();
    #define MAX_TESTS (99999)
   
    //1 Method
    TickCount = GetTickCount();
    for(new b; b < MAX_TESTS; b++)
    {
        for ( new slots = GetMaxPlayers( ), i; i < slots; i++ )
        {
            if(!IsPlayerConnected(i)) continue;
            //code
        }
    }
    printf("[1 METHOD] %d ms",GetTickCount() - TickCount);
   
    //2 Method
    TickCount = GetTickCount();
    for(new b; b < MAX_TESTS; b++)
    {
        LoopPlayers(i)
        {
            //code
        }
    }
    printf("[2 METHOD] %d ms",GetTickCount() - TickCount);
   
    //3 Method
    TickCount = GetTickCount();
    for(new b; b < MAX_TESTS; b++)
    {
        for(new i; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                //code
            }
        }
    }
    printf("[3 METHOD] %d ms",GetTickCount() - TickCount);
   
    //4 Method
    TickCount = GetTickCount();
    for(new b; b < MAX_TESTS; b++)
    {
        foreach(Player, i)
        {
        }
    }
    printf("[4 METHOD] %d ms",GetTickCount() - TickCount);
    return true;
}
Код:
#Result

[01:02:53] [1 METHOD] 621 ms
[01:02:53] [2 METHOD] 10 ms
[01:02:55] [3 METHOD] 2406 ms
[01:02:55] [4 METHOD] 6 ms
Foreach is 1,4x then faster ..
But is this a good result for my simple code, I made a few in minutes.
Reply

Here is a place to post tested codes that work in your gamemode, so, i think that post tests, and comparisons, don't are useful for nobody. I suggest you create a topic in scripting discussion for this.
Reply

pawn Код:
stock GetConnectedPlayers()
{
       return Itter_Count(Player);
}
That's what smart people do.
Reply

Who wants to bet 'SmallMoke' was [FeK]DraKiNs?

Quote:
Originally Posted by kLx
Посмотреть сообщение
pawn Код:
stock GetConnectedPlayers()
{
       return Itter_Count(Player);
}
That's what smart people do.
I actually never thought of that, nice one.
Reply

Deleted
Reply

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
Who wants to bet 'SmallMoke' was [FeK]DraKiNs?
Me.



Quote:
Originally Posted by kLx
Посмотреть сообщение
pawn Код:
stock GetConnectedPlayers()
{
       return Itter_Count(Player);
}
That's what smart people do.
pawn Код:
#define GetConnectedPlayers() \
        Itter_Count(Player)
xD
Reply

Quote:
Originally Posted by MrDeath537
Посмотреть сообщение
Me.





pawn Код:
#define GetConnectedPlayers() \
        Itter_Count(Player)
xD
lol nice! xD
Reply

Very simple and awesome countdown!
By: Markx
On top:

pawn Код:
new IsCountdownRunning;

#define Blue    "{003DF5}"
#define Red     "{F5003D}"
#define Green   "{3DF500}"
#define White   "{FFFFFF}"
#define SCM     SendClientMessage
#define SCMTA   SendClientMessageToAll
Somewhere in the script:
pawn Код:
stock Wait(ms) //Credits to Y_Less
{
    ms += GetTickCount();
    while (GetTickCount() < ms) {}
}
pawn Код:
CMD:countdown(playerid, params[])
{
    new string[128];
    if(IsCountdownRunning == 1) return SCM(playerid, -1, ""Red"[Error] "White"Please try again later");
    format(string, sizeof(string), ""Green"[System] "White"%s has started the countdown!", GetName(playerid));
    SCM(playerid, -1, string);
    IsCountdownRunning = 1;
    GameTextForAll("~b~3", 1000, 3);
    PlaySoundForAll(1056);
    Wait(1000);
    GameTextForAll("~g~2", 1000, 3);
    PlaySoundForAll(1056);
    Wait(1000);
    GameTextForAll("~y~1", 1000, 3);
    PlaySoundForAll(1056);
    Wait(1000);
    GameTextForAll("~r~G~w~O!", 1000, 3);
    PlaySoundForAll(1057);
    Wait(10000);
    IsCountdownRunning = 0;
    return 1;
}
Reply

Yes, it's quite simple. But it's not really meant to use this as password encryption.
Reply

Yeah I already thought that :P - But I still don't know why it's been made. Is it maybe a VERY old encryption, when things like Whirlpool didn't exist? :P We're time travelling, which year is it, 1118? (jk ofc)
Reply

Oh yes sorry, forgot about the wikie (*facepalm*). Thank you btw.
Reply

Quote:
Originally Posted by [HLF]Southclaw
Посмотреть сообщение
You can use it for things like those reaction tests, it comes up and the first person to decipher it gets a prize or to reveal a puzzle clue or answer or something like that, read the wiki page it tells you more about it
That's a pretty smart idea, never thought of that, ha.
Reply

Can't believe something so simple as this isn't anywhere to be found. :P

pawn Код:
stock GetAverageNumber(...)
{
    new numArgs = numargs(), Total;
    for(new i = 0; i != numArgs; i++) Total += getarg(i, 0);
    Total /= numArgs;
    return Total;
}
Reply

Yo, can anyone make like GetDifferenceBetweenNumbers(number1,number2)??
So like GetDifferenceBetweenNumbers(1,5) would return 4
Reply

Quote:
Originally Posted by [KO]KillerThriller
Посмотреть сообщение
Yo, can anyone make like GetDifferenceBetweenNumbers(number1,number2)??
So like GetDifferenceBetweenNumbers(1,5) would return 4
Bad joke, just do 5 - 1 if you are serious
Reply


Forum Jump:


Users browsing this thread: 63 Guest(s)