Jump to content

What's wrong with this?


12p

Recommended Posts

I want to give money to a player basing in just some letters (like in admin panel). For example:

Player Objetive: Maurize

Word on Command for Player: Mau

Well, it doesn't find any player...

addCommandHandler ("dardinero", 
function (player,_,destiny,cash) 
    if destiny and cash then 
    if getPlayerMoney (player) >= tonumber(cash) then 
    local matchPlayers = {} 
    local players = getElementsByType ("player") 
    for i,p in ipairs (players) do 
        local name = getPlayerName (p) 
        if string.find(destiny,name) then 
            table.insert(matchPlayers,p) 
            outputChatBox ("test") 
        end 
    end 
    if table.getn(matchPlayers) == 1 then 
        takePlayerMoney (player,tonumber(cash)) 
        givePlayerMoney (matchPlayers[1],tonumber(cash)) 
        outputChatBox ("INFO: Enviaste $"..cash.." a "..getPlayerName(matchPlayers[1])..".",player,0,255,0) 
        outputChatBox ("INFO: Recibiste $"..cash.." de "..getPlayerName(player)..".",matchPlayers[1],0,255,0) 
    elseif table.getn(matchPlayers) > 1 then 
        outputChatBox ("ERROR: Hay mas de un jugador con este nombre.",player,255,0,0) 
    else 
        outputChatBox ("ERROR: No hay jugadores con este nombre.",player,255,0,0) 
    end 
    else 
        outputChatBox ("ERROR: Tus fondos son insuficientes.",player,255,0,0) 
    end 
     
    else 
        outputChatBox ("ERROR: Falta algun argumento.",player,255,0,0) 
    end 
end) 

Edited by Guest
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...