stock SendPlayerToHell(playerid)
{
SetPlayerPos(playerid, 0, 0, 0);
SetPlayerHealth(playerid, 1);
SetPlayerInterior(playerid, 231);
SetPlayerWeather(playerid, 555);
ResetPlayerMoney(playerid);
SetPlayerArmedWeapon(playerid, 0);
}
)
#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
stock GetConnectedPlayers()
{
return Itter_Count(Player);
}
|
pawn Код:
|
|
pawn Код:
|
#define GetConnectedPlayers() \
Itter_Count(Player)
|
Me.
pawn Код:
|


xD
new IsCountdownRunning;
#define Blue "{003DF5}"
#define Red "{F5003D}"
#define Green "{3DF500}"
#define White "{FFFFFF}"
#define SCM SendClientMessage
#define SCMTA SendClientMessageToAll
stock Wait(ms) //Credits to Y_Less
{
ms += GetTickCount();
while (GetTickCount() < ms) {}
}
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;
}
|
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 ![]() |
stock GetAverageNumber(...)
{
new numArgs = numargs(), Total;
for(new i = 0; i != numArgs; i++) Total += getarg(i, 0);
Total /= numArgs;
return Total;
}
|
Yo, can anyone make like GetDifferenceBetweenNumbers(number1,number2)??
So like GetDifferenceBetweenNumbers(1,5) would return 4 |