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

Passphrase/Code Redeemer

Foereaper

Founder
Hello everyone! Being bored last night I figured I should write a passphrase/code redeemer. This works the same way as the TCG NPC's in Booty Bay, and other redeemers on retail. Passphrases/codes are premade and stored in a database table. A passphrase can only be used once.

There are currently 3 types of redemptions available.
- Type 1: Items
- Type 2: Titles
- Type 3: Money

If you have any idea for other types, please leave a comment below.

Remember to change the creature entry to your creature's entry. By default, the script reloads the code cache every 2 minutes (120 seconds). Change the values shown below in the script accordingly:

Code:
local Redeemer = {
        Entry = x,
        ReloadTimer = 120
}

Eluna Redeemer Script - GitHub

You do not need to manually run the SQL query below yourself, as the script will automatically create the table if it is missing.
However, if you want to execute the table query yourself, you can find it below:

Eluna Redeemer Query - GitHub

Your database table is then ready for you to create your own passphrases/codes as well as which rewards are tied to them:

- Passphrase is obviously the passphrase/code the player has to type into the creature to redeem their reward.
- Type is what type of reward is tied to the passphrase/code. Type 1 is item, Type 2 is title and Type 3 is money.
- Entry depends on the above type. If type is 1, then entry is item ID. If type is 2, then entry is title ID. If type is 3, then entry is 0.
- Count depends on the above type. If type is 1, then the count is the amount of items given. If type is 2, then count is 0. If type is 3, then count is the amount of copper given.
- Redeemed should stay 0. This is changed to 1 automatically when the passphrase/code is redeemed to prevent a code being used more than once.
- Player_GUID should stay NULL. This is changed to the player's GUID when the passphrase/code is redeemed.
- Date should stay NULL. This is changed to the current date/time when the passphrase/code is redeemed.

The passphrases/codes available are loaded once the server starts. This can manually be reloaded ingame by turning on your GM tag and talking to the redeemer. You will then have the option to refresh available passphrases.

Thanks to Rochet and Alex for input.
Thanks to Agency/Titan for testing.
 
Last edited:

EpiNemx

Respected Member
I just made a custom NPC and tried this, but it doesnt seem to work. I am unable to talk to the NPC, should I set certain flags on the NPC?
 

Rochet2

Moderator / Eluna Dev
I just made a custom NPC and tried this, but it doesnt seem to work. I am unable to talk to the NPC, should I set certain flags on the NPC?

Check your Eluna.log for errors or look in the console.
The NPC should have at least npcflag 1 which enables gossip windows.
 

EpiNemx

Respected Member
Check your Eluna.log for errors or look in the console.
The NPC should have at least npcflag 1 which enables gossip windows.


Thanks, the problem was the flagging part. I wasnt aware of flag 1 was gossip. Thank you.
 

Reck

Emulation Addict
There appears to be something wrong with the database system? I'm getting
Code:
lua_scripts/coderedeemer.lua:75: attempt to index field 'Cache' (a nil value)
as I attempt to redeem a code. For quick reference, line 75 is
Code:
if(Redeemer["Cache"][sCode]) then
 

Rochet2

Moderator / Eluna Dev
Most likely you used reload eluna which caused important parts not to run. Notice how Redeemer.LoadCache is tied to be run ONLY on server startup.
That means if you use reload its not run and the Redeemer table doesnt have Cache in the beginning before the LoadCache is run.
 

Foereaper

Founder
Updated the original script.

- Uploaded script to Github, changed DL links

- Optimized cache load query
- Added automatic cache reload (configurable)
- Couple rewrites to OnGossipSelect function
 
Top