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

Solved onLook function

Materion

New Member
Joined
Feb 18, 2012
Messages
81
Reaction score
2
Hello It's again me ! I have question about onLook function in tfs. I wrote such script
Lua:
function onLook(cid, item, position, distance) 
	if(item.itemid == 2456) then
		local shootrange = getItemAttribute(item.uid, shootRange) 
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Bow range: "..shootrange)
	end
	return true
end

But when I'm looking on bow in game it don't write doPlayerSendTextMessage in default window :<. Why ? When i change onLook function to onUse function it works very well ...
 
Where i have to register it ? I just registered it in actions.xml
<action itemid="2456" event="script" value="custom/test.lua"/>
 
Nah, you need to put it into creaturescripts.xml as onLook event.

Like this:
Code:
<event type="look" name="Blabla" event="script" value="yourscript.lua"/>
 
Ok i had to register it in Login.lua script -
Lua:
registerCreatureEvent(cid, "test")

But now when I try to look on that bow i got an error in server console -
MbdJqtp.png


script look like this:
Lua:
function onLook(cid, item, position, distance) 
	if(item.itemid == 2456) then
		local shootrange = getItemAttribute(item.uid, shootRange) 
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Bow range: "..shootrange)
	end
	return true
end

When i used it with onUse function in actions it worked good, but now when i changed it onLook function and registered it in creaturescripts it shows that error in server console above.
 
Last edited:
shootRange is no valid parameter, check what the correct on is.
Probably something like "shootrange" or "shootRange"
 
Ok thank you ! It worked with
Lua:
 local shootrange = getItemAttribute(item.uid, shootrange)

Im very thankful for your help and support, without you I couldn't go so fast forward with scripting :).
 
Last edited:
Back
Top