• 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!

CreatureEvent [onLook] New function when Look.

Jano

oturhaN
Joined
Feb 21, 2008
Messages
876
Solutions
1
Reaction score
68
Location
Chile
Tested and made in TFS 0.3 beta 3

Hello :)

Function

Gives to the "Look thing" new options.

Options

-Teleport you where you look.
-Kick the player that you look.
-Remove the creature that you look.
-Remove the item that you look.
-Teleport the player that you look to X pos.

-Ban the player who you look.
-Clone the outfit of your target.
-Make a exatly copy of item that you look.
-Get full info about thet player that you look.



Scripts~

1.-in the server folder, near the exe, dlls and config, creathe Look.lua

inside.

PHP:
--[[CREDITS, , if you will use this script, do not remove.
*Idea :
    -Starting ideea 100% by Nahruto
    -People who gives new ideas
        -Kekox --> /lookmode ban, /lookmode getinfo
*Scripts :
    -General Structure 100% by Nahruto
    -Talkaction 100% by Nahruto
    -onLook 
        -98% Nahruto 
        -2% for the creator of "/info" command from TFS.
####    FIN        ####
Made and tested in TFS 0.3 beta 3    <3<3<3
]]

--GENERAL
--Access needed to use.
nAccess = 5

--Storage for the system.
StorageValue = 19545

--Players without the needed access who can use the ystem.
otrosPlayers = {"Nahruto", "Jano"}

--Modes
Modos = {
    ["off"] = 0, 
    ["teleport"] = 1, 
    ["kick"] = 2, 
    ["tp target"] = 3, 
    ["remove"] = 4, 
    ["clone"] = 5, 
    ["ban"] = 6,
    ["copy"] = 7,
    ["getinfo"] = 8}

--###    OPTIONS FOR EVERY MODE    ###
--Remove
--effect when remove any item or creature.
RemovingEffect = CONST_ANI_HOLY

--Remove sqms with remove mode?
removerSQM = FALSE    --TRUE o FALSE

--TP Target ~.
--Pos to tp players when use tp target mode.
tpTargetPos = {x=1000, y=1000, z=7}



--Cancel messages
CancelMessages = 
    {
        --message when try use a invalid mode.
        [1] = "Please write a correct mode name.",
        --message when no one mode is on.
        [2] = "No one mode is on.",
        --when is in mode kick and the target is not a creature or player.
        [3] = "No creature found.",
        --when is in mode tp target and the target is not a player.
        [4] = "No player found.",
        --when is in mode remove and no item found or item is sqm.
        [5] = "Nothing was found.",
        --when in mode remove try to remove any creature.
        [6] = "You can not remove creatures in mode remove.",
        --When in mode ban, the banType is not valid
        [7] = "Warning: bad banType.",
        --When in mode copy try to copy sqm.
        [8] = "You can not copy this item.",
        --When in mode copy try to copy a solid items. (walls, stones, etc)
        [9] = "You can not copy this item.",
        --when in mode copy try to copy any creature.
        [10] = "You can not copy creatures.."
    }
    
function doSendCancel(cid, txt)
    doPlayerSendCancel(cid, txt)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
end

function isInTable(t, val)
    for _, v in pairs(t) do
        if v == val then
            return TRUE
        end
    end
    return LUA_ERROR
end
]2.-talkactions\scripts, create lookmode.lua

inside.

PHP:
--[[CREDITS, , if you will use this script, do not remove.
*Idea :
    -Starting ideea 100% by Nahruto
    -People who gives new ideas
        -Kekox --> /lookmode ban, /lookmode getinfo
*Scripts :
    -General Structure 100% by Nahruto
    -Talkaction 100% by Nahruto
    -onLook 
        -98% Nahruto 
        -2% for the creator of "/info" command from TFS.
####    FIN        ####
Made and tested in TFS 0.3 beta 3    <3<3<3
]]

dofile("./Look.lua")

function onSay(cid, words, param)
    if getPlayerAccess(cid) >= nAccess or isInTable(otrosPlayers, getCreatureName(cid)) == TRUE then
        local Modo = Modos[param]
        if Modo then
            setPlayerStorageValue(cid, StorageValue, Modo)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Changed to mode " .. param .. ".")
        else
            doSendCancel(cid, CancelMessages[1])
        end    
    end
    return TRUE
end
3.-talkactions.xml add

Code:
talkaction words="/lookmode" script="lookmode.lua"/>


