how to put player in random cars - 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: how to put player in random cars (
/showthread.php?tid=478321)
how to put player in random cars -
JasonTurkey - 29.11.2013
ok i am working on a stunt game.
i have a derby system but i want player to Put in a sultan once they do /join
I have created 6 sultans, so each player are put on each of the sultans.
and after all the players in derby game are destroyed, I want last winner player, after he wins he'll be Teleported out of the derby. Then everyone sees his name that he won using sendclientmessagetoall
Re: how to put player in random cars -
JasonTurkey - 29.11.2013
Want help asap
Re: how to put player in random cars -
Loot - 29.11.2013
You're asking too much from this section, that's not going to work.
Try here
https://sampforum.blast.hk/showthread.php?tid=30938&page=223.
Re: how to put player in random cars -
eDz0r - 29.11.2013
Use a loop to check if a player is in a car and if is no one in the car put the player in.
And for the winner problem use a variable to know how many players are in the game and when variable = 1 he is the winner.
Re: how to put player in random cars -
RajatPawar - 29.11.2013
pawn Код:
#define MAX_SULTANS 6
native IsValidVehicle(vehicleid);
new iCars[MAX_SULTANS]
;
stock GetVehicleDriver( vehicleID )
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if( IsPlayerInVehicle(i, vehicleID) ) return i;
else continue;
}
return -1;
}
public OnGameModeInit()
{
for(new i = 0; i < MAX_SULTANS; i++)
{
iCars[ i ] = AddStaticVehicle(....);
}
return 1;
}
CMD:join(playerid)
{
// Player checks, admin levels, etc.
for(new i = 0; i < MAX_SULTANS; i++)
{
if( IsValidVehicle(iCars[i]) )
{
if( GetVehicleDriver(iCars[i]) == -1) { return PutPlayerInVehicle(playerid, iCars[i], 0); }
else continue;
}
}
SendClientMessage(playerid, -1, "Sorry, all vehicles have been occupied.");
return 1;
}
- Creates vehicles under OnGameModeInit()
- When the player joins - check in a loop if the 'i'th vehicle is valid
- If it is - get the player's driver - if there is no driver, put him in that vehicle.
- If no vehicle is empty, simply return to him that message.
There are other ways, but whatever suits you.
Cheers!