stevensalvaro Posted March 15, 2016 Share Posted March 15, 2016 (edited) Solved Edited March 20, 2016 by Guest Link to comment
Addlibs Posted March 15, 2016 Share Posted March 15, 2016 if the vehicle have item id 137item id? Link to comment
stevensalvaro Posted March 15, 2016 Author Share Posted March 15, 2016 Yeah , item id on vehicle trunk Link to comment
pro-mos Posted March 17, 2016 Share Posted March 17, 2016 Your question is unclear and you've posted hell lots of code! maybe that's why you haven't got answers yet. anyway, i managed to write something: Client-side: function attachRedNeon () local theVehicle = getPedOccupiedVehicle(localPlayer) if theVehicle == false then return end local pedHaveItem137 local stuff = getAttachedElements(theVehicle) for i, v in ipairs(stuff) do local id = getElementModel(v) if id and id == 137 then pedHaveItem137 = true break end end if pedHaveItem137 then setElementData( localPlayer, "neon", idModel[1] ) outputChatBox("#00ff00Now your neon color is #ff0000Red", 255,255,255, true) triggerServerEvent ("detachNeon", getLocalPlayer(), theVehicle) triggerServerEvent ("attachNeon", getLocalPlayer(), theVehicle) pedHaveItem137 = nil end end bindKey("N", "down", attachRedNeon) Link to comment
Captain Cody Posted March 17, 2016 Share Posted March 17, 2016 Psh it's only 800 lines of code "Sarcastically" Link to comment
stevensalvaro Posted March 17, 2016 Author Share Posted March 17, 2016 actually a lots of script is replacing neon , not a function to attach it , what i need to get help is , How can i get vehicle model ID and why this script doesnt work if i use addcommandHandler when entering vehicle without restart it , but if i restart this script in the vehicle , i can use that Command .. Link to comment
pro-mos Posted March 17, 2016 Share Posted March 17, 2016 getVehicleModel(theVehicle) you need to be inside the vehicle before using the command, it wont work if you're entering the vehicle. Link to comment
stevensalvaro Posted March 17, 2016 Author Share Posted March 17, 2016 the script is fine , but if i restart the script outside the vehicle , then i enter the vehicle , nothing happend .. But if i restart the script inside the vehicle , it's work fine .. may i need to use getElementModel(theVehicle) ? I dont know if getVehicleModel will work on MTA , because it's SAMP function Link to comment
pro-mos Posted March 17, 2016 Share Posted March 17, 2016 I dont know if getVehicleModel will work on MTA , because it's SAMP function is it? but it's an MTA function too, it will work. Link to comment
stevensalvaro Posted March 17, 2016 Author Share Posted March 17, 2016 okay thanks bro , i will try it Link to comment
stevensalvaro Posted March 19, 2016 Author Share Posted March 19, 2016 hello, Why if i put item to vehicle , i must to restart the script before it's working .. ? Why cant this script looping when i put the item so it's automaticlly update element data of the vehicle ? SCRIPT if (exports.global:hasItem(theVehicle, 137)) then setElementData( theVehicle, "neon", idModel[1] ) elseif (exports.global:hasItem(theVehicle, 138)) then setElementData( theVehicle, "neon", idModel[2] ) end Link to comment
Addlibs Posted March 19, 2016 Share Posted March 19, 2016 The function you use to add an item can call an event, which can be caught by your script and act upon that event, for example, by updating the neon element data or whatever Link to comment
stevensalvaro Posted March 19, 2016 Author Share Posted March 19, 2016 can you give me some example ? or function link on wiki ? Link to comment
stevensalvaro Posted March 19, 2016 Author Share Posted March 19, 2016 You mean , add this to my own item system script ? for item id 137 then set element data for neon ? Link to comment
stevensalvaro Posted March 19, 2016 Author Share Posted March 19, 2016 I got an error too , when the vehicle has been set for example to neon 1 , then i remove item id 137 , and why the vehicle still set to neon 1 ? without item Link to comment
Addlibs Posted March 19, 2016 Share Posted March 19, 2016 How do you remove item id 137? Link to comment
stevensalvaro Posted March 19, 2016 Author Share Posted March 19, 2016 by drag item to outside of the vehicle , plant B , can i use event onVehicleEnter to check if the vehicle has item id 137 ? like this... function neonFunction(thePlayer, seat, jacked) local theVehicle = getPedOccupiedVehicle ( localPlayer ) if (exports.global:hasItem(theVehicle, 137)) then setElementData( theVehicle, "neon", idModel[1] ) elseif not (exports.global:hasItem(theVehicle, 137)) then setElementData( theVehicle, "neon", 0 ) end end addEventHandler ( "onVehicleEnter", getRootElement(), neonFunction) 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