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

Solved kill monster, get storage value, open door

jesseripper

New Member
Joined
Mar 12, 2008
Messages
20
Reaction score
1
Hi everyone, I have tried to use the search function but I havn't succeeded. I'm currently working on a project, and I'm pretty new to OT's, not a beginner, but still.

Is it possible for example to do like this,

I have around 5 quest doors in a house, each one requires a unique storage value. For example, one door requires 1001 to open, another 1002 and the third 1003 and so on.

I have also 5 different minibosses in the house, what I want to do is, when I for example kill the first boss, I get storage value of 1001, so I can open the first door. When I kill the second boss I get storage value 1002 so I can open the second door, etc.

Is this possible?

Thank you!
 
LUA:
function onKill(cid, target)

local config = {
	["bossone"] = {amount = 1, storage = 32000, doorstorage = 1001},
	["bosstwo"] = {amount = 1, storage = 32001, doorstorage = 1002},
	["bosstree"] = {amount = 1, storage = 32002, doorstorage = 1003},
	["bossfour"] = {amount = 1, storage = 32003, doorstorage = 1004},
	["bossfive"] = {amount = 1, storage = 32004, doorstorage = 1005}
}

local monster = config[getCreatureName(target):lower()]

	if(isPlayer(target)) or not monster then
		return true
	end

	if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage) +1) < monster.amount then		
		setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
	end
	if (getPlayerStorageValue(cid, monster.storage) +1) == monster.amount then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you have killed "..getCreatureName(target).."s and can now pass to the next door.")
		setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
		setPlayerStorageValue(cid, monster.doorstorage, 1)
	end
	return true
end
 
LUA:
function onKill(cid, target)

local config = {
	["bossone"] = {amount = 1, storage = 32000, doorstorage = 1001},
	["bosstwo"] = {amount = 1, storage = 32001, doorstorage = 1002},
	["bosstree"] = {amount = 1, storage = 32002, doorstorage = 1003},
	["bossfour"] = {amount = 1, storage = 32003, doorstorage = 1004},
	["bossfive"] = {amount = 1, storage = 32004, doorstorage = 1005}
}

local monster = config[getCreatureName(target):lower()]

	if(isPlayer(target)) or not monster then
		return true
	end

	if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage) +1) < monster.amount then		
		setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
	end
	if (getPlayerStorageValue(cid, monster.storage) +1) == monster.amount then
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you have killed "..getCreatureName(target).."s and can now pass to the next door.")
		setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
		setPlayerStorageValue(cid, monster.doorstorage, 1)
	end
	return true
end

I have a little question about that... If you kill the Boss in party the only one who is gonna get the storage is the last hitter?
Thanks in advance :)
 
Ive would recommend to use function ondeath, then you can check more than last hit :D
 
I have a little question about that... If you kill the Boss in party the only one who is gonna get the storage is the last hitter?
Thanks in advance :)
Yes, the last hitter gets the storage/message.
Ive would recommend to use function ondeath, then you can check more than last hit :D
Ye, your right, didn't really thought of the bosses would probable be killed in team :p
@Limos,

You should put the config outside of the function when possible. Good work, though. ;)
True, really old script I made long time ago, just made some quick edits.
Thanks for reminding.
 
So this is what I did,

I went to data/Actions/scripts/quests and pasted the lua.script you gave me.

function onKill(cid, target)

local config = {
["Thing"] = {amount = 1, storage = 32000, doorstorage = 1500},
["bosstwo"] = {amount = 1, storage = 32001, doorstorage = 1002},
["bosstree"] = {amount = 1, storage = 32002, doorstorage = 1003},
["bossfour"] = {amount = 1, storage = 32003, doorstorage = 1004},
["bossfive"] = {amount = 1, storage = 32004, doorstorage = 1005}
}

local monster = config[getCreatureName(target):lower()]

if(isPlayer(target)) or not monster then
return true
end

