Players Online + Query
#1

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

Not PlayerOnline = --;

It's PlayersOnline--; and PlayersOnline++;
Reply
#3

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--;
Reply
#4

Remove MAX_PLAYERS

pawn Code:
new PlayersOnline;
Reply
#5

Thanks.

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)