healLV Posted December 30, 2015 Share Posted December 30, 2015 So my problem is that i dont know why getElementData doesn`t accept string as name. Am I supposed to define it? function gzkill(player, cmd, name, ammount) local ammount = tonumber(ammount) lpkills = getElementData(player, "zombieskilled") pkills = getElementData(name, "zombieskilled") akills = pkills + ammount rkills = lpkills - ammount local truename = getPlayerName(name) if truename == name then setElementData(name, "zombieskilled", akills) setElementData(player, "zombieskilled", rkills) outputChatBox("Sucessfully added!", getRootElement, 255, 255, 255, false) else outputChatBox("Wrong name!", getRootElement, 255, 255, 255, false) end end addCommandHandler("idz", gzkill) --restricted I ran command /idz healLV 10. And got this: WARNING: zkillgive\main.lua:4: Bad argument @ 'getElementData' [Expected element at argument 1, got string 'healLV'] ERROR: zkillgive\main.lua:5: attempt to perform arithmetic on global 'pkills' (a boolean value) Link to comment
Revolt Posted December 30, 2015 Share Posted December 30, 2015 function gzkill(player, cmd, name, ammount) local otherPlayer = getPlayerFromName(name) if (otherPlayer) then local ammount = tonumber(ammount) lpkills = getElementData(player, "zombieskilled") pkills = getElementData(otherPlayer, "zombieskilled") akills = pkills + ammount rkills = lpkills - ammount setElementData(otherPlayer, "zombieskilled", akills) setElementData(player, "zombieskilled", rkills) outputChatBox("Sucessfully added!", root, 255, 255, 255, false) else outputChatBox("Wrong name!", root, 255, 255, 255, false) end end addCommandHandler("idz", gzkill) --restricted Link to comment
healLV Posted December 30, 2015 Author Share Posted December 30, 2015 function gzkill(player, cmd, name, ammount) local otherPlayer = getPlayerFromName(name) if (otherPlayer) then local ammount = tonumber(ammount) lpkills = getElementData(player, "zombieskilled") pkills = getElementData(otherPlayer, "zombieskilled") akills = pkills + ammount rkills = lpkills - ammount setElementData(otherPlayer, "zombieskilled", akills) setElementData(player, "zombieskilled", rkills) outputChatBox("Sucessfully added!", root, 255, 255, 255, false) else outputChatBox("Wrong name!", root, 255, 255, 255, false) end end addCommandHandler("idz", gzkill) --restricted Thanks 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