Posts: 151
Threads: 25
Joined: Jan 2016
Reputation:
0
Hello, There is any way to Count Players ??
If Count = 10 then make 10 vehicles and set players into it.
is this possible??!
Posts: 1,032
Threads: 2
Joined: Dec 2008
Quote:
Originally Posted by Kaliber
Ehh sure
For example:
PHP код:
/* For example create vehicle like this:
new veh[10]; //Global
veh[0] = CreateVehicle(...);
veh[9] = CreateVehicle(...);
*/
if(countPlayers() == 10)
{
//Here you have 10 Players...
for(new i=GetPlayerPoolSize(),idx; i != -1; i--)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
PutPlayerInVehicle(i, veh[idx++], 0);
}
}
stock countPlayers()
{
for(new i=GetPlayerPoolSize(); i != -1; i--)
{
if(!IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
count++;
}
return count;
}
|
The second function is not needed, you could add a global variable.
PHP код:
new PlayerOnline = 0;
public OnPlayerConnect()
{
PlayerOnline++;
}
public OnPlayerDisconnect()
{
PlayerOnline--;
}
That way you don't need to iterate all the time.