Jump to content

Solved


Recommended Posts

Posted

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) 

Posted

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

Posted

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

Posted

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 
  
  

Posted

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

Posted

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) 
  
  
  
  

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