Hadif Posted July 26, 2015 Share Posted July 26, 2015 Someone knows how to reset randomize plate number when vehicle explode... eg: My car plate number is "ABC123", when my car explode, it change the plate number randomly to something else like "DEF456" or something... please help me, i ll try so many way but not find the solution... addEventHandler ( "onResourceStart", getRootElement ( ), function ( ) vehicleSpawn ( ) end ) addEventHandler ( "onVehicleExplode", getRootElement ( ), function ( ) respawnExplodedVehicle ( ) end ) local defaultPlate = "GUEST " .. math.random ( 11, 99 ) function vehicleSpawn ( ) local theVehicle = { } theVehicle [ 1 ] = createVehicle ( 558, -301.7, 1767.8, 42.4, 0, 0, 88, defaultPlate, false, variant1, variant2 ) local allVehicles = theVehicle for theKey, allVehicles in ipairs ( allVehicles ) do setElementData ( allVehicles, "Owner", "Free", true ) end end function respawnExplodedVehicle ( ) if ( getElementData ( source, "Owner" ) == "Free" ) then setTimer ( respawnVehicle, 5000, 1, source ) end end Link to comment
Arnold-1 Posted July 26, 2015 Share Posted July 26, 2015 letters = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} function randomPlate (vehicle) setVehiclePlateText(vehicle,letters[math.random(1,#letters)]..letters[math.random(1,#letters)]..letters[math.random(1,#letters)]..tostring(math.random(1,9))..tostring(math.random(1,9))..tostring(math.random(1,9)) end Link to comment
Hadif Posted July 26, 2015 Author Share Posted July 26, 2015 letters = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"} function randomPlate (vehicle) setVehiclePlateText(vehicle,letters[math.random(1,#letters)]..letters[math.random(1,#letters)]..letters[math.random(1,#letters)]..tostring(math.random(1,9))..tostring(math.random(1,9))..tostring(math.random(1,9)) end how? Link to comment
Arnold-1 Posted July 26, 2015 Share Posted July 26, 2015 put that in the code, and then add this: function onExplode (vehicle) randomPlate(vehicle) end addEventHandler("onVehicleExplode",root,onExplode) Link to comment
Arnold-1 Posted July 26, 2015 Share Posted July 26, 2015 Wait, i just realized that you don't need to randomize it, your problem is that it's being randomized. but can you explain the problem more? is this happening AFTER the vehicle is respawned? Link to comment
Hadif Posted July 26, 2015 Author Share Posted July 26, 2015 Wait, i just realized that you don't need to randomize it, your problem is that it's being randomized.but can you explain the problem more? is this happening AFTER the vehicle is respawned? yes, i want it to change the car numplate after it has been respawn, im glad u understand me.... Link to comment
Arnold-1 Posted July 26, 2015 Share Posted July 26, 2015 Great, then, get the plate text using "getVehiclePlateText" BEFORE you spawn the vehicle, and after you spawn it use setVehiclePlateText and set it to the one you got from the first function. Link to comment
Hadif Posted July 27, 2015 Author Share Posted July 27, 2015 Great, then, get the plate text using "getVehiclePlateText" BEFORE you spawn the vehicle, and after you spawn it use setVehiclePlateText and set it to the one you got from the first function. no dude, i want it to change its numplate after respawn... eg: before "DRIVE 12", after respawn "DRIVE 94" Link to comment
Arnold-1 Posted July 27, 2015 Share Posted July 27, 2015 Then just use setVehiclePlateText.... Link to comment
Threule Posted July 27, 2015 Share Posted July 27, 2015 Add - so it gives random gaps too Link to comment
Hadif Posted July 27, 2015 Author Share Posted July 27, 2015 Then just use setVehiclePlateText.... ill try bro Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now