Hadif Posted July 26, 2015 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 My ingame nickname is Vaulthuntr. Host a server? Join a server?
Arnold-1 Posted July 26, 2015 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 Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Hadif Posted July 26, 2015 Author 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? My ingame nickname is Vaulthuntr. Host a server? Join a server?
Arnold-1 Posted July 26, 2015 Posted July 26, 2015 put that in the code, and then add this: function onExplode (vehicle) randomPlate(vehicle) end addEventHandler("onVehicleExplode",root,onExplode) Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Arnold-1 Posted July 26, 2015 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? Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Hadif Posted July 26, 2015 Author 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.... My ingame nickname is Vaulthuntr. Host a server? Join a server?
Arnold-1 Posted July 26, 2015 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. Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Hadif Posted July 27, 2015 Author 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" My ingame nickname is Vaulthuntr. Host a server? Join a server?
Arnold-1 Posted July 27, 2015 Posted July 27, 2015 Then just use setVehiclePlateText.... Ingame Name: Arnold If you need my help, contact me on Skype @bshr.ara NOTE:DO NOT ASK ME FOR SCRIPTS, ASK ME FOR HELP
Hadif Posted July 27, 2015 Author Posted July 27, 2015 Then just use setVehiclePlateText.... ill try bro My ingame nickname is Vaulthuntr. Host a server? Join a server?
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