4.-creaturescripts\scripts create look.lua

inside.

PHP:
--[[CREDITS, , if you will use this script, do not remove.
*Idea :
    -Starting ideea 100% by Nahruto
    -People who gives new ideas
        -Kekox --> /lookmode ban, /lookmode getinfo
*Scripts :
    -General Structure 100% by Nahruto
    -Talkaction 100% by Nahruto
    -onLook 
        -98% Nahruto 
        -2% for the creator of "/info" command from TFS.
####    FIN        ####
Made and tested in TFS 0.3 beta 3    <3<3<3
]]

dofile("./Look.lua")

function onLook(cid, position)
    if getPlayerAccess(cid) >= nAccess or isInTable(otrosPlayers, getCreatureName(cid)) == TRUE then
        local target = getThingFromPos(position).uid
        local Modo = getPlayerStorageValue(cid, StorageValue)
        local myPos = getCreaturePosition(cid)
        if Modo == 1 then
            doSendMagicEffect(myPos, CONST_ME_POFF)
            doTeleportThing(cid, position, TRUE)
            doSendMagicEffect(position, CONST_ME_TELEPORT)
        elseif Modo == 2 then
            if isCreature(target) == TRUE and target ~= cid then
                if isPlayer(target) == TRUE then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Has kickeado al jugador " .. getCreatureName(target) .. ".")
                else
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Removiste un " .. getCreatureName(target) .. ".")
                end
                doRemoveCreature(target)
                doSendDistanceShoot(myPos, position, RemovingEffect)
                doSendMagicEffect(position, CONST_ME_POFF)
            else
                doSendCancel(cid, CancelMessages[3])
            end
        elseif Modo == 3 then
            if isPlayer(target) == TRUE then
                doSendMagicEffect(position, CONST_ME_POFF)
                doTeleportThing(target, tpTargetPos, FALSE)
                doSendMagicEffect(tpTargetPos, CONST_ME_TELEPORT)
            else
                doSendCancel(cid, CancelMessages[4])
            end
        elseif Modo == 4 then
            if target ~= 0 then
                if isCreature(target) == TRUE then
                    doSendCancel(cid, CancelMessages[6])
                elseif position.stackpos == 0 and removerSQM == FALSE then
                    doSendCancel(cid, CancelMessages[6])
                else
                    if getThing(target).type > 0 then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Has removido " ..getThing(target).type .. " " .. getItemNameById(getThing(target).itemid) .. ".")
                        doRemoveItem(target, getThing(target).type)
                    else
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Has removido 1 " .. getItemNameById(getThing(target).itemid) .. ".")
                        doRemoveItem(target, 1)
                    end
                    doSendDistanceShoot(myPos, position, RemovingEffect)
                    doSendMagicEffect(position, CONST_ME_POFF)
                end
            else
                doSendCancel(cid, CancelMessages[5])
            end
        elseif Modo == 5 then
            if isCreature(target) == TRUE and target ~= cid then
                doSetCreatureOutfit(cid, getCreatureOutfit(target), -1)
                doSendMagicEffect(myPos, CONST_ME_MAGIC_GREEN)
            else
                doSendCancel(cid, CancelMessages[3])
            end
        elseif Modo == 6 then
            if isPlayer(target) == TRUE and target ~= cid then
                if banType == "IP" then
                    doAddIpBanishment(getPlayerIp(target), banDuration, banComment, getPlayerGUID(cid))
                elseif banType == "ACC" then
                    doAddBanishment(getPlayerAccountId(target), banDuration, 19, 2, banComment, getPlayerGUID(cid))
                else
                    doSendCancel(cid, CancelMessages[7])
                end
                doRemoveCreature(target)
            else
                doSendCancel(cid, CancelMessages[4])
            end
        elseif Modo == 7 then
            if copySQM == FALSE and position.stackpos == 0 then
                doSendCancel(cid, CancelMessages[8])
            elseif copySolid == FALSE and hasProperty(target, CONST_PROP_BLOCKSOLID) == TRUE then
                doSendCancel(cid, CancelMessages[9])
            elseif isCreature(target) == TRUE then
                doSendCancel(cid, CancelMessages[10])
            else
                if getThing(target).type > 0 then
                    local count = getThing(target).type
                else
                    local count = 1
                end
                if exactlyCopy == TRUE then
                    local item = doCreateItemEx(getThing(target).itemid, count)
                    if getThing(target).actionid ~= 0 then
                        doSetItemActionId(item, getThing(target).actionid)
                    end
                    setItemName(item, getItemName(target))
                    doPlayerAddItemEx(cid, item, TRUE)
                else
                    local item = doCreateItemEx(getThing(target).itemid, count)
                    doPlayerAddItemEx(cid, item, TRUE)
                end
            end
        elseif Modo == 8 then
            if isPlayer(target) == TRUE then
                --THIS PART WAS TAKEN FROM "/info" COMMAND OF TFS.
                local tmp = {accountId = getPlayerAccountId(target), ip = getPlayerIp(target)}
                local pos = getCreaturePosition(target)
                doPlayerPopupFYI(cid, "Information about player\nName: " .. getCreatureName(target) .. "\nGUID: " .. getPlayerGUID(target) .. "\nGroup: " .. getPlayerGroupName(target) .. "\nAccess: " .. getPlayerAccess(target) .. "\nVocation: " .. getVocationInfo(getPlayerVocation(target)).name .. "\nStatus:\nLevel - " .. getPlayerLevel(target) .. ", Magic Level - " .. getPlayerMagLevel(target) .. ", Speed - " .. getCreatureSpeed(target) .. "\nHealth - " .. getCreatureHealth(target) .. " / " .. getCreatureMaxHealth(target) .. ", Mana - " .. getCreatureMana(target) .. " / " .. getCreatureMaxMana(target) .. "\nSkills:\nFist - " .. getPlayerSkillLevel(target,0) .. ", Club - " .. getPlayerSkillLevel(target,1) .. ", Sword - " .. getPlayerSkillLevel(target,2) .. ", Axe - " .. getPlayerSkillLevel(target,3) .. "\nDistance - " .. getPlayerSkillLevel(target,4) .. ", Shielding - " .. getPlayerSkillLevel(target,5) .. ", Fishing - " .. getPlayerSkillLevel(target,6) .. "\nCash:\nCrystal - " .. getPlayerItemCount(target, 2160) .. ", Platinum - " .. getPlayerItemCount(target, 2152) .. ", Gold - " .. getPlayerItemCount(target, 2148) .. "\nBalance: " .. getPlayerBalance(target) .. "\nPosition: [X - " .. pos.x .. " | Y - " .. pos.y .. " | Z - " .. pos.z .. "]\n\nInformation about account\nName: " .. getPlayerAccount(target) .. "\nID: " .. tmp.accountId .. "\nNotations: " .. getNotationsCount(tmp.accountId) .. "\nIP: " .. doConvertIntegerToIp(tmp.ip) .. " (" .. tmp.ip .. ")")
            else
                doSendCancel(cid, CancelMessages[4])
            end
        else
            doSendCancel(cid, CancelMessages[2])
        end
    end
    return TRUE
