Getplayerid
#1

heey guys
I made this:
Код:
forward OnlineUpdate(playerid);
public OnlineUpdate(playerid)
{
     new string[200];
     new count = -6;
     for(new v; v < MAX_PLAYERS; ++v)
     {
           if(IsPlayerConnected(v))
           {
                   ++count;
           }
     }
     format(string,sizeof(string),"Players Online:%d Your ID:%d",count,playerid);
     TextDrawSetString(Online,string);
     return 1;
}
But when i login players online is good but your id is wrong:S
Pls help

Admigo
Reply
#2

What does it show for the player's ID?
Reply
#3

Its shows 0 lol and i am 6
Reply
#4

The better question is how do you call OnlineUpdate ? and where ?
Reply
#5

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
The better question is how do you call OnlineUpdate ? and where ?
Probably a "SetTimer" under GameModeInit() who will fail.
Reply
#6

Just made with a timer on gamemodeinit
Reply
#7

pawn Код:
//At top of ur script
new Count = 0;

//OnPlayerConnect
public OnPlayerConnect(playerid)
{
    Count ++;
   
    UpdatePlayer(playerid);
    return 1;
}

//OnPlayerDisconnect
public OnPlayerDisconnect(playerid, reason)
{
    Count --;
   
    UpdatePlayer(playerid);
    return 1;
}

//Anywhere in ur script
stock UpdatePlayer(playerid)
{
    new string[39];
    format(string, sizeof(string), "Players Online: %d | Your ID: %d", Count, playerid);
    TextDrawSetString(Online, string);
    return 1;
}
^ That should work

This was my 100th post
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)