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

Count Kill Problem

Liikuid

Spin Machine!
Joined
Jul 17, 2010
Messages
257
Reaction score
24
Location
Iquique, Chile
Thiis is the script

PHP:
local monsters = {
	--name = storage
	["rat"] = 35001,
	["troll"] = 35002,
	["rotworm"] = 35003,
	["dragon"] = 35004,
	["dragon lord"] = 35005,
	["demon"] = 35006,
}

function onKill(cid, target)
	if(isPlayer(target) ~= TRUE) then
		local master = getCreatureMaster(target)
		if(master and master ~= target) then return FALSE end

		local name = getCreatureName(target)
		local monster = monsters[string.lower(name)]
		if(monster) then
			local killedMonsters = getPlayerStorageValue(cid, monster)
			if(killedMonsters == -1) then
				killedMonsters = 1
			end
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")
			setPlayerStorageValue(cid, monster, killedMonsters + 1)
		end
	end
	return TRUE
end

it works almost fine, but the summons doesnt die

thx
 
Last edited:
this line makes no sense:
Code:
if(master and master ~= target) then return FALSE end
why not just
Code:
if master ~= target then return FALSE end

also:
Code:
        local monster = monsters[string.lower(name)]
        if(monster) then
if monster = what? shouldn't it be (excuse the rushed coding which is probably wrong) isinarray(monster,getcreaturname(target)) = TRUE then etc?
 
Lua:
local monsters = {
    --name = storage
    ["rat"] = 35001,
    ["troll"] = 35002,
    ["rotworm"] = 35003,
    ["dragon"] = 35004,
    ["dragon lord"] = 35005,
    ["demon"] = 35006,
}

function onKill(cid, target)
    if(isMonster(target)) then
        local master = getCreatureMaster(target)
        if(master and master ~= target) then return true end

        local name = getCreatureName(target)
        local monster = monsters[string.lower(name)]
        if(monster) then
            local killedMonsters = getPlayerStorageValue(cid, monster)
            if(killedMonsters == -1) then
                killedMonsters = 1
            end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You killed " .. killedMonsters .. " " .. name .. "'s.")
            setPlayerStorageValue(cid, monster, killedMonsters + 1)
        end
    end
    return true
end
 
this line makes no sense:
Code:
if(master and master ~= target) then return FALSE end
why not just
Code:
if master ~= target then return FALSE end
For 0.4 compatibility.
In 0.4, getCreatureMaster returns nil if the creature isn't a summon, and "if(master)" checks if master isn't nil or false.
also:
Code:
        local monster = monsters[string.lower(name)]
        if(monster) then
if monster = what? shouldn't it be (excuse the rushed coding which is probably wrong) isinarray(monster,getcreaturname(target)) = TRUE then etc?
As I said above, it checks if monster (table value) isn't nil, if it has been found in the table.
 
Back
Top