• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Spell Search Player

Status
Not open for further replies.

Light Yagami

Banned User
Joined
Feb 12, 2017
Messages
20
Reaction score
6
Greetings all!

This is my 1st script :) It emulates find player which also sends a text to the player you are looking for that the person who cast the spell is looking for them and gives them their location.

Lua:
-- this returns the offset of x, y, z
function getOffsetXYZ(pos1, pos2)
    return (pos1.x - pos2.x), (pos1.y - pos2.y), (pos1.z - pos2.z)
end

-- self explanitory
function getFloorLevel(z)
    if z > 0 then
        return "higher"
    elseif z < 0 then
        return "lower"
    end
    return "same"
end

-- self explanitory
function getDistance(x, y)
    local distance = ''
    if math.abs(x) < 4 and math.abs(y) < 4 then
        distance = "beside"
    else
        local d = x * x + y * y
        if d < 10000 then
            distance = "close"
        elseif d < 75076 then
            distance = "far"
        else
            distance = "very far"
        end
    end
    return distance
end

-- self explanitory
function getDirection(x, y)
    local t, direction = 0, ''
    if x ~= 0 then
        t = y / x
    else
        t = 10.
    end

    if math.abs(t) < 0.4142 then
        if x > 0 then
            direction = "west"
        else
            direction = "east"
        end
    elseif math.abs(t) < 2.4142 then
        if t > 0 then
            if y > 0 then
                direction = "north-west"
            else
                direction = "south-east"
            end
        else
            if x > 0 then
                direction = "south-west"
            else
                direction = "north-east"
            end
        end
    else
        if y > 0 then
            direction = "north"
        else
            direction = "south"
        end
    end
    return direction
end

-- returns a general location of the player 
function getLocation(x, y, z)
    local distance = getDistance(x, y)
    local level = getFloorLevel(z)
    local msg = ''
    if distance == "beside" then
        if level == "same" then
            return " is standing next to you."
        elseif level == "higher" then
            return " is above you."
        elseif level == "lower" then
            return " is below you."
        end
    elseif distance == "close" then
        if level == "same" then
            msg = " is to the "
        elseif level == "higher" then
            msg = " is on a higher level to the "
        elseif level == "lower" then
            msg = " is on a lower level to the "
        end
    elseif distance == "far" then
        msg = " is far to the "
    elseif distance == "very far" then
        msg = " is very far to the "
    end
    return msg .. getDirection(x, y) .. "."
end

-- send the target you are trying to find a message?
local sendTargetText = true

-- if so, what message would you like to send?
local targetMsg = " just exiva'd you"

function onCastSpell(creature, variant)
    local target = Creature(variant["string"])
    if target then
        if target:isPlayer() then
            -- default message
            local text = "You can not exiva yourself."
            local isSelf = target:getName() == creature:getName()
            -- if you aren't exivaing yourself then get the target's whereabouts
            if not isSelf then
                text = target:getName() .. getLocation(getOffsetXYZ(creature:getPosition(), target:getPosition()))
            end
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, text)
            -- send a message to the player when someone uses exiva on them, cannot exiva yourself
            if sendTargetText and not isSelf then
                -- message to send to the player, or make up one of your own and assign it to text
                text = creature:getName() .. targetMsg ..  " and" .. getLocation(getOffsetXYZ(target:getPosition(), creature:getPosition()))
                target:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, text)
            end
        end
    end
    return true
end
 
did you copy this from somewhere?
you said you were just starting out and now you say you made this lol
 
Sorry for double post I made a lua variation of the code in the sources :)
 
"My 1st script".
ttqUh5m.png
 
Looks very fresh, good job.

did you copy this from somewhere?
you said you were just starting out and now you say you made this lol
Give to the community some chances to grow, what matters if he copied? If he did so, prove it so we can all laugh.
 
Looks very fresh, good job.


Give to the community some chances to grow, what matters if he copied? If he did so, prove it so we can all laugh.
the thing is, he is a banned member from this community, which is why i asked.
he thought pretending to learn setting up a server and learning all tfs code within a day wouldn't be suspicious
no one just starting out would be able to do that
 
the thing is, he is a banned member from this community, which is why i asked.
he thought pretending to learn setting up a server and learning all tfs code within a day wouldn't be suspicious
no one just starting out would be able to do that
They are really scrapping the bottom of the barrel for people to join the support team (i guess that can be an issue when most of the people who do know wtf they are doing leave). I don't know why they made you part of the support team. Its not as if you know anything about programming lolz hell you don't even know how to talk to people.
Keep banning people for no apparent reason (must be envy) or just plain stupidity.
 
They are really scrapping the bottom of the barrel for people to join the support team (i guess that can be an issue when most of the people who do know wtf they are doing leave). I don't know why they made you part of the support team. Its not as if you know anything about programming lolz hell you don't even know how to talk to people.
Keep banning people for no apparent reason (must be envy) or just plain stupidity.
you are banned for a reason, stay that way
attempting to spew shit at me to get some enraged response won't help
 
Status
Not open for further replies.
Back
Top