Jump to content

Dar Dinheiro para todos do servidor


Recommended Posts

Olá, sou novo em programação e queria um script para dar dinheiro para todos os jogadores online no server, pesquisei e me deparei com o seguinte código:

 

function giveMoney(thePlayer, cmd, amount) 
    local amount = tonumber(amount) 
    if (amount) then 
        for index, player in ipairs(getElementsByType("player")) do 
            if (player ~= thePlayer) then 
                givePlayerMoney(player, amount) 
                outputChatBox(getPlayerName(thePlayer) .." Lhe Enviou#00FF00 R$".. amount .."!",player,0,255,0) 
            end 
        end 
    end 
end 
addCommandHandler( "givecash", giveMoney)

E fiz alguns testes mas não funcionou, gostaria de saber onde ta o erro e esse código é implementado na parte do servidor certo?

Link to comment
  • Moderators

Digite /debugscript 3 sempre que testar um script. Sim, o código é server-side, tente isto:


outputChatBox("Resource give money iniciado!",root)

function giveMoney(thePlayer, cmd, amount)
    if (amount) then
		 local amount = tonumber(amount)
        for index, player in ipairs(getElementsByType("player")) do 
            if (player ~= thePlayer) then 
                givePlayerMoney(player, amount) 
                outputChatBox(getPlayerName(thePlayer) .." Lhe Enviou#00FF00 R$".. tostring(amount) .."!",player,0,255,0) 
            end 
        end 
    else
        outputChatBox("Erro: digite a quantia a ser enviada!",thePlayer,255,0,0) 
    end
end 
addCommandHandler( "givecash", giveMoney)

Se não funcionar provavelmente é o seu arquivo meta errado.

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