• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

I can create Key NPC ?

Status
Not open for further replies.

Aquilla

Enthusiast
I was wondering how do this NPC Key

I wonder if the Eluna would make this system where the player enter a certain key where he would earn items or other rewards.
 
Last edited:

Viper1233

Banned
Not 100% sure what you mean but i think you mean an npc like ian drake?

4a3c22937a5aae1835b8bb09b9f1c6b1.png
 

Foereaper

Founder
Very simple test script to show you how it works below.

Code:
local KeyNPC = {}
local KeyNPC.ID = x
local KeyNPC.Code = "testcode"

function KeyNPC.OnGossipHello(event, player, unit)
	player:GossipMenuAddItem(0, "Code Input Example", 0, 1, true, "Please insert your code below.")
	player:GossipSendMenu(1, unit)
end

function KeyNPC.OnGossipSelect(event, player, object, sender, intid, code)
	if(code == KeyNPC.Code) then
		-- Do stuff here
	end
end

RegisterCreatureGossipEvent(KeyNPC.ID, 1, KeyNPC.OnGossipHello)
RegisterCreatureGossipEvent(KeyNPC.ID, 2, KeyNPC.OnGossipSelect)
 
Last edited:

Aquilla

Enthusiast
is to add support for multiple DB keys?

Example :

Code 82947 Gives 40 Vote Tokens
and
Code 82958 Gives 10 Donor Tokens

in Characters DB Haves "Keys" =

| Key | Item ID
28495 (ID)
 
Last edited:

Foereaper

Founder
Yes, you can do that, you would write a function to cache the database on start up, then query through that cache whenever you check the input code.
 

Aquilla

Enthusiast
without wanting to be boring '-' but how do I do that?

I'm new at Eluna and still am Brazilian with little experience in English

Note: I would like a method to auto delete when using the key to not use it repeatedly
 
Last edited:
Status
Not open for further replies.
Top