Jump to content

[Help] Warping script


Mr.Loki

Recommended Posts

Ok so i have been working on this warp script for the past hour and i cant seem to get it to work... i get no errors is the debug

what am i doing wrong? :?

function letsRoll (source, comm, destination) 
    if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) or isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("Moderator")) then 
            if destination == et then 
                    setElementPosition ( source, 7310.5,-2082.821,2587.76, true ) 
            elseif destination == island  then 
                    setElementPosition ( source, 7092.68,-2012.89,1, true ) 
            elseif destination == rr then 
                    setElementPosition ( source, 217.34,1822.79,6.41, true ) 
            elseif destination == rrg then 
                    setElementPosition ( source, 217.34,1822.79,11.41, true ) 
            elseif destination == area then 
                    setElementPosition ( source, 209.19,1934.13,23.24, true ) 
            elseif destination == ic then 
                    setElementPosition ( source, 1334.96,2068.11,25.59, true ) 
         
        end 
    end 
end 
addCommandHandler ( "warp", letsRoll  ) 

Link to comment
The problem is at the elseif and if statments, when you are comparing and checking if the value is that, it's not a string.

like this: elseif destination == rrg

change it to

"rrg"

thanks its working now :D:D

but i thought that solving his would help me with another code i had in the script but it didn't

function warpto(source, _, target1, target2) 
         
        if (taget2) then 
           local q1,w1,e1 = getElementPosition(gPPN(target1)) 
            setElementPosition(gPPN(target2), q1,w1,e1+10,true) 
             
        else 
            local q,w,e = getElementPosition(gPPN(target1)) 
            setElementPosition(source, q+.5,w+.5,e+1,true) 
             
    end 
end 
  
addCommandHandler("tp",warpto) 
  
function gPPN(name) 
    local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil 
    if name then 
        for _, player in ipairs(getElementsByType("player")) do 
            local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() 
            if name_:find(name, 1, true) then 
                return player 
            end 
        end 
    end 
end 

i am trying to warp 1 player to the next unless a second player is provided it warps me to the target...

but when i try to warp a player to a next player it just warps me to the target1

Link to comment

ok i reviweed the script and i added

function warpto(source, _, target1, target2) 
    if isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) or isObjectInACLGroup("user." ..getAccountName(getPlayerAccount(source)), aclGetGroup("Moderator")) then 
         
        if (target1 and target2) then 
           local q1,w1,e1 = getElementPosition(gPPN(target2)) 
            setElementPosition(gPPN(target1), q1,w1,e1+10,true) 
             
        elseif (  target1 and not target2 ) then 
            local q,w,e = getElementPosition(gPPN(target1)) 
            setElementPosition(source, q+.5,w+.5,e+1,true) 
             
        end 
    end 
end 
addCommandHandler("tp",warpto) 

and it worked perfectly thank you for your help :D:D

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