itHyperoX Posted June 21, 2017 Share Posted June 21, 2017 Hello, how can i make something thins? I want set id for each vehicle which is spawned. Then i can create /getcar command. I dont want to save this forever. local vehS = 0 function createVeh(player,CMD,veh) local vehName = getVehicleIDFromName(veh) local x, y, z = getElementPosition(player) if vehName == false then --- else vehS + 1 theveh = createVehicle(vehName,x+5,y,z) setElementData(theveh,"vehID",vehS) end end addCommandHandler("cv",createVeh) Link to comment
pa3ck Posted June 21, 2017 Share Posted June 21, 2017 Okay, so you asked a question, but you already have the answer as well, what do you expect from us..? 2 Link to comment
Discord Moderators Pirulax Posted June 21, 2017 Discord Moderators Share Posted June 21, 2017 So, what you want from us?To create a getcar command?If so, here it is: function getCar(c,p,id) if not id then outputChatBox("Please enter a valid vehID",p) return end for k,v in ipairs(getElementsByType("vehicle")) do if getElementData(v, "vehID") == id then setElementPosition(v, Vector3(getElementPosition(p))) outputChatBox("Here it is!",p) return end outputChatBox("Invalid vehID",p) end end end addCommandHandler("getcar", getCar, false,false) Link to comment
itHyperoX Posted June 21, 2017 Author Share Posted June 21, 2017 (edited) No. So i tried to create the "cv" command, but when i create the vehicle, the "vehS + 1 not changing, so something wrong with that, i need help with that. so the car id is always 0 or 1.. Edited June 21, 2017 by TheMOG Link to comment
Discord Moderators Pirulax Posted June 21, 2017 Discord Moderators Share Posted June 21, 2017 (edited) ahh, vehS = vehS + 1 The problem was, that u didnt saved the last number. Edited June 21, 2017 by Pirulax 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