SA-MP Forums Archive
Getplayerid - 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: Getplayerid (/showthread.php?tid=254633)



Getplayerid - Admigo - 11.05.2011

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


Re: Getplayerid - Alvord - 11.05.2011

What does it show for the player's ID?


Re: Getplayerid - Admigo - 11.05.2011

Its shows 0 lol and i am 6


AW: Getplayerid - Nero_3D - 11.05.2011

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


Re: AW: Getplayerid - Laronic - 11.05.2011

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.


Re: Getplayerid - Admigo - 11.05.2011

Just made with a timer on gamemodeinit


Re: Getplayerid - Laronic - 11.05.2011

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