Jump to content

How to make a quest which gives any item to the player?


Recommended Posts

I want to make a quest which gives the player any item they want by input.

But I have an issue...

the "vnum" from give_item2 does not work with my local input variable.

The quest I have tried to make looks like this:

quest giveItm begin 
	state start begin 
		when login begin 
			say("test")  
			local itm = input()
			pc.give_item2(itm, 1)
			say("test2")
		end 
	end 
end

 

Link to comment
Share on other sites

  • Premium

?

quest giveItem begin 
	state start begin 
		when login begin 
			say("test")  
			local vnum = tonumber(input());
			if (vnum == nil or vnum == 0) then
				return say_reward("Invalid input.[ENTER]");

			elseif (mysql_direct_query(string.format("SELECT vnum FROM player.item_proto WHERE vnum = '%d';", vnum)) == 0) then
				return say_reward(string.format("The item %d doesn't exist in the database.[ENTER]", vnum))
			end -- if/elseif
			
			pc.give_item2(vnum, 1);
			say(string.format("The item %d (%s) has been received.", vnum, item_name(vnum)))
			say_item_vnum(vnum);
		end -- when
	end -- state
end -- quest

 

  • Love 2

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

Acum 1 oră, Syreldar a spus:

?


quest giveItem begin 
	state start begin 
		when login begin 
			say("test")  
			local vnum = tonumber(input());
			if (vnum == nil or vnum == 0) then
				return say_reward("Invalid input.[ENTER]");

			elseif (mysql_direct_query(string.format("SELECT vnum FROM player.item_proto WHERE vnum = '%d';", vnum)) == 0) then
				return say_reward(string.format("The item %d doesn't exist in the database.[ENTER]", vnum))
			end -- if/elseif
			
			pc.give_item2(vnum, 1);
			say(string.format("The item %d (%s) has been received.", vnum, item_name(vnum)))
			say_item_vnum(vnum);
		end -- when
	end -- state
end -- quest

 

I get this on compile:

Calls undeclared function! :
mysql_direct_query
Abort (core dumped)
 

Link to comment
Share on other sites

  • Premium
3 minutes ago, HisaoShou said:

I get this on compile:

Calls undeclared function! :
mysql_direct_query
Abort (core dumped)
 

We are almost in 2018 man, don't you know you have to add that to the quest_functions file first?

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Premium

Apparently, you don't have the mysql_direct_query functions on your server, sigh.

Just remove it from the quest.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

Acum 12 minute, Syreldar a spus:

Apparently, you don't have the mysql_direct_query functions on your server, sigh.

Just remove it from the quest.

Yes, this still does not work:

quest giveItem begin 
	state start begin 
		when login begin 
			say("test")  
			local vnum = tonumber(input());
			if (vnum == nil or vnum == 0) then
				return say_reward("Invalid input.[ENTER]");
			end -- if/elseif
			
			pc.give_item2(vnum, 1);
			say(string.format("The item %d (%s) has been received.", vnum, item_name(vnum)))
			say_item_vnum(vnum);
		end -- when
	end -- state
end -- quest

 

Link to comment
Share on other sites

  • Premium

fix your server ¯\_(ツ)_/¯, unless you are using a wrong vnum that's impossible.

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

  • Premium

The question is, why?

Why would you do that on a quest?

Just change the command /item (do_item) command from GameMaster into player and done, player will be able to do for example:

/i 19 or /item 19

to get a sword+9.

 

And if you dont want players to have to know the items id, change the item function and have it read names from the proto, then gettin corresponding vnum and voilá.

  • Love 1
Link to comment
Share on other sites

  • Premium
9 hours ago, tierrilopes said:

The question is, why?

Why would you do that on a quest?

Just change the command /item (do_item) command from GameMaster into player and done, player will be able to do for example:

/i 19 or /item 19

to get a sword+9.

 

And if you dont want players to have to know the items id, change the item function and have it read names from the proto, then gettin corresponding vnum and voilá.

5

^

 

"Nothing's free in this life.

Ignorant people have an obligation to make up for their ignorance by paying those who help them.

Either you got the brains or cash, if you lack both you're useless."

Syreldar

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.