Jump to content

[help] Request Warp


Recommended Posts

the script is to send an invitation to another player an invitation to warp more than is started only if the other player accepts What did this wrong?

local invitations = {} 
  
addCommandHandler("tpa", 
function (thePlayer, cmd, who) 
    if (not who or who == "") then outputChatBox("/"..cmd..": Nenhum jogador inserido.",thePlayer,255,0,0) return end 
    local player = getPlayerFromName(who) 
    if (not player) then outputChatBox("/"..cmd..": Esse player não existe.",thePlayer,255,0,0) return end 
    if (invitations[thePlayer]) then outputChatBox("/"..cmd..": Você já enviou um convite tpa.",thePlayer,255,0,0) return end 
    outputChatBox(getPlayerName(player) .." Quer ir até você digite /aceitar ".. getPlayerName(thePlayer) ..".",player,0,255,0) 
    outputChatBox("Você um convite de tpa para".. getPlayerName(player) ..".",player,0,255,0) 
    invitations[thePlayer] = player 
    setTimer(function () invitations[thePlayer] = nil end, 60000, 1) 
end) 
  
addCommandHandler("aceitar", 
function (thePlayer, cmd, who) 
    if (not who or who == "") then outputChatBox("/"..cmd..": Nenhum jogador inserido.",thePlayer,255,0,0) return end 
    local player = getPlayerFromName(who) 
    if (not player) then outputChatBox("/"..cmd..": Esse player não existe.",thePlayer,255,0,0) return end 
    if invitations[player] then 
        setElementPosition(player, getElementPosition(thePlayer)) 
        outputChatBox("Você aceitou o tpa de ".. getPlayerName(player) .."'s ",thePlayer,0,255,0) 
        outputChatBox(getPlayerName(thePlayer) .. " aceitou o seu convite warp.",player,0,255,0) 
        invitations[player] = nil 
    end 
end) 
  
function getPlayerFromNickPart(part) 
  local player 
  part=string.lower(part) 
  for _,p in ipairs(getElementsByType("player")) do 
    local nick=string.lower(getPlayerName(p):gsub("#%x%x%x%x%x%x","")) 
    if string.find(nick,part) then 
      if not player then 
        player=p 
      else 
        return false 
      end 
    end 
  end 
  return player 
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...