Player Count Bug
#1

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

Ehm,

E_PLAYERS != E_PLAYER_COUNT ? And E_PLAYER_COUNT is not in the enum.

You could have seen that before
Reply
#3

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

My bad lol i just rewrote the code there, yes it all is E_PLAYER_COUNT, still dun work.
Reply
#5

pawn Код:
public OnGameModeInIt()
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.
Reply
#6

Again :/ i said i rewrote the first callback aka that lul
Reply
#7

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

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

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();
}
Reply
#10

FML, dont work still :/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)