KiffShark Posted December 17, 2012 Share Posted December 17, 2012 (edited) 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 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 December 19, 2012 by Guest Link to comment
Castillo Posted December 18, 2012 Share Posted December 18, 2012 Maybe the key is binding more than once? Link to comment
Renkon Posted December 18, 2012 Share Posted December 18, 2012 Indeed, onPlayerSpawn you are binding it. When he spawns again it will be binded twice. You gotta do unbindKey onPlayerWasted. Link to comment
KiffShark Posted December 18, 2012 Author Share Posted December 18, 2012 yep! solved, it was binded more than once because of onPlayerSpawn, every time spawn +1 bind D= I've used onPlayerJoin and unbind onPlayerQuit to prevent bugs, I think this won't cause bugs (I hope) (Solved) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now