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

Lua rep++// OnKill error? :(

E

Evil Puncker

Guest
Well, can someone figure out what is wrong with this script? I'm using 0.4 and everytime that I kill any monster of the quest the server crash with no error at all :(

Lua:
local config = {	
	["carniphila"] = {storage = 9999, mob_storage = 19999, race_name = "carniphilas", begin_storage_value = 1, finished_storage_value = 2, count = 150},
	["crocodile"] = {storage = 9998, mob_storage = 19998, race_name = "crocodiles", begin_storage_value = 3, finished_storage_value = 4, count = 300},
	["tarantula"] = {storage = 9997, mob_storage = 19997, race_name = "tarantulas", begin_storage_value = 5, finished_storage_value = 6, count = 300},
	["stone golem"] = {storage = 9996, mob_storage = 19996, race_name = "stone golems", begin_storage_value = 7, finished_storage_value = 8, count = 200},
	["mammoth"] = {storage = 9995, mob_storage = 19995, race_name = "mammoths", begin_storage_value = 9, finished_storage_value = 10, count = 300},

	["ice golem"] = {storage = 9994, mob_storage = 19994, race_name = "ice golems", begin_storage_value = 11, finished_storage_value = 12, count = 300},

	["quara constrictor scout"] = {storage = 9993, mob_storage = 19993, race_name = "quara scouts", begin_storage_value = 26, finished_storage_value = 27, count = 300},
	["quara hydromancer scout"] = {storage = 9993, mob_storage = 19992, race_name = "quara scouts", begin_storage_value = 26, finished_storage_value = 27, count = 300},
	["quara mantassin scout"] = {storage = 9993, mob_storage = 19991, race_name = "quara scouts", begin_storage_value = 26, finished_storage_value = 27, count = 300},
	["quara pincher scout"] = {storage = 9993, mob_storage = 19990, race_name = "quara scouts", begin_storage_value = 26, finished_storage_value = 27, count = 300},
	["quara predator scout"] = {storage = 9993, mob_storage = 19989, race_name = "quara scouts", begin_storage_value = 26, finished_storage_value = 27, count = 300},
	
	["quara constrictor"] = {storage = 9992, mob_storage = 19988, race_name = "quaras", begin_storage_value = 24, finished_storage_value = 25, count = 300},
	["quara hydromancer"] = {storage = 9992, mob_storage = 19987, race_name = "quaras", begin_storage_value = 24, finished_storage_value = 25, count = 300},
	["quara mantassin"] = {storage = 9992, mob_storage = 19986, race_name = "quaras", begin_storage_value = 24, finished_storage_value = 25, count = 300},
	["quara pincher"] = {storage = 9992, mob_storage = 19985, race_name = "quaras", begin_storage_value = 24, finished_storage_value = 25, count = 300},
	["quara predator"] = {storage = 9992, mob_storage = 19984, race_name = "quaras", begin_storage_value = 24, finished_storage_value = 25, count = 300},

	["fire elemental"] = {storage = 9991, mob_storage = 19983, race_name = "fire elementals", begin_storage_value = 28, finished_storage_value = 29, count = 70},
	["massive fire elemental"] = {storage = 9991, mob_storage = 19982, race_name = "fire elementals", begin_storage_value = 28, finished_storage_value = 29, count = 70},

	["water elemental"] = {storage = 9990, mob_storage = 19981, race_name = "water elementals", begin_storage_value = 30, finished_storage_value = 31, count = 70},
	["massive water elemental"] = {storage = 9990, mob_storage = 19980, race_name = "water elementals", begin_storage_value = 30, finished_storage_value = 31, count = 70},

	["earth elemental"] = {storage = 9989, mob_storage = 19979, race_name = "earth elementals", begin_storage_value = 32, finished_storage_value = 33, count = 70},
	["massive earth elemental"] = {storage = 9989, mob_storage = 19978, race_name = "earth elementals", begin_storage_value = 32, finished_storage_value = 33, count = 70},

	["energy elemental"] = {storage = 9988, mob_storage = 19977, race_name = "energy elementals", begin_storage_value = 34, finished_storage_value = 35, count = 70},
	["massive energy elemental"] = {storage = 9988, mob_storage = 19976, race_name = "energy elementals", begin_storage_value = 34, finished_storage_value = 35, count = 70},
	
	["mutated rat"] = {storage = 9987, mob_storage = 19975, race_name = "mutated rats", begin_storage_value = 13, finished_storage_value = 14, count = 200},
	["giant spider"] = {storage = 9986, mob_storage = 19974, race_name = "giant spiders", begin_storage_value = 15, finished_storage_value = 16, count = 500},

	["hydra"] = {storage = 9985, mob_storage = 19973, race_name = "hydras", begin_storage_value = 17, finished_storage_value = 18, count = 2000},
	["sea serpent"] = {storage = 9984, mob_storage = 19972, race_name = "sea serpents", begin_storage_value = 19, finished_storage_value = 20, count = 2000},
	["behemoth"] = {storage = 9983, mob_storage = 19971, race_name = "behemoths", begin_storage_value = 21, finished_storage_value = 22, count = 2000},
	["serpent spawn"] = {storage = 9982, mob_storage = 19970, race_name = "serpent spawns", begin_storage_value = 23, finished_storage_value = 24, count = 1500},

	["demon"] = {boss = "no", begin_storage_main_value = 36, finished_storage_main_value = 37, special_storage = 10007, storage = 9981, begin_special_task_boss_storage_value = 0, finished_special_task_boss_storage_value = 1, count = 6666},
	
	--bosses
	["demodras"] = {boss = "yes", special_storage = 10005, begin_special_task_boss_storage_value = 0, finished_special_task_boss_storage_value = 1},
	["tiquandas revenge"] = {boss = "yes", special_storage = 10006, begin_special_task_boss_storage_value = 0, finished_special_task_boss_storage_value = 1},
	
	["the snapper"] = {storage = 9998, begin_boss_storage_value = 1, finished_boss_storage_value = 2},
	["hide"] = {storage = 9997, begin_boss_storage_value = 3, finished_boss_storage_value = 4},
	["the bloodtusk"] = {storage = 9995, begin_boss_storage_value = 5, finished_boss_storage_value = 6},
	["shardhead"] = {storage = 9994, begin_boss_storage_value = 7, finished_boss_storage_value = 8},
	["esmeralda"] = {storage = 9987, begin_boss_storage_value = 9, finished_boss_storage_value = 10},
	["the old widow"] = {storage = 9986, begin_boss_storage_value = 11, finished_boss_storage_value = 12},
	["the many"] = {storage = 9985, begin_boss_storage_value = 13, finished_boss_storage_value = 14},
	["leviathan"] = {storage = 9984, begin_boss_storage_value = 15, finished_boss_storage_value = 16},
	["stonecracker"] = {storage = 9983, begin_boss_storage_value = 17, finished_boss_storage_value = 18},
	["the noxious spawn"] = {storage = 9982, begin_boss_storage_value = 19, finished_boss_storage_value = 20},
	["thul"] = {storage = 9992, begin_boss_storage_value = 21, finished_boss_storage_value = 22}
	}
