Bohemian_Bear Posted October 16, 2013 Share Posted October 16, 2013 Well, i am new here, and please sry for the bad english. I am trying to make an hud that changes one "state of damage" pic related to the vehicle types function enterVehicle(theVehicle, seat, jacked) if (getVehicleType(theVehicle) == "Automobile") then local vehicle = "textures/car.png" end if (getVehicleType(theVehicle) == "Plane") then local vehicle = "textures/plane.png" end if (getVehicleType(theVehicle) == "Bike") then local vehicle = "textures/bike.png" end if (getVehicleType(theVehicle) == "Helicopter") then local vehicle = "textures/heli.png" end if (getVehicleType(theVehicle) == "Boat") then local vehicle = "textures/boat.png" end end 2 questions, this is right? And this is will return me "textures/....png" with the "vehicle" variable? Also, if there anyway to make this code better, will help. TY! Link to comment
Castillo Posted October 16, 2013 Share Posted October 16, 2013 That code will make the 'vehicle' variable local, which means it only exists inside that 'if'. You could also use 'elseif' instead of using separated 'if'. Or you can also do it this way: function enterVehicle ( theVehicle, seat, jacked ) local vType = getVehicleType ( source ) local vehicle = "textures/".. ( vType == "Automobile" and "car" or vType == "Plane" and "plane" or vType == "Bike" and "bike" or vType == "Helicopter" and "heli" or vType == "Boat" and "boat" ) ..".png" end Link to comment
Bohemian_Bear Posted October 16, 2013 Author Share Posted October 16, 2013 Nice, this will work... When i ask for vehicle, it will returns to me textures/vehicleType.png, right? I am still learning with some scripts open source and reading; I can set things like, global variables, session variables or things like session variables? Link to comment
Castillo Posted October 16, 2013 Share Posted October 16, 2013 By session variables you mean data that only exists until you quit the server? if so, then yes, you can set element data. getElementData setElementData Link to comment
Bohemian_Bear Posted October 16, 2013 Author Share Posted October 16, 2013 Yes yes, i'll read thos two; So much tank you! 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