PDA

View Full Version : [Help] "news Alives;"


Luicy.
12/10/2015, 05:55 PM
So.. In my derby GM I got this..

new Alives;


and

GetPlayersOnServer()
{
new count;
for(new x=0; x< MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x)))
{
count++;
Alives++;

}
}
return count;
}

So..
Will

Alives++;

Set the "new" to the current online?

bgedition
12/10/2015, 06:08 PM
Set the "new" to the current online?

What do you mean by this? I'm not getting it.

Luicy.
12/10/2015, 06:21 PM
Like, Will the "new Alives;"
update to "GetPlayersOnServer()"

Isolated
12/10/2015, 06:26 PM
Why are you counting the same thing twice? Remove the Alives, and just the function as is. It will return the amount of players connected, not weather they are spawned or not.

bgedition
12/10/2015, 06:29 PM
Maybe Alives++ is used for something else in the script.

Luicy.
13/10/2015, 01:09 PM
Why are you counting the same thing twice? Remove the Alives, and just the function as is. It will return the amount of players connected, not weather they are spawned or not.

No, The count and alives are for different things, As you can see "return count;"
if I would replace that with alive, it would be fucked up,
As people dies in the derby,

Unte99
13/10/2015, 02:08 PM
new Alives;

public OnPlayerConnect(playerid)
{
Alives++;
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
Alives--;
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
Alives--;
return 1;
}


And yes, that code will get the number of online players.

PrO.GameR
13/10/2015, 04:53 PM
new Alives;

public OnPlayerConnect(playerid)
{
Alives++;
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
Alives--;
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
Alives--;
return 1;
}


And yes, that code will get the number of online players.
You are not helping him get "alives" count, but Online counts, he simply wants to check how many players on server are alive, he is doing it wrong, and you are doing it worse


Buddy, you should make something like
new Alive[MAX_PLAYERS];
put these under mentioned callbacks:

OnPlayerConnect Alive[playerid]=0;
OnPlayerDisconnect Alive[playerid]=0;
OnPlayerDeath Alive[playerid]=0;
OnPlayerSpawn Alive[playerid]=1;

and under your GetPlayersOnServer
GetPlayersOnServer()
{
new count;
Alives=0;
for(new x=0; x< MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x)))
{
count++;
if(Alive[playerid]==1) Alives++;

}
}
return count;
}
And now it does what you want it to do, count alives in the server while counting onlines too

Unte99
13/10/2015, 05:46 PM
You are not helping him get "alives" count, but Online counts, he simply wants to check how many players on server are alive, he is doing it wrong, and you are doing it worse


Buddy, you should make something like
new Alive[MAX_PLAYERS];
put these under mentioned callbacks:

OnPlayerConnect Alive[playerid]=0;
OnPlayerDisconnect Alive[playerid]=0;
OnPlayerDeath Alive[playerid]=0;
OnPlayerSpawn Alive[playerid]=1;

and under your GetPlayersOnServer
GetPlayersOnServer()
{
new count;
Alives=0;
for(new x=0; x< MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x)))
{
count++;
if(Alive[playerid]==1) Alives++;

}
}
return count;
}
And now it does what you want it to do, count alives in the server while counting onlines too

Number of alive players will be the same as online players.

Luicy.
13/10/2015, 05:50 PM
You are not helping him get "alives" count, but Online counts, he simply wants to check how many players on server are alive, he is doing it wrong, and you are doing it worse


Buddy, you should make something like
new Alive[MAX_PLAYERS];
put these under mentioned callbacks:

OnPlayerConnect Alive[playerid]=0;
OnPlayerDisconnect Alive[playerid]=0;
OnPlayerDeath Alive[playerid]=0;
OnPlayerSpawn Alive[playerid]=1;

and under your GetPlayersOnServer
GetPlayersOnServer()
{
new count;
Alives=0;
for(new x=0; x< MAX_PLAYERS; x++)
{
if(IsPlayerConnected(x)))
{
count++;
if(Alive[playerid]==1) Alives++;

}
}
return count;
}
And now it does what you want it to do, count alives in the server while counting onlines too

I know what I want to do, He helped me out there, Cause It's derby I got another for "Alive", So Alive will be like this:
Remove on death, Disconnect, player exits vehicle.
and add:
On spawn, after it's only one left

----To Helper:
Thank you.

PrO.GameR
13/10/2015, 05:54 PM
Alrighty, in my universe being Alive in this video game means being spawned and playing, and apparently staring at loginscreen or w/e counts as being alive in yours, I should fly back to mine now then, cya