• 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 Help with my code

Adiko

GetOnMyHorse
Joined
Apr 25, 2009
Messages
177
Reaction score
0
Location
Poland \ Wodzisław
Im getting errors with that code kill.lua
PHP:
function onKill(cid, target)
	local monster = getCreatureName(target)
	local room = getArenaMonsterIdByName(monster)
	if room > 0 then
		setPlayerStorageValue(cid, room, 1)
		doPlayerSendTextMessage(cid,MESSAGE_EVENT_DEFAULT,'You can enter next arena room!')
	end
	return TRUE
end
function onKill(cid, target)
if isPlayer(target) == TRUE then
---- BOUNTY HUNTERS START -----
pid = cid
pid2 = getPlayerGUID(target)
    local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..pid2.." AND `killed` = 0;")
    if(result_plr:getID() ~= -1) then
    prize = tonumber(result_plr:getDataInt("prize"))
    bid = tonumber(result_plr:getDataInt("id"))
	result_plr:free()
    else
    prize = 0
	bid = 0
    end

if (bid ~= 0 and prize ~= 0 and getTileInfo(getCreaturePosition(cid)).pvp ~= true) then
    db.executeQuery("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id`  = "..bid..";")
	doPlayerAddMoney(cid,prize*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!')
end	
---- BOUNTY HUNTERS END -----
end
return TRUE
end
dofile("./arena.lua")
dofile("./GuildWar.lua")
dofile("./bounty.lua")

local PZ = createConditionObject(CONDITION_INFIGHT)
setConditionParam(PZ, CONDITION_PARAM_TICKS, getConfigInfo('pzLocked'))

function onKill(cid, target)
	if isPlayer(cid) == TRUE and isPlayer(target) == TRUE then
		local myGuild = getPlayerGuildId(cid)
		local enemyGuild = getPlayerGuildId(target)
		if myGuild ~= 0 and enemyGuild ~= 0 then
			if enemyGuild == getGuildWarInfo(myGuild).With then
				removeFrag(cid)
				doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "This Frag will not count") --Remove this if you wish
				doAddCondition(cid, PZ)
				registerDeath(myGuild, enemyGuild, cid, target)
			end
		end
		local Target = getPlayerGUID(target)
		if IsHunted(Target) == TRUE then
			if isKilled(Target) == FALSE then
				doPlayerAddMoney(cid, GetReward(Target))
				doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Congratulations you received " .. GetReward(Target) .. " GPs for killing "..getCreatureName(target)..".")
				UpdateKiller(getPlayerGUID(target), getPlayerGUID(cid))
			end
		end
	end
	if getPlayerStorageValue(cid, isIN) == 1 then
		local Room = getArenaMonsterIdByName(getCreatureName(target))
		if Room ~= 0 then
			setPlayerStorageValue(cid, Room, 1)
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, Cancel[8])
		end
	end
	return TRUE
end

errors in console:
[08/05/2009 14:24:57] Lua Script Error: [CreatureScript Interface]
[08/05/2009 14:24:57] data/creaturescripts/scripts/kill.lua

[08/05/2009 14:24:57] cannot open ./arena.lua: No such file or directory
[08/05/2009 14:24:57] Warning: [Event::loadScript] Can not load script. data/creaturescripts/scripts/kill.lua
 
Try this one:

kill.lua
Code:
function onKill(cid, target)
if isPlayer(target) == TRUE then
---- BOUNTY HUNTERS START -----
pid = cid
pid2 = getPlayerGUID(target)
    local result_plr = db.getResult("SELECT * FROM `bounty_hunters` WHERE `sp_id` = "..pid2.." AND `killed` = 0;")
    if(result_plr:getID() ~= -1) then
    prize = tonumber(result_plr:getDataInt("prize"))
    bid = tonumber(result_plr:getDataInt("id"))
	result_plr:free()
    else
    prize = 0
	bid = 0
    end

if (bid ~= 0 and prize ~= 0 and getTileInfo(getCreaturePosition(cid)).pvp ~= true) then
    db.executeQuery("UPDATE `bounty_hunters` SET `killed` = 1, `k_id`="..getPlayerGUID(cid)..", `kill_time` = " .. os.time() .. " WHERE `id`  = "..bid..";")
	doPlayerAddMoney(cid,prize*1000)
	doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_BLUE,'[BOUNTY HUNTERS] You killed hunted player, so you gained the reward!')
end	
---- BOUNTY HUNTERS END -----
end
return TRUE
end
 
Back
Top