Questions - 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: Questions (
/showthread.php?tid=144503)
Questions -
Lajko1 - 27.04.2010
I have some questions
1.)how is possible to get a number of all players on server ? so when player will connect there will be a message how much players are currently online ?
2.)How is possible to make server version i tried like this
Код:
#define SV 1.0 // Server Version
and than i do like this
Код:
format(str,sizeof(str),"System:Welcome on Roleplay Server %s.\nServer current version:%d.\nTotal players online:%d",name,SV);
SendClientMessage(playerid,0xFFFF00AA,str);
thats all what i need to know
Re: Questions -
Hiddos - 27.04.2010
Use PVar's and give them +1 when somebody joins and -1 when somebody leaves.
Re: Questions -
Correlli - 27.04.2010
Loop through all connected players and use a variable for counting the connected players.
Quote:
Originally Posted by Lajko1
|
You'll need to use
%f to format and show the version correctly.
And with this you'll need to use
%s to format and show the version correctly.
Re: Questions -
Lajko1 - 27.04.2010
thank you,but for showing players on server can you post something to learn from ?
Re: Questions -
Correlli - 27.04.2010
pawn Код:
stock ReturnServerPlayers()
{
new
countVariable;
for(new u = 0; u < GetMaxPlayers(); u++)
{
if(IsPlayerConnected(u)) countVariable++;
}
return countVariable;
}
pawn Код:
/* usage. */
new
arr[24];
format(arr, sizeof(arr), "Players online: %i", ReturnServerPlayers());
SendClientMessage(playerid, 0xFFFFFFFF, arr);
Re: Questions -
Lajko1 - 27.04.2010
Код:
stock ReturnServerPlayers()
{
new
countVariable;
for(new u = 0, u < GetMaxPlayers(); u++) // line 57
{
if(IsPlayerConnected(u)) countVariable++;
}
return countVariable;
}
Errors:
Код:
C:\Documents and Settings\Administrator\Desktop\Server\gamemodes\Roleplay.pwn(57) : error 021: symbol already defined: "u"
C:\Documents and Settings\Administrator\Desktop\Server\gamemodes\Roleplay.pwn(57) : error 001: expected token: ")", but found ";"
C:\Documents and Settings\Administrator\Desktop\Server\gamemodes\Roleplay.pwn(57) : warning 204: symbol is assigned a value that is never used: "u"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Re: Questions -
Correlli - 27.04.2010
My mistake, I was in a hurry - I've added
, instead of
; in the for-loop. Check my post again, I've fixed the code.
Re: Questions -
Lajko1 - 27.04.2010
ty
Re: Questions -
Correlli - 27.04.2010
You're welcome.