TalkAction Remove RS (and frags) for premium points [ TFS 0.3.x ]

nsanee

Member
Joined
Apr 13, 2008
Messages
665
Best answers
0
Reaction score
16
Remove RS (and frags) for premium points [ TFS 0.3.4 ]

This simple script will remove Red Skull for premium points - the amount is configurable, as well as effect on succesfull removal. It works with Gesior's AAC shopsystem.

Removing frags doesn't work in 0.3.5, as for some reason they have changed the function for it, or the way it works - dunno since I don't use it.

File: /data/talkactions/scripts/removeskull.lua
Lua:
local exstorage = 1499
-- how many premium points are needed to take off the red skull
local COST = 20
-- "yes" or "no" // should it also remove all frags?
local REMOVE_FRAGS = "yes"
-- effect to use // you can find the list in data/lib/constant.lua
local EFFECT = CONST_ME_YELLOW_RINGS

function onSay(cid, words, param, channel)
    if (exhaustion.check(cid, exstorage) == true) then
        doPlayerSendCancel(cid, "You are exhausted")
        return false
    end
    
    if getCreatureSkullType(cid) == SKULL_RED then
        local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
        local points = query:getDataInt("premium_points")

        if points >= COST then
            local update = db.executeQuery("UPDATE `accounts` SET `premium_points`= "..(points - COST).." WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
            if (update == true) then            
                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your red skull has been taken off!\nRemaining premium points: " .. (points - COST))
                doCreatureSetSkullType(cid, SKULL_NONE)
                doWriteLogFile("./data/logs/removeskull.log", "Success: " .. getCreatureName(cid))
                if (REMOVE_FRAGS == "yes") then
                    doPlayerSetRedSkullTicks(cid, 0)
                end
                doSendMagicEffect(getPlayerPosition(cid), effect)
            else
                doPlayerSendCancel(cid, "Database error")
            end
           
        else
            doPlayerSendCancel(cid, "You need " ..COST.. " premium points to remove red skull")
        end
    else
        doPlayerSendCancel(cid, "You do not have red skull")
    end
    exhaustion.set(cid, exstorage, 30)
    
    if (query ~= nil) then
        query:free()
    end
    
    return TRUE
   
end
File: /data/talkactions/talkactions.xml

Code:
<talkaction words="!removeskull" event="script" value="removeskull.lua"/>
03-11-2009: changed the query:free() placement so that it won't show up errors. Also changed topic title that it's for 0.3.4. I didn't think they'd change the way it works in 0.3.5 but seems like I was wrong. As I don't use it yet I'll update the script when I do.
 
Last edited:

Saj

Remember my name
Joined
Feb 26, 2008
Messages
2,127
Best answers
0
Reaction score
5
Nice. Good job mate!
 

Zoriath

New Member
Joined
Mar 26, 2008
Messages
1,496
Best answers
0
Reaction score
3
Looks like this is for Gesior's ShopSystem... It uses table premium_points if I'm not mistaking... Can you say that in the first post? Will prevent a lot of people who use another AAC, for instance TFS CMS, from mistaking.
 
OP
nsanee

nsanee

Member
Joined
Apr 13, 2008
Messages
665
Best answers
0
Reaction score
16
Yes, I don't think any other AAC has a built-in shop system, and if some one uses another AAC he's most likely using his own, custom shop system, as well as scripts. I added the info anyway.

Thanks for comment Saj ;]
 

gullefjung

New Member
Joined
Apr 11, 2008
Messages
18
Best answers
0
Reaction score
0
It dosen't take away the frags on my server just the redskull :s
 

chojrak

Banned User
Joined
Oct 25, 2008
Messages
5,832
Best answers
2
Reaction score
158
You should write function like doPlayerAddPoints, getPlayerPoints and post on Lua Functions section. Will be usefull for many ppls.
 

freak15

Professional Hoster
Joined
Dec 31, 2008
Messages
355
Best answers
0
Reaction score
2
Location
Sweden
Dosnt Remove Frags rofl?
it dosnt remove frags for me lol
 

Suxex

Member
Joined
Aug 13, 2007
Messages
391
Best answers
0
Reaction score
5
Location
Halland - Getinge
It doesn't remove frags for me either =( and this came up in the console:

[15/10/2009 16:22:43] Lua Script Error: [TalkAction Interface]
[15/10/2009 16:22:43] data/talkactions/scripts/removeskull.lua:eek:nSay

[15/10/2009 16:22:43] data/talkactions/scripts/removeskull.lua:33: attempt to index global 'query' (a nil value)
[15/10/2009 16:22:43] stack traceback:
[15/10/2009 16:22:43] data/talkactions/scripts/removeskull.lua:33: in function <data/talkactions/scripts/removeskull.lua:8>
[15/10/2009 16:22:58] > Saving server...
[15/10/2009 16:23:02] > SAVE: Complete in 3.672 seconds using relational house storage.

[15/10/2009 16:23:09] Lua Script Error: [TalkAction Interface]
[15/10/2009 16:23:09] data/talkactions/scripts/removeskull.lua:eek:nSay

[15/10/2009 16:23:09] data/talkactions/scripts/removeskull.lua:19: attempt to call global 'doPlayerSetRedSkullTicks' (a nil value)
[15/10/2009 16:23:09] stack traceback:
[15/10/2009 16:23:09] data/talkactions/scripts/removeskull.lua:19: in function <data/talkactions/scripts/removeskull.lua:8>
Someone have a suggestion about this?

Thanks in advice!
 

Elexonic

Well-Known Member
Joined
Jun 18, 2008
Messages
1,921
Best answers
0
Reaction score
56
When it takes the network from me skull this mistake goes out ->

[02/11/2009 22:49:45] Lua Script Error: [TalkAction Interface]
[02/11/2009 22:49:45] data/talkactions/scripts/removeskull.lua:eek:nSay

[02/11/2009 22:49:45] data/talkactions/scripts/removeskull.lua:19: attempt to call global 'doPlayerSetRedSkullTicks' (a nil value)
[02/11/2009 22:49:45] stack traceback:
[02/11/2009 22:49:45] data/talkactions/scripts/removeskull.lua:19: in function <data/talkactions/scripts/removeskull.lua:8>
When I use the script and do not have network skull it works out this for me :S
Error->
[02/11/2009 22:50:52] Lua Script Error: [TalkAction Interface]
[02/11/2009 22:50:52] data/talkactions/scripts/removeskull.lua:eek:nSay

[02/11/2009 22:50:52] data/talkactions/scripts/removeskull.lua:33: attempt to index global 'query' (a nil value)
[02/11/2009 22:50:52] stack traceback:
[02/11/2009 22:50:52] data/talkactions/scripts/removeskull.lua:33: in function <data/talkactions/scripts/removeskull.lua:8>
And Not Remove Frags :S
Used Tfs 0.3.5 Pl1
Fixed pleased : (
 

Laxiaa

New Member
Joined
Oct 14, 2009
Messages
14
Best answers
0
Reaction score
0
This script doesnt remove frags, only red skull. But anyway after logging on u have this rs again.
 
Top