Get random players - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Get random players (
/showthread.php?tid=261413)
Get random players -
VoViNaToR - 13.06.2011
Hello i want to make command that will display random player name who is online, can i have any help with this ?
Re: Get random players -
Benjo - 13.06.2011
Your best bet would be to make use of the 'random' function. A few examples of how it can be used:
pawn Код:
new i = random(10); // would store a random integer between 0 - 10 into the i variable
pawn Код:
if(random(5) == 1) // would give a 1 in 5 chance of passing the IF statement
For further information, check the wiki entry here:
https://sampwiki.blast.hk/wiki/Random
Re: Get random players -
VoViNaToR - 13.06.2011
Yes i know how to make simple random function like:
pawn Код:
new screenie = random(13);
if(screenie == 1)
{
SetPlayerPos(playerid, 720.4771,-1744.3759,7.3889);
SetPlayerCameraPos(playerid, 693.2117,-1794.4960,53.9965);
SetPlayerCameraLookAt(playerid, 767.3105,-1609.9528,17.4037);
}
else if( screenie == 2)
{
SetPlayerPos(playerid, 2246.4504,-1705.5930,22.8527);
SetPlayerCameraPos(playerid, 2227.4084,-1715.7412,49.0753);
SetPlayerCameraLookAt(playerid, 2261.9358,-1772.0881,13.5469);
}
else if( screenie == 3)
{
I bet you didnt even read my question.
Re: Get random players -
VoViNaToR - 13.06.2011
Ok i found similiar function on GF /lotto comand

will use it then
Re: Get random players -
Benjo - 13.06.2011
I'm extremely offended that you have responded in such a manner, I find it to be very rude.
Your initial request for help is very vague; exactly what bits do you need help with? How do you want the name to be displayed? Textdraw, ClientMessage, 3DTextLabel? Do you want the code writing for you, or do you just want pointing in the right direction? Understand that I have no way of knowing what level of coding you are at.
EDIT: too late, nevermind then.
Re: Get random players -
VoViNaToR - 13.06.2011
Benjo im sorry. Im just hard working on my script and i didnt solve my problem, i needed just randomly select some player and show me his name in any way
pawn Код:
format(string, sizeof(string), "* %s .",RANDOM PLAYER NAME);
SendClientMessage(i, COLOR_YELLOW, string);
Re: Get random players -
Jefff - 13.06.2011
pawn Код:
new OnlineID[MAX_SERVER_SLOTS],Add; // replace MAX_SERVER_SLOTS
for(new d,g=GetMaxPlayers(); d < g; d++)
if(IsPlayerConnected(d))
{
OnlineID[Add] = d;
Add++;
}
new RandomID = OnlineID[random(Add)];