Jump to content

Warp/Teleport accept


Ralf122

Recommended Posts

i can look how you did it. it's almost the same as accept. am i right?

EDIT;

the only thing whats irritating is you have to write the whole name with colorcodes ETC.

I tested it with a friend but my mate did /warpto [name] and it worked but it said warp is not allowed to. because i blocked the Freeroam warping.

Link to comment
local invitations = {} 
  
function getPlayerByPartOfName(playerPart) 
  local pl = getPlayerFromName(playerPart) 
  if isElement(pl) then 
    return pl 
  else 
    for i,v in ipairs (getElementsByType ("player")) do 
      if (string.find(getPlayerName(v),playerPart)) then 
        return v 
      end 
    end 
  end 
end 
  
addCommandHandler("warpto", 
function (thePlayer, cmd, who) 
    if (not who or who == "") then outputChatBox("/"..cmd..": No player inserted.",thePlayer,255,0,0) return end 
    local player = getPlayerByPartOfName(who) 
    if (not player) then outputChatBox("/"..cmd..": This player does not exists.",thePlayer,255,0,0) return end 
    if (invitations[thePlayer]) then outputChatBox("/"..cmd..": You already sent a warp invitation.",thePlayer,255,0,0) return end 
    outputChatBox(getPlayerName(player) .." want's to warp to you, write /accept ".. getPlayerName(thePlayer) ..".",player,0,255,0) 
    outputChatBox("You have sent a warp invitation to ".. getPlayerName(player) ..".",player,0,255,0) 
    invitations[thePlayer] = player 
    setTimer(function () invitations[thePlayer] = nil end, 60000, 1) 
end) 
  
addCommandHandler("accept", 
function (thePlayer, cmd, who) 
    if (not who or who == "") then outputChatBox("/"..cmd..": No player inserted.",thePlayer,255,0,0) return end 
    local player = getPlayerByPartOfName(who) 
    if (not player) then outputChatBox("/"..cmd..": This player does not exists.",thePlayer,255,0,0) return end 
    if invitations[player] then 
        setElementPosition(player, getElementPosition(thePlayer)) 
        outputChatBox("You have accepted ".. getPlayerName(player) .."'s warp invitation.",thePlayer,0,255,0) 
        outputChatBox(getPlayerName(thePlayer) .. " accepted your warp invitation.",player,0,255,0) 
        invitations[player] = nil 
    end 
end) 

Link to comment
  
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 
  

returns player from nick part, ignoring colorcodes and caps.returns false if more then 1 player with that nick part.

bit better then solidsnakes, because of the ignoring colorcodes, caps, and caring of more then 1player check.

Link to comment
  
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 
  

returns player from nick part, ignoring colorcodes and caps.returns false if more then 1 player with that nick part.

bit better then solidsnakes, because of the ignoring colorcodes, caps, and caring of more then 1player check.

do i have to replace the script of Solidsnake with this one?

Link to comment

Dude, we answered your questions.

We taked part from our free time, which we could use to improve our very scripts and projects, to help you.

Just, PLEASE, try to learn yourself how to make scripts!

Castillo learned by himself, me too and possibly many others guys learned without nothing else than the wiki and interest on the theme!

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