2016-06-16 01:50:13 +01:00
require ( " global " ) ;
properties = {
permissions = 0 ,
parameters = " sssssss " ,
2016-06-17 05:05:31 +01:00
description =
[ [
2016-08-11 20:02:01 -04:00
Warp player or < targetname > to a location from a list , or enter a zoneID with coordinates .
! warp < spawn list > |
! warp < zone > < x > < y > < z > |
! warp < zone > < x > < y > < z > < privateArea > < targetname > |
2016-06-16 01:50:13 +01:00
] ] ,
}
2016-06-17 05:05:31 +01:00
function onTrigger ( player , argc , p1 , p2 , p3 , p4 , privateArea , name , lastName )
2016-06-16 01:50:13 +01:00
2016-06-17 05:05:31 +01:00
if name then
2016-06-16 01:50:13 +01:00
if lastName then
2016-06-17 05:05:31 +01:00
player = GetWorldManager ( ) : GetPCInWorld ( name .. " " .. lastName ) or nil ;
2016-06-16 01:50:13 +01:00
else
2016-06-17 05:05:31 +01:00
player = GetWorldManager ( ) : GetPCInWorld ( name ) or nil ;
2016-06-16 01:50:13 +01:00
end ;
end ;
if not player then
printf ( " [Command] [warp] error! No target or player specified! " ) ;
return ;
end ;
local messageID = MESSAGE_TYPE_SYSTEM_ERROR ;
local sender = " [warp] " ;
-- we're getting a list/array from c# so 0 index
local pos = player : GetPos ( ) ;
local player_x = pos [ 0 ] ;
local player_y = pos [ 1 ] ;
local player_z = pos [ 2 ] ;
local player_rot = pos [ 3 ] ;
local player_zone = pos [ 4 ] ;
local worldManager = GetWorldManager ( ) ;
2017-06-19 22:23:27 -04:00
if argc >= 3 then
2016-06-16 01:50:13 +01:00
if argc == 3 then
local x = tonumber ( applyPositionOffset ( p1 , player_x ) ) or player_x ;
local y = tonumber ( applyPositionOffset ( p2 , player_y ) ) or player_y ;
local z = tonumber ( applyPositionOffset ( p3 , player_z ) ) or player_z ;
player : SendMessage ( messageID , sender , string.format ( " setting coordinates X:%d Y:%d Z:%d within current zone (%d) " , x , y , z , player_zone ) ) ;
2017-08-26 13:53:23 -04:00
2017-04-05 18:39:04 -04:00
worldManager : DoPlayerMoveInZone ( player , x , y , z , player_rot , 0x00 ) ;
2016-06-16 01:50:13 +01:00
else
local zone = tonumber ( applyPositionOffset ( p1 , player_zone ) ) or player_zone ;
local x = tonumber ( applyPositionOffset ( p2 , player_x ) ) or player_x ;
local y = tonumber ( applyPositionOffset ( p3 , player_y ) ) or player_y ;
local z = tonumber ( applyPositionOffset ( p4 , player_z ) ) or player_z ;
if privateArea == " " then privateArea = nil end ;
player : SendMessage ( messageID , sender , string.format ( " setting coordinates X:%d Y:%d Z:%d to new zone (%d) private area:%s " , x , y , z , zone , privateArea or " unspecified " ) ) ;
2017-03-07 08:32:57 -05:00
worldManager : DoZoneChange ( player , zone , privateArea , 0 , 0x02 , x , y , z , 0.00 ) ;
2016-06-16 01:50:13 +01:00
end
else
player : SendMessage ( messageID , sender , " Unknown parameters! Usage: " .. properties.description ) ;
end ;
end ;
function applyPositionOffset ( str , offset )
local s = str ;
if s : find ( " @ " ) then
2016-08-11 20:02:01 -04:00
s = tonumber ( s : sub ( s : find ( " @ " ) + 1 , s : len ( ) ) ) ;
if s then s = s + offset end ;
2016-06-16 01:50:13 +01:00
end
2016-08-11 20:02:01 -04:00
print ( s ) ;
2016-06-16 01:50:13 +01:00
return s ;
end ;