Jump to content

HELP Function


Recommended Posts

Hello,

I want to make when vehicle has item id 1 then setelementdata "test" 1 , and when player enter vehicle and press 'N' then item ID 1 work.

What function i need ? am i right about :

When vehicle has item id 1 ----- "setElementData function"

When Player enter vehicle ----- "getElementData function"

When press N ---- Trigger the event ?

Link to comment
addEventHandler("onPlayerLogin", root,  
function() 
   bindKey(source, "n", "down", factionVehicle) 
end) 
  
addEventHandler("onResourceStart", root, 
function() 
   for p, v in ipairs(getElementsByType("player")) do 
       bindKey(v, "n", "down", factionVehicle) 
   end 
end) 
  
function factionVehicle(thePlayer, theVehicle) 
  --your code 
end    

Link to comment

so if i want to make it work with get / set element data , i must to write :

client

  
addEventHandler("onPlayerLogin", root, 
function() 
   bindKey(source, "n", "down", factionVehicle) 
end) 
  
addEventHandler("onResourceStart", root, 
function() 
   for p, v in ipairs(getElementsByType("player")) do 
       bindKey(v, "n", "down", factionVehicle) 
   end 
end) 
  
function factionVehicle(thePlayer, theVehicle) 
  getElementData (theVehicle, "test") 
  triggerServerEvent ("test1", getLocalPlayer(), theVehicle) 
end 
  
  
  
  
  
  
end   
  

Link to comment

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