• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

TalkAction [TFS 0.2.6] /send

SaLeM

New Member
Joined
Oct 14, 2007
Messages
97
Reaction score
0
Location
Spain
Hiya!

Finally I have completed this script that I really wanted. It sends a player to an XYZ position:

First:

Type this into your data/talkactions/talkactions.xml file:

PHP:
<talkaction words="/send" script="sending.lua"/>

Then, go to data/talkactions/scripts/ and create a .lua file called sending.lua. Within it, paste this using Notepad or any text editor:

PHP:
function onSay(cid, words, param)
	if getPlayerGroupId(cid) < 3 then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You cannot use this command")
  elseif param ~= "" then
    if string.find(param, ',') ~= nil then
      local sep1 = string.find(param, ',')
      local param1 = string.sub(param, 1, sep1-1)
      local subparam1 = string.sub(param,sep1+1,string.len(param))
      if string.find(subparam1, ',') ~= nil then
        local sep2 = string.find(subparam1, ',')
        local param2 = string.sub(subparam1,1,sep2-1)
        local subparam2 = string.sub(subparam1,sep2+1,string.len(param))
        if string.find(subparam2, ',') ~= nil then
          local sep3 = string.find(subparam2, ',')
          local param3 = string.sub(subparam2,1,sep3-1)
          local param4 = string.sub(subparam2,sep3+1,string.len(param))
          local target = getPlayerByName(param1)
          
          if target == FALSE then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
          elseif param1 == "" then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player")
          elseif (param2 == "") or (isNumber(param2) == FALSE)  then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type X")
          elseif (param3 == "") or (isNumber(param3) == FALSE)  then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type Y")
          elseif (param4 == "") or (isNumber(param4) == FALSE)  then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type Z")
          elseif words == "/send" then	
            posicion = {x = param2, y = param3, z = param4}
            doTeleportThing(target, posicion, 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You have sent " .. getCreatureName(target) .. " to position: x= " .. param2 .. ", y= " .. param3 .. ", z= " .. param4 .. ".")
          end
        else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /send \"Name,X,Y,Z")
        end
      else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /send \"Name,X,Y,Z")
      end
    else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /send \"Name,X,Y,Z")
    end
  else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must set a player and XYZ position")
  end
end

Where:

if getPlayerGroupId(cid) < 3 then

is the minimun group id to use this command.

Then, ingame, type this to teleport any player to any position:

/send "playername,x,y,z

If you find any bug, just tell it to me. :)

Edit: Changed "-" separator to "," because some players might have a name with "-".

Greetz
 
Last edited:
Nice script, been trying to request this command for a while now, thanks!
 
Nice, but I think you should make it with commas like:
/send "God Lord,x,y,x

Because I don't think it will work if the player has a "-" in his/her name
 
@Up

Thanks! ^^.

Nice, but I think you should make it with commas like:
/send "God Lord,x,y,x

Because I don't think it will work if the player has a "-" in his/her name

Thanks too. Talaturen also suggested me that, so now it's updated.

:)
 
A command could do so?

Example: /sendtown "Kyron,Carlin

Yeah, try this:

PHP:
local idgroup = 5   --Min Group Access

