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

Simple Premium System

Salja

Respected Member
Simple Premium System, check on login is player premium or not and send a welcome massage.
If the player are premium than he can use #premium as chat command that will open a gossip menu

NOTE 1: SQL need insert in characters database
NOTE 2: for add a new premium user insert the account id od the user in the new table "premium" and set active to 1
NOTE 3: you can add some more premium things as example telepoter and and and let me know when they need something

Thanks Foereaper for help with gossip on chat command

SQL
Code:
-- ----------------------------
-- Table structure for premium
-- ----------------------------
DROP TABLE IF EXISTS `premium`;
CREATE TABLE `premium` (
  `AccountId` int(11) unsigned NOT NULL,
  `active` int(11) unsigned NOT NULL default '1'
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

Lua Script
Code:
-- NOTE: need to insert character_premium.sql in your characters database

local function PremiumOnLogin(event, player)  -- Send a welcome massage to player and tell him is premium or not
    local result = CharDBQuery("SELECT AccountId FROM premium WHERE active=1 and AccountId = "..player:GetAccountId())
    if (result) then
        player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Welcome "..player:GetName().." you are Premium! |r")
    else
        player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Welcome "..player:GetName().." you are NOT Premium! |r")
    end
end

local function PremiumOnChat(event, player, msg, _, lang)
    local result = CharDBQuery("SELECT AccountId FROM premium WHERE active=1 and AccountId = "..player:GetAccountId())
    if (msg == "#premium") then  -- Use #premium for sending the gossip menu
        if (result) then
            OnPremiumHello(event, player)
        else
            player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Sorry "..player:GetName().." you are NOT Premium! |r")
        end
    end
end

function OnPremiumHello(event, player)
    player:GossipClearMenu()
    player:GossipMenuAddItem(0, "Show Bank", 0, 3)
    player:GossipMenuAddItem(0, "Show AuctionsHouse", 0, 4)
    player:GossipMenuAddItem(0, "Nevermind..", 0, 1)
    -- Room for more premium things
    player:GossipSendMenu(1, player, 100)
end

function OnPremiumSelect(event, player, _, sender, intid, code)
    if (intid == 1) then                     -- Close the Gossip
        player:GossipComplete()
    elseif (intid == 2) then                 -- Go back to main menu
        OnPremiumHello(event, player)
    elseif (intid == 3) then                 -- Send Bank Window
        player:SendShowBank(player)
    elseif (intid == 4) then                 -- Send Auctions Window
        player:SendAuctionMenu(player)
    end
    -- Room for more premium things
end

RegisterPlayerEvent(3, PremiumOnLogin)              -- Register Event On Login
RegisterPlayerEvent(18, PremiumOnChat)              -- Register Evenet on Chat Command use
RegisterPlayerGossipEvent(100, 2, OnPremiumSelect)  -- Register Event for Gossip Select

S9q6wlnJfI.jpg

suIr8RSWBb.jpg

fQwPuy1PeP.jpg

MmZzlac8GU.jpg
 

slp13at420

Mad Scientist
Code:
-- NOTE: need to insert character_premium.sql in your characters database

local function PremiumOnLogin(event, player)  -- Send a welcome massage to player and tell him is premium or not
    local result = CharDBQuery("SELECT AccountId FROM premium WHERE active=1 and AccountId = "..player:GetAccountId())
    if (result) then
        player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Welcome "..player:GetName().." you are Premium! |r")
    else
        player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Welcome "..player:GetName().." you are NOT Premium! |r")
    end
end

local function PremiumOnChat(event, player, msg, _, lang)
    local result = CharDBQuery("SELECT AccountId FROM premium WHERE active=1 and AccountId = "..player:GetAccountId())
    if (msg == "#premium") then  -- Use #premium for sending the gossip menu
        if (result) then
            OnPremiumHello(event, player)
        else
            player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Sorry "..player:GetName().." you are NOT Premium! |r")
        end
    end
end

function OnPremiumHello(event, player)
    player:GossipClearMenu()

I did notice something about the script you may want to change. as it is now every time a player uses #premium it will query the db.
rather than doing it over and over for the same value , why not just table the value when a player logs on like :

Code:
ACCT = {}
print ("Premium Table Allocated.")
-- Trinity using Eluna

function Player_Premium_Table(event, player)
	local Q = WorldDBQuery("SELECT username, premium FROM auth.account WHERE `id` = '"..player:GetAccountId().."';"); -- this would need to be changed for your Premium value location.
	ACCT[player:GetAccountId()] = {
		Name = Q:GetString(0),
		Premium = Q:GetUInt32(1)
									};
	print(ACCT[player:GetAccountId()].Name.." :Premium table loaded.")
print(ACCT[player:GetAccountId()].Premium)
end
RegisterPlayerEvent(3, Player_Premium_Table)
this will only query once when they logon and then you can just reference the value from the ACCT table when you do the logon notice"you are/are not Premium" or the "#premium" command.
makes it much faster when referencing the data for that players account using something like this:
Code:
if ACCT[player:GetAccountId()]==1 then -- 0/1 inactive/active
          do stuff

this is how I do my VIP system . it just tables there vip level then scripts will sometimes references the table and use the stored value.
this is a hasty reverse engineer to use as an example so I doubt it will actually load and work without err's.
 
Last edited:

Lstm

Respected Member
It would be possible to add custom menu items to add to the premium players?
Multivendor style ..
Thank you!
 

slp13at420

Mad Scientist
all you would have to do is expand the function OnPremiumHello with more GossipMenuAddItem 's.
now I don't know how int's are handled .. would having all gossip menus start with 1 and go up or should each gossip script be allotted its own unique int id range.
and then add to your OnPremiumSelect an if to filter for specific intid and do whatever.

Code:
[COLOR="#808080"]
function OnPremiumHello(event, player)
    player:GossipClearMenu()
    player:GossipMenuAddItem(0, "Show Bank", 0, 3) -- intid 3
    player:GossipMenuAddItem(0, "Show AuctionsHouse", 0, 4) -- intid 4
    player:GossipMenuAddItem(0, "Nevermind..", 0, 1) -- intid 1
    -- Room for more premium `player:GossipAddItem` things [COLOR="#FFFF00"]<--expand here[/COLOR]
    player:GossipSendMenu(1, player, 100)
end

function OnPremiumSelect(event, player, _, sender, intid, code)
    if (intid == 1) then                     -- Close the Gossip
        player:GossipComplete()
    elseif (intid == 2) then                 -- Go back to main menu 
        OnPremiumHello(event, player)
    elseif (intid == 3) then                 -- Send Bank Window
        player:SendShowBank(player)
    elseif (intid == 4) then                 -- Send Auctions Window
        player:SendAuctionMenu(player)
    end
    -- Room for more premium vendor/buff/perks/things [COLOR="#FFFF00"]<--expand here[/COLOR]
end
[/COLOR]

a little touch-up also would make it faster reacting and more dynamic . but still an excellent idea.
depending on what it is you want to add I may be able to help add it for you .
 
Last edited:

Lstm

Respected Member
Thank you, I took a big doubt .. but I wanted to know how I can identify more spaces for prizes, example: adding a sub menu to SET ITEM / WEAPON / ETC ...
Thank you .. ♥
 

slp13at420

Mad Scientist
I will snap something together but its gonna take a little time since I work 12hrs a day. I will have something for you by the next 48 hours.
 

slp13at420

Mad Scientist
the direct approach for sending the vendor window too the player cannot be done ..buutttttt.... I am going to change it to summon a premium vendor instead.
 

slp13at420

Mad Scientist

Ok here is a version of this system by Salja updated with dynamic n tables n loops woohoooooo lol
using #premium in chat will open a gossip menu IF the player has a Premium rank.
selecting the vendor will summon a vendor npc. the npc will open a gossip window with vendor choices IF the player has a Premium rank else it will instantly despawn but if the player is a Premium then the vendor will stay spawned for 90 seconds.

You will need to add a single custom column to your auth.account table:
Code:
[COLOR="#808080"]
CREATE TABLE dummy (
	`premium` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0'
)
[/COLOR]

this also requires the vendor npc be added to your creature.template:
Code:
[COLOR="#808080"]
REPLACE INTO `creature_template` (`entry`, `difficulty_entry_1`, `difficulty_entry_2`, `difficulty_entry_3`, `KillCredit1`, `KillCredit2`, `modelid1`, `modelid2`, `modelid3`, `modelid4`, `name`, `subname`, `IconName`, `gossip_menu_id`, `minlevel`, `maxlevel`, `exp`, `faction_A`, `faction_H`, `npcflag`, `speed_walk`, `speed_run`, `scale`, `rank`, `mindmg`, `maxdmg`, `dmgschool`, `attackpower`, `dmg_multiplier`, `baseattacktime`, `rangeattacktime`, `unit_class`, `unit_flags`, `unit_flags2`, `dynamicflags`, `family`, `trainer_type`, `trainer_spell`, `trainer_class`, `trainer_race`, `minrangedmg`, `maxrangedmg`, `rangedattackpower`, `type`, `type_flags`, `lootid`, `pickpocketloot`, `skinloot`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `spell1`, `spell2`, `spell3`, `spell4`, `spell5`, `spell6`, `spell7`, `spell8`, `PetSpellDataId`, `VehicleId`, `mingold`, `maxgold`, `AIName`, `MovementType`, `InhabitType`, `HoverHeight`, `Health_mod`, `Mana_mod`, `Armor_mod`, `RacialLeader`, `questItem1`, `questItem2`, `questItem3`, `questItem4`, `questItem5`, `questItem6`, `movementId`, `RegenHealth`, `mechanic_immune_mask`, `flags_extra`, `ScriptName`, `WDBVerified`, `equipment_id`, `mg`) VALUES 
(101, 0, 0, 0, 0, 0, 31048, 0, 0, 0, 'Premium Vendor', 'Premium Gear', 'Buy', 0, 80, 80, 0, 35, 35, 129, 1, 1.14286, 3.5, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '', 0, 3, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, '', 1, NULL, 0);[/COLOR]

then add the script: "Premium_1_Engine.lua"
Code:
[COLOR="#808080"]
-- Premium System by Salja of emudevs.com
-- updated by slp13at420 of emudevs.com
-- just add 1 column to your auth.account table:
-- name `premium` : Datatype = TINYINT : Length/Set = 1 : Unsigned = checked : Default = 0
-- just add 1 npc vendor to your wold.creature_template table.
-- for TrintyCore2 3.3.5 Eluna
local npcid = 101
BUFFS = {};
PREM = {};
local BUFFS = {48074,43223,36880,467,48469,48162,23948,24752,16877,10220,13033,11735,10952};
PREM["SERVER"] = {
		vendor_id = npcid
				};
print ("Salja's Premium System Table: initialized and allocated.")

local function PremiumOnLogin(event, player)  -- Send a welcome massage to player and tell him is premium or not

local Q = WorldDBQuery("SELECT username, premium FROM auth.account WHERE `id` = '"..player:GetAccountId().."';"); -- this would need to be changed for your Premium value location.

PREM[player:GetAccountId()] = {
	Name = Q:GetString(0),
	Premium = Q:GetUInt32(1)
				};
			
	if(PREM[player:GetAccountId()].Premium==1)then
		player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Welcome "..player:GetName().." you are Premium.|r")
	else
		player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Welcome "..player:GetName()..".|r")
		player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E You can donate to earn the Premium Rank.|r")
    	end
print(PREM[player:GetAccountId()].Name.." :Premium table loaded.")
end

RegisterPlayerEvent(3, PremiumOnLogin) 

local function UnSummonPremiumVendor(eventid, timer, player, creature)
	creature:DespawnOrUnsummon()
	WorldDBQuery("DELETE FROM world.creature WHERE `guid` = '"..creature:GetGUIDLow().."';") 
end

local function SummonPremiumVendor(player)
	if(PREM[player:GetAccountId()].Premium==1)then
		PerformIngameSpawn(1, PREM["SERVER"].vendor_id, player:GetMapId(), 0, player:GetX(), player:GetY(), player:GetZ(), player:GetO(), 1, 90000, 1)
	end
end

local function PremiumOnChat(event, player, msg, _, lang)
	if (msg == "#premium") then  -- Use #premium for sending the gossip menu
		if(PREM[player:GetAccountId()].Premium==1)then
            OnPremiumHello(event, player)
        else
            player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Sorry "..player:GetName().." you dont have the Premium rank. |r")
            player:SendBroadcastMessage("|CFFE55BB0[Premium]|r|CFFFE8A0E Please consider donating for the rank. |r")
        end
    end
end

function OnPremiumHello(event, player)
	player:GossipClearMenu()
	player:GossipMenuAddItem(0, "Show Bank.", 0, 2)
	player:GossipMenuAddItem(0, "Show AuctionsHouse.", 0, 3)
	player:GossipMenuAddItem(0, "Summon the Premium Vendor.", 0, 4)
	player:GossipMenuAddItem(0, "Buff me.", 0, 5)
	player:GossipMenuAddItem(0, "Repair my items.", 0, 6)
	player:GossipMenuAddItem(0, "Reset my Talents.", 0, 7)
	player:GossipMenuAddItem(0, "Nevermind..", 0, 1)
	player:GossipSendMenu(1, player, 100)
end

function OnPremiumSelect(event, player, unit, sender, intid, code)
	
	if(intid==1) then -- Close the Gossip
        end
 	if(intid==2) then -- Send Bank Window
        	player:SendShowBank(player)
        end
	if(intid==3) then -- Send Auctions Window
        	player:SendAuctionMenu(player)
        end
	if(intid==4)then -- summon the Premium Vendor
		SummonPremiumVendor(player)
	end
	if(intid==5)then -- buff  me
		for _, v in ipairs(BUFFS)do
			player:AddAura(v, player)
		end
	end
	if (intid==6) then -- Repair all items 100%
		player:DurabilityRepairAll(100,100)
	end
	if (intid==7) then -- Reset talent points. Salja's idea.
		player:SetFreeTalentPoints(78, 0)
		player:SetFreeTalentPoints(78, 1)
		player:SendBroadcastMessage("|cff00cc00All your talents are reset!|r")
	end
	if(intid > 7) then -- Go back to main menu
		player:GossipComplete()
		OnPremiumHello(event, player)
	end
player:GossipComplete()
end

RegisterPlayerEvent(18, PremiumOnChat)              -- Register Evenet on Chat Command use
RegisterPlayerGossipEvent(100, 2, OnPremiumSelect)  -- Register Event for Gossip Select

local function PremiumVendorHello(eventid, player, creature)
	if(PREM[player:GetAccountId()].Premium==1)then
		player:GossipClearMenu()
		player:GossipMenuAddItem(1, "Armor.", 0, 1012)
		player:GossipMenuAddItem(1, "Weapons.", 0, 1013)
		player:GossipMenuAddItem(1, "Misc Premium items.", 0, 1014)
		player:GossipMenuAddItem(2, "Nevermind..", 0, 1011)
		player:GossipSendMenu(1, creature)
		creature:RegisterEvent(UnSummonPremiumVendor, 90000, 1, player, creature)
	else
		creature:RegisterEvent(UnSummonPremiumVendor, 1, 1, player, creature)
	end
end

local function PremiumVendorSelect(event, player, creature, sender, intid, code)	
VendorRemoveAllItems(101)
	if(intid==1011) then
	end
    if(intid==1012)then
    	AddVendorItem(PREM["SERVER"].vendor_id, 17,1,1,0)
    	player:SendVendorWindow(creature)
	end
    if(intid==1013)then
    	AddVendorItem(PREM["SERVER"].vendor_id, 25,1,1,0)
    	player:SendVendorWindow(creature)
	end
    if(intid==1014)then
    	AddVendorItem(PREM["SERVER"].vendor_id, 38,1,1,0)
    	player:SendVendorWindow(creature)
    end
player:GossipComplete()
end

RegisterCreatureGossipEvent(PREM["SERVER"].vendor_id, 1, PremiumVendorHello)
RegisterCreatureGossipEvent(PREM["SERVER"].vendor_id, 2, PremiumVendorSelect)

[/COLOR]





 
Last edited:

slp13at420

Mad Scientist

since I updated it with Lua Tables you can add more scripts to work with the Premium Engine script.
by using this:
Code:
[COLOR="#808080"]
     if(PREM[player:GetAccountId()].Premium==1)then
          do stuff
[/COLOR]
you can add premium allow/deny to what ever script you wish to run with this.
 

Foereaper

Founder

since I updated it with Lua Tables you can add more scripts to work with the Premium Engine script.
by using this:
Code:
[COLOR="#808080"]
     if(PREM[player:GetAccountId()].Premium==1)then
          do stuff
[/COLOR]
you can add premium allow/deny to what ever script you wish to run with this.

If you are to use the above, your script would have to start with a letter after "P" in the alphabet, or the above script would have to be moved into the extensions folder.
 

slp13at420

Mad Scientist
If you are to use the above, your script would have to start with a letter after "P" in the alphabet, or the above script would have to be moved into the extensions folder.

sorry bout that lol I totally forgot.
if you do choose to add independent scripts to this then I recommend you create a sub-folder in lua_scripts folder and add them plus these there. name any new scripts so they load alphanumerically after the Premium_1_Engine.lua script.
 
Top