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

Script Problem.. Quest Box

Teddy

SweStream.se
Joined
Oct 2, 2008
Messages
3,797
Reaction score
10
Location
Sweden 172
All my quest i have from 0.3.6 are look like this
LUA:
function onUse(cid, item, frompos, item2, topos)

	if item.uid == 51001 then
		if getPlayerStorageValue(cid,51001) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Chain Armor.")
			doPlayerAddItem(cid,2464,1)
			setPlayerStorageValue(cid,51001,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end

	elseif item.uid == 51002 then
		if getPlayerStorageValue(cid,51002) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found 2 Crystal Coin.")
			doPlayerAddItem(cid,2160,2)
			setPlayerStorageValue(cid,51002,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		
			elseif item.uid == 51003 then
		if getPlayerStorageValue(cid,51003) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Rope.")
			doPlayerAddItem(cid,2120,1)
			setPlayerStorageValue(cid,51003,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		
			elseif item.uid == 51004 then
		if getPlayerStorageValue(cid,51004) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Shovel.")
			doPlayerAddItem(cid, MESSAGE_INFO_DESCR54,1)
			setPlayerStorageValue(cid,51004,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		
			elseif item.uid == 51005 then
		if getPlayerStorageValue(cid,51005) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Backpack.")
			doPlayerAddItem(cid,1988,1)
			setPlayerStorageValue(cid,51005,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
					elseif item.uid == 51006 then
		if getPlayerStorageValue(cid,51006) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Mage Hat.")
			doPlayerAddItem(cid,8820,1)
			setPlayerStorageValue(cid,51006,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
					elseif item.uid == 51007 then
		if getPlayerStorageValue(cid,51007) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Mage Armor.")
			doPlayerAddItem(cid,8819,1)
			setPlayerStorageValue(cid,51007,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		
							elseif item.uid == 51008 then
		if getPlayerStorageValue(cid,51008) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Boots.")
			doPlayerAddItem(cid,2643,1)
			setPlayerStorageValue(cid,51008,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		
						elseif item.uid == 51009 then
		if getPlayerStorageValue(cid,51009) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Spellbook.")
			doPlayerAddItem(cid,2175,1)
			setPlayerStorageValue(cid,51009,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		
						elseif item.uid == 51010 then
		if getPlayerStorageValue(cid,51010) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Spike Sword.")
			doPlayerAddItem(cid,2383,1)
			setPlayerStorageValue(cid,51010,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		
								elseif item.uid == 51011 then
		if getPlayerStorageValue(cid,51011) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Dwarven Shield.")
			doPlayerAddItem(cid, MESSAGE_INFO_DESCR MESSAGE_INFO_DESCR,1)
			setPlayerStorageValue(cid,51011,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
										elseif item.uid == 51012 then
		if getPlayerStorageValue(cid,51012) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Rod.")
			doPlayerAddItem(cid,2182,1)
			setPlayerStorageValue(cid,51012,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
										elseif item.uid == 51013 then
		if getPlayerStorageValue(cid,51013) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Wand.")
			doPlayerAddItem(cid,2190,1)
			setPlayerStorageValue(cid,51013,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
												elseif item.uid == 51014 then
		if getPlayerStorageValue(cid,51014) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Spear.")
			doPlayerAddItem(cid,2389,1)
			setPlayerStorageValue(cid,51014,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		elseif item.uid == 51015 then
				if getPlayerStorageValue(cid,51015) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Aol.")
			doPlayerAddItem(cid,2173,1)
			setPlayerStorageValue(cid,51015,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
		elseif item.uid == 51016 then
			if getPlayerStorageValue(cid,51016) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Chain Legs.")
			doPlayerAddItem(cid,2468,1)
			setPlayerStorageValue(cid,51016,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
				elseif item.uid == 51017 then
			if getPlayerStorageValue(cid,51017) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Health Potion.")
			doPlayerAddItem(cid,7618,1)
			setPlayerStorageValue(cid,51017,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
						elseif item.uid == 51018 then
			if getPlayerStorageValue(cid,51018) == -1 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You have found a Leather Helmet.")
			doPlayerAddItem(cid,2461,1)
			setPlayerStorageValue(cid,51018,1)
		else
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"The is empty.")
		end
								elseif item.uid == 51019 then
			if getPlayerStorageValue(cid,51019) == -1 then
			doPlayerSendTextMessage(cid,19,"You have found a First Mount.")
			doPlayerAddItem(cid,11246,1)
			setPlayerStorageValue(cid,51019,1)
		else
			doPlayerSendTextMessage(cid,TALKTYPE_ORANGE_1,"The is empty.")
		end
	
	
	end
	return TRUE
end
But they dont work anymore in last rev drom 0.4 ? .. how can i do so its work for 0.4... its very much quests so i cant edit ;/
 
Last edited:
Oh wait there's not a bracket missing, my bad, but there still is the letter missing.

You

Code:
if(type([B][COLOR="red"]questItem[/COLOR][/B].item)=="string")then

Should be


Code:
if(type([B][COLOR="green"]questItems[/COLOR][/B].item)=="string")then

And you can compare my C++ writing skill to the ability to write English for a Brazilian, really bad, however a Brazilian can read English and I can read C++ partialy, get it now?

1st.
A thing lies in "reading", "writting", "understanding", and "misunderstanding". Brazilian guy may think that he knows english and tries to write in it. But result may come with full/partialy fail. You can't do the same in c++. Or u are able to code in c++ or u can't. There 's no saying like "i can write in c++ partialy"

2nd
There's no a mistake with a letter since "questItems" is a table with whole quest things and uid ties to that, and "questItem" is a content of single row of "questItems" table, related to current item.uid. Thats why this guy posted:
Eh..
LUA:
questItem = questItems[item.uid];

Code:
local defaultMsg = MESSAGE_INFO_DESCR;
local defaultEmptyText = "It's empty.";
 
local questItems = {
	[51001] = {item = 2461, count = 1, text = "You have found a Chain Armor.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51002] = {item = 2160, count = 2, text = "You have found 2 Crystal Coin.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51003] = {item = 2120, count = 1, text = "You have found a Rope.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51004] = {item = "Put here id of shovel instead of this msg.", count = 1, text = "You have found a Shovel.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51005] = {item = 1988, count = 1, text = "You have found a Backpack.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51006] = {item = 8820, count = 1, text = "You have found a Mage Hat.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51007] = {item = 8819, count = 1, text = "You have found a Mage Armor.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51008] = {item = 2643, count = 1, text = "You have found a Boots.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51009] = {item = 2175, count = 1, text = "You have found a Spellbook.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51010] = {item = 2383, count = 1, text = "You have found a Spike Sword.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51011] = {item = "Put here id of Dwarven shield instead of this msg.", count = 1, text = "You have found a Dwarven Shield.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51012] = {item = 2182, count = 1, text = "You have found a Rod.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51013] = {item = 2190, count = 1, text = "You have found a Wand.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51014] = {item = 2389, count = 1, text = "You have found a Spear.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51015] = {item = 2173, count = 1, text = "You have found a Aol.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51016] = {item = 2468, count = 1, text = "You have found a Chain Legs.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51017] = {item = 7618, count = 1, text = "You have found a Health Potion.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51018] = {item = "Put here id of Leather Helmet instead of this msg.", count = 1, text = "You have found a Leather Helmet.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg},
	[51019] = {item = 11246, count = 1, text = "You have found a First Mount.", msg_type = defaultMsg, emptyText = defaultEmptyText, emptyType = defaultMsg}
}
function onUse(cid, item, frompos, item2, topos)
	if(not questItems[item.uid])then
		return;
	end
	[COLOR="red"]questItem = questItems[item.uid];[/COLOR]
	if(type(questItem.item)=="string")then
		print("Error while using a quest system script. UID = ".. item.uid .. ". Error msg: ".. questItem.item);
		return;
	end
	if(getCreatureStorage(cid,item.uid) > 0)then
		doPlayerSendTextMessage(cid, questItem.emptyType, questItem.defaultEmptyText)
	else
		doPlayerSendTextMessage(cid, questItem.msg_type, questItem.text)
		doPlayerAddItem(cid, questItem.item, questItem.count);
		doCreatureSetStorage(cid, item.uid, 1);
	end
	return TRUE
end
 
Lol now I get it about the error part, not really 100% using my brain right now, lol, but still you keep on using 'return;', make it atleast return true or false? lol.

And I'm not saying I can write C++, since I simply can't, I'm saying I can read it, which differs very much if you'd use your intelligence.
 
Well, as u said u're one not thinking right now.


'return' makes current function to finish. in lua 'return' don't have to get a value to return to. Since i know a bit tfs sources and how does action works, most of script doesn;t need to return any statement. true means a script successed, false means it failed and send msg, u cannot use it. simply 'return' without returning value just stop executing a function.

Litte trick for u. U can leave action script without 'return' statement at all. If you do one and there's more action script tied with this item it'll be exected either till, getting "return" in one of action scripts, or till the ond of checking if action script exist for this item.

First checked UID, then AID, then ID (there was one thing more. i forgot this). So if you set AID, UID to item, and then tie Script to UID and AID. the one tied with UID will execute first and if there's no return statement, AID will execute either. [and then ID if AID script doesn't; has return statement, and exist a script tied with that ID].

Btw. i don't need a babysitter to defend me. no offense ;)
 
Well, as u said u're one not thinking right now.


'return' makes current function to finish. in lua 'return' don't have to get a value to return to. Since i know a bit tfs sources and how does action works, most of script doesn;t need to return any statement. true means a script successed, false means it failed and send msg, u cannot use it. simply 'return' without returning value just stop executing a function.

Litte trick for u. U can leave action script without 'return' statement at all. If you do one and there's more action script tied with this item it'll be exected either till, getting "return" in one of action scripts, or till the ond of checking if action script exist for this item.

First checked UID, then AID, then ID (there was one thing more. i forgot this). So if you set AID, UID to item, and then tie Script to UID and AID. the one tied with UID will execute first and if there's no return statement, AID will execute either. [and then ID if AID script doesn't; has return statement, and exist a script tied with that ID].

Btw. i don't need a babysitter to defend me. no offense ;)

Lol, I'll read this tomorrow when I'm sober again xDD good night :p
 
Stop hatin', I only criticize to help not to judge.

Quas you've taught us alot about how you are as a man today, judging by your actions. Got nothing further to discuss with an ignorant. CBA responding to you if you reply to me.

@Unknown666
There's a way of saying "Treat people like you want to be treated." My point being with this is that Quas wants to be treated like an asshole.

C++ ain't as hard as he describes it to be, it's just the way it looks when your not familiar with it. Read the basics and you'll have a different view about it. From there on you can start with editing existing code and later make your own, that's a good way of advancing.

C++ is a bit different from OT C++, just a heads up.
 
Well, i just was pointing failures of you both, which comes from disability to proper reading. Actions speak louder whan words. Well seems i've become an asshole cuz i was 'helping' ya with ur misunderstanding, and have enlighten you. Your opinion.

Basics of C are not hard. Depends what you're gonna describe by saying 'basics'
 
Well, i just was pointing failures of you both, which comes from disability to proper reading. Actions speak louder whan words. Well seems i've become an asshole cuz i was 'helping' ya with ur misunderstanding, and have enlighten you. Your opinion.

Basics of C are not hard. Depends what you're gonna describe by saying 'basics'

Not that it matters to you, but I haven't slept properly for 3 days, not saying it's why I was mistaken but it was a reason for me to skim through your text instead of reading the whole content.

By basics I mean Programming A. Programming is not hard aslong as you find it fun to do. If you don't then it's really the wrong profession for the guy doing it because he will fail.

I started off with installing Ubuntu, MVCV and reading programming A. That pretty much was the start for me.
 
Oh Rly Menz? You're not the only one who havent slept good since few days, but still got some force left to point your failures.

Don't even know what the "Programming A" is.
 
Oh Rly Menz? You're not the only one who havent slept good since few days, but still got some force left to point your failures.

Don't even know what the "Programming A" is.

Seems like you're out to pick a fight again, quit being a keyboard warrior it's not fun. Also Programming A, B, C etc.. is Programming courses you learn at school or you can just go to the library and ask for a Programming A ~ C book.
 
GL with ur A programming /b/ro. I am goin to take a sleep since i am kinda tired due irregularry sleepin'. You should do the same, since u're tired too, instead lookin thru a forum.
 
Back
Top