if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage) +1) < monster.amount then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
end
if (getPlayerStorageValue(cid, monster.storage) +1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you have killed "..getCreatureName(target).."s and can now pass to the next door.")
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
setPlayerStorageValue(cid, monster.doorstorage, 1)
end
return true
end




There's my monster, "Thing". So I kill the thing, but nothing happens. I have set the action ID on the door to 1500 aswell. and yeah, in data/actions.xml I put

<action uniqueid="1500" event="script" value="quests/addams.lua"/>

Nothing works. And I recieve this message:

http://3.ii.gl/OeDEzU.png

Any tips?
 
It should be in creaturescripts.
XML:
<event type="kill" name="Bosskill" event="script" value="addams.lua"/>
You also have to register the name in login.lua.
LUA:
registerCreatureEvent(cid, "Bosskill")

You can choose the name and the lua file name.
 
It should be in creaturescripts.
XML:
<event type="kill" name="Bosskill" event="script" value="addams.lua"/>
You also have to register the name in login.lua.
LUA:
registerCreatureEvent(cid, "Bosskill")

You can choose the name and the lua file name.


Sorry for beeing a retard, I don't understand. I opened creaturescripts, imported the XML code.

Then I opened login.lua and imported that in the bottom of the page.

Recieves this message:

http://4.ii.gl/MCH04y.png
 
Wut?

Go into creaturescripts/scripts and open login.lua and copy everything inside it and post it here on otland with tags:

LUA:
Tags
 
Code:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		addEvent(valid(doCreatureSay), 500, cid, "Hello, it appears that your character has been locked for name violating rules, what new name would you like to have?", TALKTYPE_PRIVATE_NP, true, cid)
	elseif(accountManager == MANAGER_ACCOUNT) then
		addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to manage your account. If you would like to start over, type {cancel} anywhere.", TALKTYPE_PRIVATE_NP, true, cid)
	else
		addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to create an account or {recover} to recover an account.", TALKTYPE_PRIVATE_NP, true, cid)
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end

	registerCreatureEvent(cid, "Idle")
	registerCreatureEvent(cid, "Mail")
	if(getPlayerOperatingSystem(cid) >= CLIENTOS_OTCLIENT_LINUX) then
		registerCreatureEvent(cid, "ExtendedOpcode")
	end

	registerCreatureEvent(cid, "ReportBug")
	if(config.useFragHandler) then
		registerCreatureEvent(cid, "SkullCheck")
	end

	registerCreatureEvent(cid, "GuildEvents")
	registerCreatureEvent(cid, "AdvanceSave")
	return true
	end
	
	registerCreatureEvent(cid, "Bosskill")
	end

thats how it looks
 
Enjoy:
LUA:
local config = {
	loginMessage = getConfigValue('loginMessage'),
	useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
	local loss = getConfigValue('deathLostPercent')
	if(loss ~= nil) then
		doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
	end

	local accountManager = getPlayerAccountManager(cid)
	if(accountManager == MANAGER_NONE) then
		local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
		if(lastLogin > 0) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
			str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
		else
			str = str .. " Please choose your outfit."
			doPlayerSendOutfitWindow(cid)
		end

		doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
	elseif(accountManager == MANAGER_NAMELOCK) then
		addEvent(valid(doCreatureSay), 500, cid, "Hello, it appears that your character has been locked for name violating rules, what new name would you like to have?", TALKTYPE_PRIVATE_NP, true, cid)
	elseif(accountManager == MANAGER_ACCOUNT) then
		addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to manage your account. If you would like to start over, type {cancel} anywhere.", TALKTYPE_PRIVATE_NP, true, cid)
	else
		addEvent(valid(doCreatureSay), 500, cid, "Hello, type {account} to create an account or {recover} to recover an account.", TALKTYPE_PRIVATE_NP, true, cid)
	end

	if(not isPlayerGhost(cid)) then
		doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
	end

	registerCreatureEvent(cid, "Idle")
	registerCreatureEvent(cid, "Mail")
	if(getPlayerOperatingSystem(cid) >= CLIENTOS_OTCLIENT_LINUX) then
		registerCreatureEvent(cid, "ExtendedOpcode")
	end

	registerCreatureEvent(cid, "ReportBug")
	if(config.useFragHandler) then
		registerCreatureEvent(cid, "SkullCheck")
	end

	registerCreatureEvent(cid, "GuildEvents")
	registerCreatureEvent(cid, "AdvanceSave")
	
	registerCreatureEvent(cid, "Bosskill")
	return true
end
 
thanks. i fucking suck, won't get it working.

added <event type="kill" name="Bosskill" event="script" value="addams.lua"/> to creaturescripts.xml

added the thing you posted to login.lua


added a lua file addams.lua containing
function onKill(cid, target)

local config = {
["Thing"] = {amount = 1, storage = 32000, doorstorage = 1500},
["bosstwo"] = {amount = 1, storage = 32001, doorstorage = 1002},
["bosstree"] = {amount = 1, storage = 32002, doorstorage = 1003},
["bossfour"] = {amount = 1, storage = 32003, doorstorage = 1004},
["bossfive"] = {amount = 1, storage = 32004, doorstorage = 1005}
}

local monster = config[getCreatureName(target):lower()]

if(isPlayer(target)) or not monster then
return true
end

if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage) +1) < monster.amount then
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
end
if (getPlayerStorageValue(cid, monster.storage) +1) == monster.amount then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Congratulations, you have killed "..getCreatureName(target).."s and can now pass to the next door.")
setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) +1)
setPlayerStorageValue(cid, monster.doorstorage, 1)
end
return true
end
 
Back
Top