Jump to content

Detectar Players


Tonyx97

Recommended Posts

Hola a todos, tengo una duda, quiero que con un comando, le salga un mensage a la persona especifica, y si el player que definimos no existe que ponga en chatbox "This player doesn't exist", yo lo consegui, pero me salia tantos mensages como players habia en el server.

function llamar (thePlayer,commandName,player,text) 
    if player then --Aqui debe de ir el codigo que les pido a ustedes, La ayuda. 
        outputChatBox ("..(text)..", player, 255, 0, 0) 
    end 
end 
addCommandHandler ("llamar", llamar) 

Link to comment

podrias usar esta funcion.

Ve si funciona esa o remoldealo

function llamar(player,cmd,playername,text) 
    if playername and text then 
      local player2 = findPlayerByName(playername) 
      if player2 then 
        outputChatBox ("..(text)..", player2, 255, 0, 0) 
       end 
end 
end 
addCommandHandler("llamar",llamar) 
  
function findPlayerByName (name) 
    local player = getPlayerFromName(name) 
    if player then return player end 
    for i, player in ipairs(getElementsByType("player")) do 
        if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then 
            return player 
        end 
    end 
return false 
end 

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...