• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

TalkAction Premium system

Xavizus

Panchira Project Member
Joined
Jun 16, 2010
Messages
14
Reaction score
0
Location
Sweden
Greetings Otlander's!
Now you would think "what the hell?!".
This is a premium system where you get premium days from premium points (Which you usally get from donations)

Credits:
Kekox - The best VIP system ever - 99% credits to him from this thread
Xavizus - 1% Credits for making this script useable for normal premium

This has been tested in TFS 0.3.6 - Crying Damson!

Okey let's begin!

1.
Usally the sql query: premium_points already exists but just incase!
Add this SQL Query in your phpmyadmin:
Code:
ALTER TABLE `accounts` ADD `premium_points` int(11) NOT NULL DEFAULT 0;

2. Now let's go to your function lua(\data\lib\50-function.lua)
Add following at the top:
Lua:
function getPlayerPremiumPoints(cid)
	local info = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = "..getPlayerAccountId(cid).." LIMIT 1")
	if info:getID() ~= LUA_ERROR then
	local points= info:getDataInt("premium_points")
	info:free()
	return points
end
	return LUA_ERROR
end

function doAddPremiumPoints(cid, points)
	db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + "..points.." WHERE `id` = "..getPlayerAccountId(cid)..";")
end

3. Now, go to your talkaction folder (Data\talkactions\scripts\)
Create a new file with the name: premium.lua
Add follwing lines:
Lua:
function onSay(cid, words, param, channel)
local cfg = {
	days = 60, -- Change for how many days that should be added
	points = 20 -- Change for how many premium_points it should cost.
}
local playerpoints = getPlayerPremiumPoints(cid)
--------------------------------
	if playerpoints >= cfg.points then
		doPlayerAddPremiumDays(cid, cfg.days)
		db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. cfg.points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
		local playerpoints = getPlayerPremiumPoints(cid)
		doPlayerPopupFYI(cid, "Succesfull added 60 premium days! You have "..playerpoints.." remaining.")
		doWriteLogFile('data/logs/premium.txt', 'Account = '..getPlayerAccountId(cid)..' has bought '..cfg.days..' premium days!\n') 
	else
		doPlayerPopupFYI(cid, "You haven\'t enough of premium points!")
	end
	return false
end
4. Once again, create a new lua file, but with the name: add_points.lua!
Add following lines in to Add_points.lua:
Lua:
function onSay(cid, words, param, channel)
        if(param == '') then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires param.")
                return true
        end

        local t = string.explode(param, ",")
        t[1] = tonumber(t[1])
        if(not t[1]) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Command requires numeric param.")
                return true
        end

        local pid = cid
        if(t[2]) then
                pid = getPlayerByNameWildcard(t[2])
                if(not pid) then
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Player " .. t[2] .. " not found.")
                        return true
                end
        end

        if(t[1] > 500) then
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You can only add max 500 Premium points.")
                return true
        end
       
    doAddPremiumPoints(pid, t[1])
    doPlayerPopupFYI(cid, "Succsess!")
	doPlayerPopupFYI(pid, t[1].."Premium Points have been added to your account!")
        return true
end

5. Now go back one folder (Data\Talkactions\talkactions.xml)
Open the file Talkactions.xml and add:
--For normal players
Lua:
<talkaction words="!premium" event="script" value="premium.lua"/>
--For Gods
Lua:
<talkaction log="yes" words="/addpoints" access="5" event="script" value="add_points.lua"/>

6. Now we are done!
Some importent notes:
The god command /addpoints works like this: -DON'T forget the comma.
Code:
/addpoints 30, Xavizus
When the !premium command is used, a file will be created in (Data\logs\premium.txt) so you can see who have bought premium. Example:
Code:
[07/07/2010 16:19:56] Account = 2 has bought 60 premium days!
*Note Account = 2 (means Account with id 2) - It's an uniq id so don't worry!

ONCE AGAIN:
Credits:
Kekox - The best VIP system ever - 99% credits to him from this thread (1% to me for remaking this)
Xavizus - For making this script useable for normal premium
 
Rep++
Is pretty usefull thanks for sharing.
PHP:
doWriteLogFile("data/lib/Never_though_this_function_existed.txt")

Regards, Efren.
 
Rep++
Is pretty usefull thanks for sharing.
PHP:
doWriteLogFile("data/lib/Never_though_this_function_existed.txt")

Regards, Efren.

Thanks for the rep :p
About the doWriteLogFile function.. didn't know about it untill I got some help from "Someone I don't remember", and I find it usefull :p
I have changed this code abit so that the text file get the name of the account id :p

Yeap I know that this is nice, because, I (Who suck at php coding and using Modern AAC) can have an in-game shop system.
But what I am trying to do now is to do a History list so when you type : !shop History it will show what you have bought, in a FYI window. going to be a bit tricky, but in the end it will be awesome :D And ofc when I get it to work till 100%, I will share this with you :D
 
Last edited:
Please, english... But, I understand somehow what you are saying... (Thanks for GOOGLE TRANSLATE!!! :D)

If you knew english, then you would be able to install it...
 
Back
Top