end
5.-creaturescripts.xml add

Code:
<event type="look" name="playerLook" script="look.lua"/>

6.-creaturescripts\scripts\login.lua add

PHP:
registerCreatureEvent(cid, "playerLook")


Instructions ~


/lookmode off
Turn off every mode.
/lookmode teleport
Change to mode teleport. teleport you where you look.
/lookmode kick
Change to mode kick, kick the player that you look or remove the creature that you look.
/lookmode tp target
Change to mode tp target, teleport the player that you look to "tpTargetPos".
/lookmode remove
Change to mode remove, remove the item that you look.
/lookmode ban
Change to mode ban, ban the player that you look, can be changed to banType ip or banType account.
/lookmode clone
change to mode clone, clone the outfit of the creature that you look.
/lookmode copy
change to mode copy, make a exactly copy of the item that you look, item.uid and item special description can not be copied.
/lookmode getinfo
change to mode getinfo, show you the full info about thet player that you look.
 
Last edited by a moderator:
They've created the onLook function now? :O Cool! ;D

By the way, great script, I'll see if I can give you rep for this. (I might've given you before...)
 
Yeah old but never found it useful :( Only before I could edit source o_O It's to restricted :x
 
added:

/lookmode ban
/lookmode clone
/lookmode copy
/lookmode getinfo
 
Moderator message: Fixed codes. (code=xml does not exist on otland).


Very nice :D Good work ^^
 
Eheheheheh

Cool script but one bug:

If someone names himself "Nahruto" or "Jano" then he'll get access to use it ..

Check it through IP instead :p
 
Eheheheheh

Cool script but one bug:

If someone names himself "Nahruto" or "Jano" then he'll get access to use it ..

Check it through IP instead :p

Use groups with other flags instead... And in all scripts you make dont use "if getPlayerGroupId " crap, instead use flags...


You could make custom flag to check if he can use these commands ^.-
 
omg!! i love this script dude please i have 1 error can u help?!

Code:
Error: [CreatureEvent::configureEvent] No valid type for creature event.look
Warning: [BaseEvents::loadFromXml] Can not configure event
i think is my login.lua? or my creaturescripts.xml
Code:
[COLOR=Red]<event type="look"[/COLOR] name="playerLook" script="look.lua"/> [COLOR=Blue]i think this is the error [/COLOR]
Code:
function onLogin(cid)
    registerCreatureEvent(cid, "PlayerDeath")
    registerCreatureEvent(cid, "playerLook") 
    return TRUE
end
awwww!! dont tell me it wont work for 8.1 !:(:(:(

it does not work with 8.1!:(:(?? dam i wanted this is very cool script
 
Last edited by a moderator:
nice :D how can i change "/lookmode teleport" for not teleporting to protection zone area, and when i go to a energy field i cant teleport(i mean when i have energy on my battle)... i want "/lookmode teleport" like that how can i change it? so it would be very cool like the movie "Jumper" :D xD

Code:
	if (getTilePzInfo(aPos) == TRUE and getPlayerSkullType(cid) > 0) then
		return tpError(cid, "You cannot teleport into a protection zone after attacking a player.")
	end
thats exactly what i want where i have to add this?

and forbid teleporting when energy on my battle xD sorry for my bad english
 
Last edited:
Tnx Nahruto:D! now it work if getTilePzInfo now i need help with this

Code:
        if Modo == 1 then
			if (getTilePzInfo(position)) == FALSE then
				doTeleportThing(cid, position, TRUE)
			else
[COLOR="Red"]			if getTileItemById(pos, 4608, 4609, 4610, 4611, 4612) == TRUE then
				doSendCancel(cid, "You cannot teleport into water.")[/COLOR]
			else
				doSendCancel(cid, "You cannot teleport into a protection zone.")
			end
		end

what is wrong i still teleporting to those water ids :s this is the error

[13/03/2009 15:09:24] Lua Script Error: [CreatureScript Interface]
[13/03/2009 15:09:24] data/creaturescripts/scripts/look.lua:eek:nLook

[13/03/2009 15:09:24] attempt to index a number value
[13/03/2009 15:09:24] stack traceback:
[13/03/2009 15:09:24] [C]: in function 'getTileItemById'
[13/03/2009 15:09:24] data/creaturescripts/scripts/look.lua:27: in function <data/creaturescripts/scripts/look.lua:18>
 
Last edited:
change
PHP:
if getTileItemById(pos, 4608, 4609, 4610, 4611, 4612) == TRUE then
to
PHP:
if getTileItemById(pos, {4608, 4609, 4610, 4611, 4612}) == TRUE then
 
still error
[13/03/2009 15:47:31] attempt to index a nil value
[13/03/2009 15:47:31] stack traceback:
[13/03/2009 15:47:31] [C]: in function 'getTileItemById'
[13/03/2009 15:47:31] data/creaturescripts/scripts/look.lua:27: in function <data/creaturescripts/scripts/look.lua:18>
 
lol sorry for bothering u but still the same error
[14/03/2009 05:53:37] attempt to index a function value
[14/03/2009 05:53:37] stack traceback:
[14/03/2009 05:53:37] [C]: in function 'getTileItemById'
[14/03/2009 05:53:37] data/creaturescripts/scripts/look.lua:27: in function <data/creaturescripts/scripts/look.lua:18>

Code:
[COLOR="Blue"]        if Modo == 1 then
			if (getTilePzInfo(position)) == FALSE then
				doTeleportThing(cid, position, TRUE)
			else
			if isInArray({4608, 4609, 4610, 4611, 4612},getTileItemById(pos)) == TRUE then
				doSendCancel(cid, "You cannot teleport into water.")
			else
				doSendCancel(cid, "You cannot teleport into a protection zone.")
			end
		end[/COLOR]
 
hi
I have question Never have I seen features onlook and I wanted to ask a question that looks like a script that looks as if the players look at each other if something happens
 
Back
Top