Questions
#1

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
Reply
#2

Use PVar's and give them +1 when somebody joins and -1 when somebody leaves.
Reply
#3

Loop through all connected players and use a variable for counting the connected players.

Quote:
Originally Posted by Lajko1
Код:
#define SV 1.0
You'll need to use %f to format and show the version correctly.

Код:
#define SV "1.0"
And with this you'll need to use %s to format and show the version correctly.
Reply
#4

thank you,but for showing players on server can you post something to learn from ?
Reply
#5

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);
Reply
#6

Код:
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.
Reply
#7

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.
Reply
#8

ty
Reply
#9

You're welcome.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)