Vehicles Help - 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)
+--- Thread: Vehicles Help (
/showthread.php?tid=617548)
Vehicles Help -
oktokt1 - 22.09.2016
Hello, There is any way to Count Players ??
If Count = 10 then make 10 vehicles and set players into it.
is this possible??!
Re: Vehicles Help -
Kaliber - 22.09.2016
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;
}
Re: Vehicles Help -
StreetGT - 22.09.2016
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.
Re: Vehicles Help -
oktokt1 - 24.09.2016
Thnaks guys. I got it.