Random player
#1

Hi guys.

First of all please nobody tell me to search, because i'm doing that since 5 days, trying to get it..

I want the server to pick a random player from players online, and changes his Team.. etc..

Also i want it to not get a "TEAMLESS" player.
like:

if(gTeam[i] != TEAMLESS){ get the random one} ..
like i want a random player , except a team..

I want someone to explain it for me..

Thanks
Reply
#2

Seriously? I searched and I immediately got many results - for example, https://sampforum.blast.hk/showthread.php?tid=261708
Reply
#3

Oh i saw that before..
if you are talking about this:

Код:
if(strcmp(cmd, "/mission", true) == 0)
{
    new onlineids[MAX_PLAYERS]; // to store all online playerids
    new playersonline; // to store the amount of current online players
    new pname[16]; // to store the chosen player's name

    for(new i=0; i<MAX_PLAYERS; i++) // loop through max amount of players (hopefully redefined from default!) 
    {
        if(IsPlayerConnected(i)) // check to see if current id in the loop is connected
        {
            onlineids[playersonline] = i; // store the current id into the onlineids variable
            playersonline++; // increase the playersonline by 1
        }
    }

    GetPlayerName(onlineids[random(playersonline)], pname, sizeof(pname)); // use the random function to randomly select a store online id
    format(pname, sizeof(pname), "Player name is %s", pname);
    SendClientMessage(playerid, COLOR_WHITE, pname);
    return 1;
}
where should i put team thing..?
i tried :

Код:
if(IsPlayerConnected(i) && gTeam[i] != TEAMLESS)
nothing happened.. it picked a TEAMLESS dude.
Reply
#4

So anyone?!...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)