Jump to content

Bindkey (Executes the function several times) [SOLVED]


KiffShark

Recommended Posts

Hi everybody

I've done an script to create an object in player coords

when some player press "k" or type /bloqueo

when I use /bloqueo it's created and everything is good, but when press "k" it's created 2 or 3 times :S

I don't know why, it should work like /bloqueo

(everything works ok with the command, it's problem of account's data, money, lvl... this works ok)

function barrera ( pla, dim ) 
local account = getPlayerAccount(pla) 
local zombiekills = getAccountData(account,"Zombie kills") 
if (zombiekills >= 50) then 
    dinero = getPlayerMoney ( pla ) 
    if (dinero > 30 ) then 
        if not isPedInVehicle(pla)then 
  
        local x,y,z=getElementPosition(pla) 
        local xx,yy,zz=getElementRotation(pla) 
  
        local madera = createObject(3260, x,y, z+0.15,xx,yy+90,zz+180) 
  
        takePlayerMoney ( pla, 30 ) 
        outputChatBox("*Barrera de madera construida ($30)*", pla, 255, 0, 0) 
        else 
        outputChatBox("*No puedes construir barrera desde el vehículo*", pla, 255, 0, 0) 
        end 
    else 
    outputChatBox("*Necesitas $30 para construir una barrera*", pla, 255, 0, 0) 
    end 
else 
outputChatBox ( "*Nivel 2 requerido para construir barreras*", pla, 255, 0, 0 ) 
end 
end 
  
addCommandHandler ( "bloqueo", barrera ) 
  
function bindK () 
bindKey (source,"k", "down", barrera) 
end 
addEventHandler("onPlayerSpawn",getRootElement(),bindK) 

what's happens? :/

Thanks!

Edited by Guest
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...