Player Count Bug - 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: Player Count Bug (
/showthread.php?tid=248338)
Player Count Bug -
Lorenc_ - 13.04.2011
pawn Код:
enum ServerData
{
E_PLAYER_COUNT,
}
new gServerData[ServerData];
public OnGameModeInit()
{
gServerData[E_PLAYER_COUNT] = 0;
return 1;
}
public OnPlayerConnect(playerid)
{
gServerData[E_PLAYER_COUNT]++;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(!IsPlayerNPC(playerid))
{
gServerData[E_PLAYER_COUNT]--;
if(gServerData[E_PLAYER_COUNT] == 0)
{
endRound();
}
}
return 1;
}
stock endRound()
{
printf("HI");
}
Not seeming to work, any suggestions?
Re: Player Count Bug -
Mauzen - 13.04.2011
Ehm,
E_PLAYERS != E_PLAYER_COUNT ? And E_PLAYER_COUNT is not in the enum.
You could have seen that before
Re: Player Count Bug -
Stigg - 13.04.2011
Try:
pawn Код:
enum ServerData
{
E_PLAYERS,
}
new gServerData[ServerData];
public OnGameModeInIt()
{
gServerData[E_PLAYERS] = 0;
return 1;
}
public OnPlayerConnect(playerid)
{
gServerData[E_PLAYERS]++;
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
if(!IsPlayerNPC(playerid))
{
gServerData[E_PLAYERS]--;
if(gServerData[E_PLAYERS] == 0)
{
endRound();
}
}
return 1;
}
Re: Player Count Bug -
Lorenc_ - 13.04.2011
My bad lol i just rewrote the code there, yes it all is E_PLAYER_COUNT, still dun work.
Re: Player Count Bug -
Zimon95 - 13.04.2011
It should be
OnGameModeInit, pawn is case sensitive and it will give you an error.
EDIT: sorry I was sending the message while you were replying.
Re: Player Count Bug -
Lorenc_ - 13.04.2011
Again :/ i said i rewrote the first callback aka that lul
Re: Player Count Bug -
Cameltoe - 13.04.2011
Quote:
Originally Posted by Lorenc_
Again :/ i said i rewrote the first callback aka that lul
|
Did you try to print inside the == 0?
You could also try using < 1
Re: Player Count Bug -
BlackBank - 13.04.2011
Quote:
Originally Posted by Cameltoe
Did you try to print inside the == 0?
You could also try using < 1
|
This will work.
Because You set the variable to 0 and when a player leaves there will be -1 en then he will check if the variable is 0.
but your variable will works with -1, -2 etc..
Re: Player Count Bug -
Cameltoe - 13.04.2011
Quote:
Originally Posted by BlackBank3
This will work.
Because You set the variable to 0 and when a player leaves there will be -1 en then he will check if the variable is 0.
but your variable will works with -1, -2 etc..
|
So, do either:
pawn Код:
if(gServerData[E_PLAYERS] == 0)
{
endRound();
}
else gServerData[E_PLAYERS]--;
pawn Код:
gServerData[E_PLAYERS]--;
if(gServerData[E_PLAYERS] < 1)
{
endRound();
}
Re: Player Count Bug -
Lorenc_ - 13.04.2011
FML, dont work still :/