Jump to content

[HELP]setAccountData


Recommended Posts

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

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

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...