[Include] [INC] Amit_B's Define Functions
#1

Amit_B's Define Functions

This script is an simple library, that allows you to use new options in scripting, that created with defines.
The library contain 13 new options.

Download: http://pastebin.com/f777a0ee8

New options:

OP(i)
A shortcut to an "all connected players" loop. "i" is the variable.
Example:
pawn Code:
for(OP(i)) SetPlayerHealth(i,100.0);
This is just like doing:
pawn Code:
for(new i=0;i<MAX_PLAYERS;i++) if(IsPlayerConnected(i)) SetPlayerHealth(i,100.0);
OA(i)
This is almost exactly like doing "OP", the difference is that here it referenced to the RCON admins.
Example:
pawn Code:
for(OA(admins)) SendClientMessage(admins,0xffffffaa,"Hi Admins!");
OA2(i)
This options is exactly like "OA", but here you can send the message to the admins in your own admin script.
Just replace the define "Your_IsPlayerAdmin_Function" in the script to your "IsPlayerAdmin" function, and it will work.
Example:
pawn Code:
for(OA2(admins)) SendClientMessage(admins,0xffffffaa,"Hi Admins!");
OA3(i)
This option is just like "OA" and "OA2" together.

rgba2hex(i,i,i,i)
Just like the known function "rgba2hex", but in define.

K
An nice option that giving you an shortcut word of the code "*1000".
Example:
pawn Code:
new x = 1K; // x equal to 1000
SendPlayerFormat(i,x,v,s,...)
Sending a formatted text (note: this is exactly like "new ... format ... SendClientMessage", and its means that you can't use "return SendPlayerFormat".
i = The ID of the player to send the message
x = Message color
v = Some variable name
s = The text
... = All of the other variables
pawn Code:
new n[MAX_PLAYER_NAME];
GetPlayerName(playerid,n,sizeof(n));
SendPlayerFormat(playerid,0xffffffaa,string," Your name: %s",n);
SendPlayerFormat(playerid,0xffffffaa,string2," ID: %d | Skin: %d",playerid,GetPlayerSkin(playerid));
SendAllFormat(x,v,s,...)
Just like the SendPlayerFormat, but this show the message to all of the players.

PlaySound(i,i)
Play a sound to an player (without the bugged function parameters).

fcreate(s)
Creates a file.

dexist(s)
Checks if some directory is exists.

equal(s,s)
Shortcut of the comparison ability on the "strcmp" function (also, fixing it's bug).

sleep(i)
Exactly like the "sleep" keyword, and working in all of the functions.

Bugs: I did'nt test the script. But all the new thing need to work... if you find a bug, please report in this topic.

Enjoy =]
Reply
#2

Well, nice job, these functions will make scripting faster
Reply
#3

stock sleep2(s)
{
assert s > 0 && s < cellmax;
new nt[4], ot[4];
gettime(ot[0],ot[1],ot[2]);
ot[3] = ot[2] + (ot[1]*60) + (ot[0]*600);
while(nt[3] != (ot[3]+seconds))
{
gettime(nt[0],nt[1],nt[2]);
nt[3] = nt[2] + (nt[1]*60) + (nt[0]*600);
}
}
stupid thing in one thread, because of server death with it.
better use plugin Xthreads, or any other with system sleep func
Reply
#4

Tanks Amit!
great job
do a lot more thing :P :P
Reply
#5

Good Job Amit.. [;

Reply
#6

nice job
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)