17.02.2010, 17:27
I'm making a script to put a player in a random vehicle on spawn, but I don't really have a clue how to do this...
As you can see I always get the same car model now, so how can I make it to pick a random car from the list?
pawn Код:
//I have this
new cars[87][1] = {
{400},{401},{402},{404},{405},{410},{411},{413},{415},{418},
{419},{421},{422},{424},{426},{429},{434},{436},{439},{442},
{445},{451},{458},{446},{467},{470},{474},{475},{477},{478},
{479},{480},{482},{483},{489},{491},{492},{495},{496},{500},
{505},{506},{507},{516},{517},{518},{525},{526},{527},{529},
{533},{534},{535},{536},{540},{541},{542},{543},{545},{546},
{547},{549},{550},{551},{554},{555},{558},{559},{560},{561},
{562},{565},{566},{567},{568},{575},{576},{579},{580},{585},
{587},{589},{600},{602},{603},{604},{605}
};
pawn Код:
// And this is my OnPlayerSpawn
public OnPlayerSpawn(playerid)
{
PlayerVehicle[playerid] = CreateVehicle(560, -1253.9496,-193.6417,56.3562, 0.0, -1, -1, 60000);
PutPlayerInVehicle(playerid, PlayerVehicle[playerid], 0);
SetVehiclePos(PlayerVehicle[playerid], -1253.943848, -193.086182, 59.217461);
Spawned[playerid] = 1;
StartedPlaying[playerid] = 1;
return 1;
}