Jump to content

create Vehicle


Recommended Posts

Posted

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.

Posted
 _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 

Posted
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.

Posted

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) 
  

Posted

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.

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...