Jump to content

fix code


Ahmed Abo-elezz

Recommended Posts

please whan i try to start script he say to me

Bad argument @ 'bindKey' [Expected player at argument 1, got resource]

please help me

addEventHandler ("onResourceStart",getRootElement(), 
    function () 
    bindKey (source,"forwards","down",press) 
    end) 
     
function press(player,key,state) 
    if (stats == "down") then 
        Again[player] = setTimer(function(player) 
        local x, y, z, rx, ry, rz = getElementAttachedOffsets (Weapon) 
        attachElements (Weapon, vehicle, x, y, z, rx, ry, rz+3) 
        end, 50, 0, player) 
                 
        elseif (stats == "up") and (isTimer(Again[player])) then 
        killTimer(Again[player]) 
        Again[player] = nil 
    end 
end 

Link to comment

The message is very clear: At bindKey first argument should be player but it was a resource. See the source of onResourceStart, use getElementsByType. One more error at line 9, Weapon is not DEFINED.

+

off-topic:

no offense but how did u create the ammunation script? seems fishy

Link to comment
  • Other Languages Moderators

You should attach the event onResourceStart to resourceRoot, as getRootElement will makes the event triggered when any other resources started.

Also in your code the table Again and the variables Weapon and vehicle is not defined.

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