CobbTheWarriorsRPG Posted May 28, 2015 Share Posted May 28, 2015 Hi, I'm trying to make a resource to check if you are admin you can give values to the account of a player, but not work for me, I need help! thank you very much --Server Side: addCommandHandler("rechargemp", function (player, cmd, torecharge, ammount) local tocargaAccount = getAccountPlayer ( torecharge ) local accountname = getPlayerAccount ( player ) if isObjectInACLGroup ( "user.".. accountname, aclGetGroup ( "Admin" ) ) then --If you are admin you can give medalloPoints To the player account outputChatBox("You give "..ammount.." to "..torecharge.."") setAccountData( acc, "medalloPoints", tonumber(ammount)) setElementData( source, "medalloPoints", tonumber(ammount)) else outputChatBox("You are not admin") end end ) Link to comment
Walid Posted May 28, 2015 Share Posted May 28, 2015 acc it's not defined in your code. Ayways try this it should work addCommandHandler("rechargemp", function (player, cmd, torecharge, ammount) local target = getPlayerFromPartialName( torecharge ) local account = getPlayerAccount ( player ) if (isElement(target)) then local acc = getPlayerAccount(target) if isObjectInACLGroup ( "user."..getAccountName(account), aclGetGroup ( "Admin" ) ) then outputChatBox("You give "..ammount.." to "..torecharge.."") setAccountData( acc, "medalloPoints", tonumber(ammount)) setElementData( target, "medalloPoints", tonumber(ammount)) else outputChatBox("You are not admin",player,255,255,0) end else outputChatBox("This player does no longer exist!",player,255,255,0) end end ) function getPlayerFromPartialName(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end Link to comment
CobbTheWarriorsRPG Posted May 29, 2015 Author Share Posted May 29, 2015 @Walid it works!, thanks! Link to comment
Walid Posted May 29, 2015 Share Posted May 29, 2015 @Walid it works!, thanks! you are welcome. 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