Re: Useful Functions -
sciman001 - 08.05.2011
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.
Re: Useful Functions -
RyDeR` - 08.05.2011
That's not a function.
Re: Useful Functions -
sciman001 - 08.05.2011
o. well sorry to spam? i guess.
Re: Useful Functions -
SmallMoke - 30.05.2011
@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
![Tongue](images/smilies/razz.gif)
)
Respuesta: Useful Functions -
TheChaoz - 30.05.2011
mmm no i think that u are wrong but that's just a personal opinion based on time of scripting.
Re: Useful Functions -
SmallMoke - 30.05.2011
@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.
Re: Useful Functions -
CyNiC - 30.05.2011
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.
Re: Useful Functions -
kLx - 30.05.2011
pawn Код:
stock GetConnectedPlayers()
{
return Itter_Count(Player);
}
That's what smart people do.
Re: Useful Functions -
Calgon - 30.05.2011
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.
-
GaGlets(R) - 30.05.2011
Deleted
Re: Useful Functions -
MrDeath537 - 31.05.2011
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
Re: Useful Functions -
sciman001 - 31.05.2011
Quote:
Originally Posted by MrDeath537
Me.
pawn Код:
#define GetConnectedPlayers() \ Itter_Count(Player)
xD
|
lol nice!
![Cheesy](images/smilies/biggrin.png)
![Cheesy](images/smilies/biggrin.png)
![Cheesy](images/smilies/biggrin.png)
xD
Re: Useful Functions -
Markx - 31.05.2011
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;
}
Re: Useful Functions -
RyDeR` - 03.06.2011
Yes, it's quite simple. But it's not really meant to use this as password encryption.
Re: Useful Functions -
Kwarde - 03.06.2011
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)
Re: Useful Functions -
Kwarde - 03.06.2011
Oh yes sorry, forgot about the wikie (*facepalm*). Thank you btw.
Re: Useful Functions -
Famalamalam - 03.06.2011
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 ![Cheesy](images/smilies/biggrin.png) or to reveal a puzzle clue or answer or something like that, read the wiki page it tells you more about it ![Tongue](images/smilies/razz.gif)
|
That's a pretty smart idea, never thought of that, ha.
Re: Useful Functions -
Donya - 03.06.2011
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;
}
Re: Useful Functions -
[KO]KillerThriller - 04.06.2011
Yo, can anyone make like GetDifferenceBetweenNumbers(number1,number2)??
So like GetDifferenceBetweenNumbers(1,5) would return 4
AW: Re: Useful Functions -
Nero_3D - 04.06.2011
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