local points = 10002
local main_storage = 10001
local bosses_storage = 10003

function onKill(cid, target)
local mob = config[string.lower(getCreatureName(target))]
if not(mob and isPlayer(target) ~= true) then
	return true
end
local killedMonsters = getPlayerStorageValue(cid, mob.storage)
local mob_storages = getPlayerStorageValue(cid, mob.mob_storage)
local totalpoints = getPlayerStorageValue(cid, points)
if(totalpoints == -1) then
	totalpoints = 0
end
	for k, v in pairs(config) do
		if getPlayerStorageValue(cid, main_storage) == v.begin_storage_value then
			counts = getPlayerStorageValue(cid, v.mob_storage)
			if counts < 0 then
				counts = 0
			end
		end
	end
	for k, v in pairs(config) do
		if getPlayerStorageValue(cid, v.mob_storage) == -1 then
			if getPlayerStorageValue(cid, main_storage) == v.begin_storage_value then
				doPlayerSetStorageValue(cid, v.mob_storage, 0)
			end
		end
	end
if getPlayerStorageValue(cid, main_storage) == mob.begin_storage_value and counts <= mob.count then
	doPlayerSetStorageValue(cid, mob.mob_storage, getPlayerStorageValue(cid, mob.mob_storage) + 1)
		x = 0
		s = "You killed "
		for k, v in pairs(config) do
			if getPlayerStorageValue(cid, main_storage) == v.begin_storage_value then
				if s ~= "You killed " then
					s = s .. " "
				end
				count = getPlayerStorageValue(cid, v.mob_storage)
				if count < 0 then
					count = 0
				end
				s = s ..count.." " .. k .. ","
				x = x + count
			end
		end
		s = string.sub(s, 1, string.len(s) - 1)..". You have killed " .. x .." of ".. mob.count .." "..mob.race_name.."."
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, s)
		if x == mob.count then 
			doPlayerSetStorageValue(cid, mob.storage, 1)
			doPlayerSetStorageValue(cid, main_storage, mob.finished_storage_value)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You have killed enough "..mob.race_name..".")
				if totalpoints < 50 then
					if mob.count < 1500 then
						doPlayerSetStorageValue(cid, points, totalpoints + 1)
						doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "Your total points is "..getPlayerStorageValue(cid, points)..".")	
					else
						doPlayerSetStorageValue(cid, points, totalpoints + 3)
						doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "Your total points is "..getPlayerStorageValue(cid, points)..".")	
					end
				end
			for k, v in pairs(config) do
				if x == mob.count then
					if getPlayerStorageValue(cid, main_storage) == v.finished_storage_value then
						if getPlayerStorageValue(cid, v.mob_storage) >= 0 and getPlayerStorageValue(cid, v.storage) >= 0 then
							doPlayerSetStorageValue(cid, v.mob_storage, -1)
						end
					end
				end
			end
			return true
		end
