• 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 Issues with lua code.

Tech_Rob

New Member
Joined
Oct 10, 2007
Messages
100
Reaction score
1
Problem has been solved by Cykotitan. Thanks.

Greetings Otlanders! I have helped several in the past with some lua codes, but now I ask for yours. Here is the issue I am having.
I am trying to get an action id set to a scroll, it seems if I use onKill command, the creature dies and stands still with 0 hp, and no body.

Now if I use the onDeath command, I end up getting the creature to die and no body is left at all. I did see a script somewhere with keys dropping from monsters, so I tried that as well with no luck.
I have the event registered in the login.lua, and I have the event added to the monster that is suppose to drop it. Any ideas?

I am using TFS Crying Damson .3.6pl1

Code:
local scroll = 1949

function onKill(cid, target, lastHit)
if isMonster(cid) then

if(1 == math.random(1, 4)) then
 doPlayerAddItem(uid, scroll)
doSetItemActionId(uid, 12000)
 return true
elseif(2 == math.random(1, 4)) then
 doPlayerAddItem(uid, scroll)
doSetItemActionId(uid, 12002)
 return true
elseif(3 == math.random(1, 4)) then
 doPlayerAddItem(uid, scroll)
doSetItemActionId(uid, 12003)
 return true
elseif(4 == math.random(1, 4)) then
 doPlayerAddItem(uid, scroll)
doSetItemActionId(uid, 12004)
 return true
 
end
 end
 return false
 end
 
Last edited:
Code:
local scroll = 1949

function onKill(cid, target, lastHit)
	if isMonster(cid) then
		doItemSetAttribute(doPlayerAddItem(cid, scroll, 1), "aid", 12000 + math.random(4))
	end
	return true
end
 
Thanks for your response, I will give this one a shot and see what happens.

Edit: Tested with no luck. Does not give errors, but does not give them requested item either. Going to play around with the script a little bit more, if any suggestions they are greatly appreciated. I will post if I find a solution.

Edit2: After playing around with the script some more, I noticed TFS 3.6pl1 does not have doItemSetAttribute in the funtions. Atleast not listed in the doc. So I will be looking for another way to add it.
 
Last edited:
So I have tried other ways including onKill, and onPrepareDeath with no luck. Seems even with the script given if I remove the add actionid line, I still do not receive the scroll.
 
Edit2: After playing around with the script some more, I noticed TFS 3.6pl1 does not have doItemSetAttribute in the funtions. Atleast not listed in the doc. So I will be looking for another way to add it.
It does, but the Docs weren't updated.

ONT, we were checking if the killer (cid) is the monster (instead of checking the target) - and onKill/onDeath are not executed for monsters unless registered in their scriptfile.

Code:
local scroll = 1949

function onKill(cid, target, lastHit)
	if isMonster([B][COLOR="Red"]target[/COLOR][/B]) then
		doItemSetAttribute(doPlayerAddItem(cid, scroll, 1), "aid", 12000 + math.random(4))
	end
	return true
end
 
Back
Top