TorNix~|nR Posted January 29, 2021 Share Posted January 29, 2021 (edited) Hello guys, I want some help with this command code please, it won't work like this: /kills 'accountname' 'amount' function isPlayerInACL(thePlayer, acl) local account = getPlayerAccount(thePlayer) if (account) and not (isGuestAccount(account)) then local aclGroup = aclGetGroup(acl) if (aclGroup) then local accountName = getAccountName(account) return isObjectInACLGroup("user."..accountName, aclGroup) end end return false end addCommandHandler("kills", function (thePlayer, _, account, amount) if (isPlayerInACL(thePlayer, "Admin")) and (tonumber(amount)) then local account = getPlayerAccount(player) local player = getAccountName(account) if (player) then if (setElementData(player, "kills", tonumber(amount))) then if (account) then setAccountData(account,"kills", tonumber(amount)) end outputChatBox("done", thePlayer, 0, 0, 255) else outputChatBox("failed", thePlayer, 255, 0, 0) end else outputChatBox("account not found", thePlayer, 255, 0, 0) end end end) Edited January 29, 2021 by TorNix~|nR Link to comment
SpecT Posted January 29, 2021 Share Posted January 29, 2021 (edited) I guess you want to make a function which sets the number of kills of an account you type in the command ? addCommandHandler("kills", function (thePlayer, _, account, amount) if (isPlayerInACL(thePlayer, "Admin")) and (tonumber(amount)) then local targetAccount = getAccount(account) if (targetAccount) then if (account) then setAccountData(account,"kills", tonumber(amount)) end outputChatBox("done", thePlayer, 0, 0, 255) else outputChatBox("failed", thePlayer, 255, 0, 0) end else outputChatBox("account not found", thePlayer, 255, 0, 0) end end end) Edited January 29, 2021 by SpecT Link to comment
TorNix~|nR Posted January 29, 2021 Author Share Posted January 29, 2021 setAccountData(account,"kills", tonumber(amount)) end I got Bad argument @ 'setAccountData' [Expected account at argument 1, got string '...'] how to check the account? Link to comment
SpecT Posted January 29, 2021 Share Posted January 29, 2021 Oops I made some mistakes This should work: addCommandHandler("kills", function (thePlayer, _, account, amount) if (isPlayerInACL(thePlayer, "Admin")) and (tonumber(amount)) then local targetAccount = getAccount(account) if (targetAccount) then if (setAccountData(targetAccount,"kills", tonumber(amount))) then outputChatBox("done", thePlayer, 0, 0, 255) else outputChatBox("failed", thePlayer, 255, 0, 0) end else outputChatBox("account not found", thePlayer, 255, 0, 0) end end end) 1 Link to comment
TorNix~|nR Posted January 29, 2021 Author Share Posted January 29, 2021 (edited) @SpecT, It's working thanks, but a little problem, when I make the command, the player should logout and login, how to change that into an immediately change? Edited January 29, 2021 by TorNix~|nR Link to comment
SpecT Posted January 29, 2021 Share Posted January 29, 2021 It depends how the player gets the kills count information. If it's with getElementData then this should update it immediately. addCommandHandler("kills", function (thePlayer, _, account, amount) if (isPlayerInACL(thePlayer, "Admin")) and (tonumber(amount)) then local targetAccount = getAccount(account) local targetPlayer = getAccountPlayer(targetAccount) if (targetAccount) then if (setAccountData(targetAccount,"kills", tonumber(amount))) then if targetPlayer then -- If there is a player logged into the account setElementData(targetPlayer, "kills", tonumber(amount)) end outputChatBox("done", thePlayer, 0, 0, 255) else outputChatBox("failed", thePlayer, 255, 0, 0) end else outputChatBox("account not found", thePlayer, 255, 0, 0) end end end) 1 Link to comment
TorNix~|nR Posted January 29, 2021 Author Share Posted January 29, 2021 Thank you, it's working 1 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