function onSay(cid, words, param)
  if getPlayerGroupId(cid) < idgroup then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You aren't allowed to use this command")
  elseif param ~= "" then
    if string.find(param, ',') ~= nil then
      local sep1 = string.find(param, ',')
      local param1 = string.sub(param, 1, sep1-1)
      local param2 = string.sub(param,sep1+1,string.len(param))
      local target = getPlayerByName(param1)
      
      local carlin = {x = 123, y = 123, z = 123}
      local thais = {x = 123, y = 123, z = 123}
      local rook = {x = 123, y = 123, z = 123}
      local venore = {x = 123, y = 123, z = 123}
      local abdendriel = {x = 123, y = 123, z = 123}
      
      if target == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
      elseif param1 == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player")
      elseif (param2 == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a city")
      elseif words == "/sendtown" then    
        player = getCreatureName(target)
        city = string.lower(param2)
        if city == "carlin" then
          doTeleportThing(target, carlin, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        elseif city == "thais" then
          doTeleportThing(target, thais, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        elseif city == "rook" then
          doTeleportThing(target, rook, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        elseif city == "venore" then
          doTeleportThing(target, venore, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        elseif city == "abdendriel" then
          doTeleportThing(target, abdendriel, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "City doesn't exist")
        end
      end
    else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /send \"Name,City")
    end
  else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player and a city")
  end
end

Change your cities to the ones you want, and also change your city position:

local carlin = {x = 123, y = 123, z = 123}
local thais = {x = 123, y = 123, z = 123}
local rook = {x = 123, y = 123, z = 123}
local venore = {x = 123, y = 123, z = 123}
local abdendriel = {x = 123, y = 123, z = 123}

if city == "carlin" then
doTeleportThing(target, carlin, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
elseif city == "thais" then
doTeleportThing(target, thais, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
elseif city == "rook" then
doTeleportThing(target, rook, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
elseif city == "venore" then
doTeleportThing(target, venore, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
elseif city == "abdendriel" then
doTeleportThing(target, abdendriel, 1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)

;)
 
Last edited:
Yeah SaleM, It's nice! I added you Rep+ :thumbup:

I've found a little error on the second script.
This:
PHP:
    else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /send \"Name,City")
    end
Should be this:
PHP:
     else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /sendtown \"Name,City")
    end

It's just the "sendtown" word :p
 
Yeah SaleM, It's nice! I added you Rep+ :thumbup:

I've found a little error on the second script.
This:
PHP:
    else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /send \"Name,City")
    end
Should be this:
PHP:
     else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /sendtown \"Name,City")
    end

It's just the "sendtown" word :p
 
Yeah, try this:

PHP:
local idgroup = 5   --Min Group Access

function onSay(cid, words, param)
  if getPlayerGroupId(cid) < idgroup then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You aren't allowed to use this command")
  elseif param ~= "" then
    if string.find(param, ',') ~= nil then
      local sep1 = string.find(param, ',')
      local param1 = string.sub(param, 1, sep1-1)
      local param2 = string.sub(param,sep1+1,string.len(param))
      local target = getPlayerByName(param1)
      
      local carlin = {x = 123, y = 123, z = 123}
      local thais = {x = 123, y = 123, z = 123}
      local rook = {x = 123, y = 123, z = 123}
      local venore = {x = 123, y = 123, z = 123}
      local abdendriel = {x = 123, y = 123, z = 123}
      
      if target == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
      elseif param1 == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player")
      elseif (param2 == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a city")
      elseif words == "/sendtown" then    
        player = getCreatureName(target)
        city = string.lower(param2)
        if city == "carlin" then
          doTeleportThing(target, carlin, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        elseif city == "thais" then
          doTeleportThing(target, thais, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        elseif city == "rook" then
          doTeleportThing(target, rook, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        elseif city == "venore" then
          doTeleportThing(target, venore, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        elseif city == "abdendriel" then
          doTeleportThing(target, abdendriel, 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player.. " has been sent to: "..city)
        else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "City doesn't exist")
        end
      end
    else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /send \"Name,City")
    end
  else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player and a city")
  end
end

Change your cities to the ones you want, and also change your city position:





;)


Shorter:
PHP:
local idgroup = 5   --Min Group Access

function onSay(cid, words, param)
  if getPlayerGroupId(cid) < idgroup then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You aren't allowed to use this command")
  elseif param ~= "" then
    if string.find(param, ',') ~= nil then
      local sep1 = string.find(param, ',')
      local param1 = string.sub(param, 1, sep1-1)
      local param2 = string.sub(param,sep1+1,string.len(param))
      local target = getPlayerByName(param1)
      
      local towns = {
	    ["carlin"] = {x = 123, y = 123, z = 123}
        ["thais"] = {x = 123, y = 123, z = 123}
        ["rook"] = {x = 123, y = 123, z = 123}
        ["venore"] = {x = 123, y = 123, z = 123}
        ["abdendriel"] = {x = 123, y = 123, z = 123}
      }
      if target == FALSE then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "A player with that name is not online")
      elseif param1 == "" then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player!")
      elseif (param2 == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a city!")
      elseif words == "/sendtown" then    
        player = getCreatureName(target)
        city = string.lower(param2)
        if towns[city] ~= nil then
          doTeleportThing(target, towns[city], 1)
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, player .. " has been sent to: " .. city)	  
        else
          doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "City doesn't exist")
        end
      end
    else
      doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "Wrong format: /send \"Name,City")
    end
  else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, "You must type a player and a city")
  end
end
 
Back
Top