• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Please help me with this script [creatureScript]

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Why this script is not working? :S i've tried all and is not working

(Edited version of the Colandus' Script)

LUA:
function onDeath(cid, corpse, lasHitKiller, mostDamageKiller)

local values =
{
	["KILLERNAME"] = field item,
	["KILLERLEVEL"] = getPlayerLevel(lastHitKiller),
	["TARGETNAME"] = getCreatureName(cid),
	["TARGETLEVEL"] = getPlayerLevel(cid)
}

local index =
{
	rewardItem = 
	{
		enable = "yes",
		item = 5943,
		count = 1
	},
	killMessage =
	{
		enable = "yes",
		message = "formateString(You killed |TARGETNAME|, values)!.",
		messageType = MESSAGE_STATUS_CONSOLE_ORANGE
	},
	animationEffect =
	{
		enable = "yes",
		message = "Owned",
		messageColor = TEXTCOLOR_TEAL
	},
	broadcastMessage =
	{
		enable = "yes",
		message = "formateString(The player |TARGETNAME| was killed at level |TARGETLEVEL| by |KILLERNAME|, values)."
	},
	broadcastGM =
	{
		enable = "no",
		access = 4,
		messageType = MESSAGE_STATUS_CONSOLE_BLUE
	}
}

	if isCreature(lastHitKiller) then
		values =
		{
			["KILLERNAME"] = getCreatureName(lastHitKiller),
			["KILLERLEVEL"] = getPlayerLevel(lastHitKiller),
			["TARGETNAME"] = getCreatureName(cid),
			["TARGETLEVEL"] = getPlayerLevel(cid)
		}
		return TRUE
	end
		
	if(getBooleanFromString(index.rewardItem.enable) == TRUE) and isPlayer(lastHitKiller) then
		reward = doPlayerAddItem(lastHitKiller, index.rewardItem.item, index.rewardItem.count)
		setItemName(reward, formateString("hearth of |TARGETNAME|", values))
		doSetItemSpecialDescription(reward, formateString("Hearth of |TARGETNAME| that was killed at level |TARGETLEVEL| by |KILLERNAME|.", values))
		return TRUE
	else
		return TRUE
	end

	if(getBooleanFromString(index.killMessage.enable) == TRUE) and isPlayer(lastHitKiller) then
		doPlayerSendTextMessage(lastHitKiller, index.killMessage.message, index.killMessage.messageType)
		return TRUE
	else
		return TRUE
	end

	if(getBooleanFromString(index.animationEffect.enable) == TRUE) then
		doSendAnimatedText(getCreaturePosition(cid), index.animationEffect.message, index.animationEffect.messageColor)
		return TRUE
	else
		return TRUE
	end

	if(getBooleanFromString(index.broadcastMessage.enable) == TRUE) then
		if(getBooleanFromString(index.broadcastGM.enable) == TRUE) and getPlayerGroupId(lastHitKiller) >= 4 then
			doBroadcastMessage(index.broadcastGM.message, index.broadcastGM.messageType)
			return TRUE
		else
			doBroadcastMessage(index.broadcastMessage.message)
			return TRUE
		end
	else
		return TRUE
	end

	return TRUE
end

Of course, i've edited the function "formateString(str)" to this:
LUA:
function formateString(str, values)
	return(str:gsub("|([A-Z]+)|", (function(a) return values[a] end)))
end

No errors in console :S
 
Last edited:
Back
Top