SA-MP Forums Archive
Players Online + Query - 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: Players Online + Query (/showthread.php?tid=123880)



Players Online + Query - Mechscape - 27.01.2010

Now i write here code:

Top of Script
Code:
new PlayersOnline[MAX_PLAYERS];
OnPlayerConnect
Code:
  PlayersOnline = ++;
  new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  format(string, sizeof(string), "%s has joined the server! Online Players: %d", pname, PlayersOnline);
  SendClientMessageToAll(0xAAAAAAAA, string);
OnPlayerDisconnect
Code:
	PlayersOnline = --;
	new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
  GetPlayerName(playerid, pname, sizeof(pname));
  switch(reason)
  {
    case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", pname);
    case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pname);
    case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pname);
  }
  SendClientMessageToAll(0xAAAAAAAA, string);
Error output
Code:
C:\Program Files\SAMP\gamemodes\erp.pwn(129) : error 029: invalid expression, assumed zero
C:\Program Files\SAMP\gamemodes\erp.pwn(129 -- 131) : error 022: must be lvalue (non-constant)
C:\Program Files\SAMP\gamemodes\erp.pwn(144) : error 029: invalid expression, assumed zero
C:\Program Files\SAMP\gamemodes\erp.pwn(144 -- 146) : error 022: must be lvalue (non-constant)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
That is OnPlayerConnect and OnPlayerDisconnect


Re: Players Online + Query - Double-O-Seven - 27.01.2010

Not PlayerOnline = --;

It's PlayersOnline--; and PlayersOnline++;


Re: Players Online + Query - Mechscape - 27.01.2010

Removed and still
Code:
C:\Program Files\SAMP\gamemodes\erp.pwn(129) : error 022: must be lvalue (non-constant)
C:\Program Files\SAMP\gamemodes\erp.pwn(129) : warning 215: expression has no effect
C:\Program Files\SAMP\gamemodes\erp.pwn(144) : error 022: must be lvalue (non-constant)
C:\Program Files\SAMP\gamemodes\erp.pwn(144) : warning 215: expression has no effect
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Error line:
Code:
PlayersOnline++;
Code:
PlayersOnline--;



Re: Players Online + Query - MadeMan - 27.01.2010

Remove MAX_PLAYERS

pawn Code:
new PlayersOnline;



Re: Players Online + Query - Mechscape - 27.01.2010

Thanks.

But
Code:
format(string, sizeof(string), "%s has joined the server! Online Players: %d", pname, PlayersOnline);
will that work?


Re: Players Online + Query - [HiC]TheKiller - 27.01.2010

Quote:
Originally Posted by Picharelo
Thanks.

But
Code:
format(string, sizeof(string), "%s has joined the server! Online Players: %d", pname, PlayersOnline);
will that work?
Yes, it will.