Jump to content

help with a simple script


Brad96

Recommended Posts

hi ,i want to explainme how i am use the bindKey function in server-side

this is my script ,i want to create a vehicle when i press the key ,thanks

function cas(player,key) 
    x, y, z = getElementPosition(player) 
    cs = createVehicle (411 ,x+5 ,y, z) 
    css = createObject (359, x, y, z) 
    css2 = createObject (359, x, y, z) 
    x, y, z = getElementRotation ( cs ) 
    attachElements ( css, cs, 1, 2, 0.20, 0, 0, 90) 
     attachElements ( css2, cs, -1, 2, 0.20, 0, 0, 90) 
    end 
    addEventHandler("onResourceStart",getRootElement(),function () 
    bindKey(player,"2","down",cas) 
     
  
end) 

Link to comment
function FunctionName() 
    for index, player in pairs(getElementsByType("player")) do 
        bindKey(player,"2","down",cas) 
    end 
end 
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), FunctionName ) 

Link to comment

is this?

function cas(player) 
    x, y, z = getElementPosition(player) 
    cs = createVehicle (411 ,x+5 ,y, z) 
    css = createObject (359, x, y, z) 
    css2 = createObject (359, x, y, z) 
    x, y, z = getElementRotation ( cs ) 
    attachElements ( css, cs, 1, 2, 0.20, 0, 0, 90) 
     attachElements ( css2, cs, -1, 2, 0.20, 0, 0, 90) 
end 
  
    function FunctionName() 
    for index, player in pairs(getElementsByType("player")) do 
        bindKey(player,"2","down",cas) 
    end 
end 
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()), FunctionName ) 

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