Count 1/2 players
#1

Hi, for my server I wanna make some kind of police radio.
in a textdraw every 25 seconds a player from gTeam[playerid] = TEAM_COPS
will see 2 people having a wanted level higher than 1.
after 25 seconds there should come 2 new people displayed
if theres none having a wantedlevel higher than 1 it should say no suspects...

Well so basically what I need to create is something that can count 2 players
Is that possible
if yes, how?
Reply
#2

you can loop all players with your timer and check if there are others with wanted level
Reply
#3

It is.
Search forum, find GetRandomID() function and add wanted level star check to it.
Reply
#4

I think It's simple:

1 timer.
2 global vars (for saving the last people who are "wanted")

A loop for all players. Check if they are wanted. If(true), display their names and save theirs ID.
Again the loop. Check for wanted people and check if their ID are saved in the vars.
Reply
#5

Ok, so I decided to do jihost's thing
so I foudn this stock:
pawn Код:
{
    new bool:connected[MAX_PLAYERS] = false, amount = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
      if(IsPlayerConnected(i))
      {
        connected[i] = true;
        amount++;
      }
    if(amount = 0) return -1;
    new rand = random(amount), done = 0;
    for(new i = 0; i < MAX_PLAYERS; i++)
      if(connected[i])
      {
        if(done == rand) return i;
        done++;
        }
    return -1;
}
and added it in my GM (on the end)
then I made a test command:
pawn Код:
if (strcmp("/test", cmdtext, true) == 0)
    {
        format(string,sizeof(string),"Test id:%d",GetRandomID());
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
but I get this warning:
Код:
C:\Users\William\Documents\Famous' World\Famous' World\gamemodes\Famous.pwn(8436) : warning 211: possibly unintended assignment
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
error line:
pawn Код:
if(amount = 0) return -1;
its in the stock thing
Reply
#6

Simple:

pawn Код:
if(amount == 0) return -1;
Reply
#7

pawn Код:
if (!strcmp("/test", cmdtext, true))
    {
        format(string,sizeof(string),"Test id:%d",getRandomID());
        SendClientMessage(playerid,COLOR_RED,string);
        return 1;
    }
    stock getRandomID()
    {
        new i, c;
        for ( ; i < MAX_PLAYERS; ++i )
        {
            if ( IsPlayerConnected( i ) )
            {
                ++c;
            }
        }
        return random(c);
    }
Reply
#8

ah, thanks both worked!
and how do I do that when a random ID gets picked and it hasn't got a wantedlevel higher than 5 there will be another ID picked with a wantedlevel higher than 3?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)