Jump to content

Random vehicle in race, with chekpoints [ solved ]


denny199

Recommended Posts

Hey there, i've helping my mate with a map but now we've got some problems with our script.

evrything is working fine until chekpoint 27

When I hit chekpoint 26, I'm getting a random plane from the plane table.

When i hit chekpoint 27, I'm getting a random car, that needs to be a plane.

And when I hit chekpoint 28 it's getting the randomcar again.

so, what wrong in my code?

  
local carids = {568, 424, 573, 579, 400, 500, 444, 470, 489, 490, 495, 468, 471} 
local planeids = {592, 577, 511, 512, 593, 520, 553, 475, 519, 460, 513} 
local boatids = {471, 473, 493, 595, 484, 430, 453, 452, 446, 454} 
  
  
function randomCar(checkpoint, time) 
    local veh = getPedOccupiedVehicle(source) 
    
    if 1 <= checkpoint and checkpoint <= 25 then 
        setElementModel (veh, carids[math.random(#carids)]) 
    elseif checkpoint <= 26 then 
        setElementModel (veh, planeids[math.random(#planeids)]) 
    elseif checkpoint <= 31 then 
    setElementModel (veh, carids[math.random(#carids)]) 
    elseif checkpoint <= 35 then 
        setElementModel (veh, boatids[math.random(#boatids)]) 
    end 
end 
addEvent('onPlayerReachCheckpoint') 
addEventHandler('onPlayerReachCheckpoint', getRootElement(), randomCar) 

Edited by Guest
Link to comment

>= means greater than or equal to

> means greater than

<= means less than or equal to

< means less than

== means equal to

~= means not equal to

So, providing you have surpassed from the first year of primary school, you should be able to figure it out.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...