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

onKill help.

Ninja Bodil

New Member
Joined
Mar 7, 2009
Messages
116
Reaction score
0
So this script should give a storage value when you kill a monster, but nothing happens.
I've put the name of the event in login.lua but nothing. And I get no errors.

PHP:
function onKill(cid, target, lastHit)
    if getCreatureName(target) == "Test Monster" then
    if isPlayer(target) then return true end
		if getCreatureStorage(cid, 6501) > 0 then
			if getCreatureStorage(cid, 6501) < 50 then
			    if getCreatureStorage(cid, 6501) < 0 then
					doCreatureSetStorage(cid, 6501, 0)
				end
	            doCreatureSetStorage(cid, 6501, getCreatureStorage(cid, 6501) + 1)
	            doSendAnimatedText(cid, getCreatureStorage(cid, 6501), 255)
			end	
	    end
	end
	return true
end
 
if getCreatureStorage(cid, 6501) > 0 then -- higher then 0
if getCreatureStorage(cid, 6501) < 50 then -- lower then 50
if getCreatureStorage(cid, 6501) < 0 then -- lower then 0?!!? how can it be lower then zero if you checked 2 line over that it's higher then 0

try debug:
PHP:
function onKill(cid, target, lastHit) 
print('1' .. getCreatureName(target)
    if getCreatureName(target) == "Test Monster" then 
print('2 name valid')
    if isPlayer(target) then print('3 fail! is player') return true end 
print('3 all ok, add count')
           doCreatureSetStorage(cid, 6501, math.max(0, getCreatureStorage(cid, 6501)) + 1) 
           doSendAnimatedText(cid, getCreatureStorage(cid, 6501), 255) 
    end 
print('4 finish')
    return true 
end
It will show in console of server what script execute and what not.
I removed check how many is killed, because I don't see any reason why it should limit it to 50.
math.max(0, getCreatureStorage(cid, 6501)) - function 'max' will return 0 when storage will be lower then 0
 
Back
Top