-.Paradox.- Posted April 2, 2014 Posted April 2, 2014 Hello, guys is it possible to spawn a vehicle by getting the vehicle Id from an edit box? If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
Saml1er Posted April 2, 2014 Posted April 2, 2014 _yoBox = guiCreateEdit( 0.3, 0.1, 0.4, 0.1, "10", true ) local VehID = tonumber ( guiGetText ( _yoBox ) ) -- <-- < -- tonumber () will try to convert the string into a number if type (VehID) == "number" then outputChatBox ( VehID ) --<--<--< This will output the vehicle ID end
WhoAmI Posted April 2, 2014 Posted April 2, 2014 It's pointless to check if the variable is number, when you converted it to number before.
Saml1er Posted April 2, 2014 Posted April 2, 2014 It's pointless to check if the variable is number, when you converted it to number before. And what if someone writes "HelloWorld!10" then tonumber won't work in such case so it will give him error when he is using createVehicle.
WhoAmI Posted April 2, 2014 Posted April 2, 2014 So add if: if ( VehID ) then Then it would return int, or false.
Saml1er Posted April 2, 2014 Posted April 2, 2014 So add if: if ( VehID ) then Then it would return int, or false. But its not a requirement.
cheez3d Posted April 2, 2014 Posted April 2, 2014 CLIENT local gui = {edit = guiCreateEdit(200,200,150,30,"",false),button = guiCreateButton(200,250,150,30,"Spawn",false)} addEventHandler("onClientGUIClick",gui.button,function() triggerServerEvent("onPlayerRequestCar",localPlayer,string.match(guiGetText(gui.edit),"[0-9]") and tonumber(guiGetText(gui.edit)) or 497) end,false) SERVER addEvent("onPlayerRequestCar",true) addEventHandler("onPlayerRequestCar",root,function(id) if id then local x,y,z = getElementPosition(client) local rx,ry,rz = getElementRotation(client) createVehicle(id,x,y,z,rx,ry,rz) end end)
-.Paradox.- Posted April 2, 2014 Author Posted April 2, 2014 Thank you Cheez3D i will try it If you're looking for a cheap paid scripter, don't hesitate to contact me. Great minds discuss ideas, Average minds discuss events and small minds discuss people.
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