elseif getPlayerStorageValue(cid, bosses_storage) == mob.begin_boss_storage_value and killedMonsters == 2 then
	doPlayerSetStorageValue(cid, bosses_storage, mob.finished_boss_storage_value)
	doPlayerSetStorageValue(cid, mob.storage, 3)
	doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You have killed "..getCreatureName(target)..".")
	if totalpoints < 50 then
		doPlayerSetStorageValue(cid, points, totalpoints + 1)
		doPlayerSendTextMessage(cid, TALKTYPE_ORANGE_1, "Your total points is "..getPlayerStorageValue(cid, points)..".")	
	end
elseif getPlayerStorageValue(cid, mob.special_storage) == mob.begin_special_task_boss_storage_value then
	if mob.boss == "no" then
		if killedMonsters <= mob.count and getPlayerStorageValue(cid, main_storage) == mob.begin_storage_main_value then
			doPlayerSetStorageValue(cid, mob.storage, killedMonsters + 1)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have killed "..getPlayerStorageValue(cid, mob.storage).." of "..mob.count.." "..getCreatureName(target)..".")
			if getPlayerStorageValue(cid, mob.storage) == mob.count then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You have killed enough "..getCreatureName(target)..".")
				doPlayerSetStorageValue(cid, mob.special_storage, mob.finished_special_task_boss_storage_value)
				doPlayerSetStorageValue(cid, storages.main_storage, mob.finished_storage_main_value)
			end
		end
	elseif mob.boss == "yes" then
		if isInArray({-1,0}, killedMonsters) then
			doPlayerSetStorageValue(cid, mob.special_storage, mob.finished_special_task_boss_storage_value)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Congratulations! You have killed "..getCreatureName(target)..".")
		end
	end	
end
return true
end
 
Back
Top