Vehicles Help
#1

Hello, There is any way to Count Players ??
If Count = 10 then make 10 vehicles and set players into it.
is this possible??!
Reply
#2

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!= -1i--)
    {
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
        
PutPlayerInVehicle(iveh[idx++], 0);
    }
}
stock countPlayers()
{
    for(new 
i=GetPlayerPoolSize(); != -1i--)
    {
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
        
count++;
    }
    return 
count;

Reply
#3

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!= -1i--)
    {
        if(!
IsPlayerConnected(i) || IsPlayerNPC(i)) continue;
        
PutPlayerInVehicle(iveh[idx++], 0);
    }
}
stock countPlayers()
{
    for(new 
i=GetPlayerPoolSize(); != -1i--)
    {
        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.
Reply
#4

Thnaks guys. I got it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)