• 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.

Action [LEVER] Donate shop ingame *HOT*

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,444
Solutions
5
Reaction score
1,166
Location
Sweden
Hey there,

NEW VERSION OF THE SCRIPT CAN BE FOUND HERE!


I want to release my donate shop ingame system.
Buy donate items ingame for premium points!
Feel free to rep me :)
Tested in 0.4

Don't post your version of the script here (Respect)

First i want to thanks limos for the function. View Profile: Limos - OtLand

Make file in actions/scripts name it donateshop.lua and paste this into it:

Code:
local t = {
[1938] = {100,"arcane staff",2453},
[1939] = {100,"magic plate armor",2472},
}

function onUse(cid,item,fromPosition,itemEx,toPosition)
local v = t[item.uid]
      if getPremiumPoints(cid,v[1]) > v[1] and getPlayerFreeCap(cid) >= (getItemWeightById(v[3])) then
               doPlayerAddItem(cid,v[3])
               db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..v[1]..' WHERE id=' .. getPlayerAccountId(cid))
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have buy a " .. v[2] .. " for "..v[1].." points! Your current balance is "..getPremiumPoints(cid).." points!")
         elseif getPremiumPoints(cid,v[1]) < v[1] then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need atleast "..v[1].." points to buy "..getItemNameById(v[3]).."!")
         elseif getPlayerFreeCap(cid) < (getItemWeightById(v[3])) then
               doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need " .. getItemWeightById(v[3]) .. ".00 oz in order to get the item")
                 end
     return true
end


function getPremiumPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return 0
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end


Then open actions.xml and paste
Code:
<action uniqueid="1938-1939" event="script" value="donateshop.lua"/>


Configuration:

[1938] = {100,"arcane staff",2453},

1938: The uniqueid
100: How much points it
2453: The id of item


You can easy add more, etc:
Code:
[1938] = {100,"arcane staff",2453},
[1939] = {100,"magic plate armor",2472},
[1940] = {150,"demon armor",2494},
[1941] = {50,"demon shield",2520},

And don't forget to add the uniqueids to actions.xml etc:

Code:
<action uniqueid="1938-1941" event="script" value="donateshop.lua"/>

-- BALANCE CHECK --

This script allows you to check your points balance on your account.

Make file in actions/script and name it by balance.lua and paste into it :

Code:
function onUse(cid,item,fromPosition,itemEx,toPosition)
      if getPlayerLevel(cid) > 1 then
               doPlayerSendTextMessage(cid,19,"You have " .. getPremiumPoints(cid) .. " points on your account!")
                 end
     return true
end


function getPremiumPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return 0
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end

and in actions.xml paste

Code:
<action uniqueid="12461" event="script" value="balance.lua"/>

-- BALANCE CHECK NPC --

Go to data/npc and make xml file named by balance.xml and paste into :

Code:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Balance" script="balance.lua" walkinterval="2000" floorchange="0">
    <health now="150" max="150"/>
    <look type="142" head="114" body="0" legs="95" feet="114" corpse="2212"/>
    <parameters>
        <parameter key="module_shop" value="1"/>
        <parameter key="message_greet" value="Hello |PLAYERNAME|. Would you like to {balance} points?."/>
    </parameters>
</npc>

and go to data/npc/scripts and make file named balance.lua and paste into:

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local Topic = {}

function onCreatureAppear(cid)                npcHandler:eek:nCreatureAppear(cid) end
function onCreatureDisappear(cid)            npcHandler:eek:nCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg)            npcHandler:eek:nCreatureSay(cid, type, msg) end
function onThink()                    npcHandler:eek:nThink() end



--[[functions]]--
function getPoints(cid)
    local res = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."' LIMIT 1 ;")
    local value = 0
    if(res:getID() ~= -1) then
        value = res:getDataInt("premium_points")
        res:free()
    end
return value
end

function greetCallback(cid)
    Topic[cid] = 0
    return true
end
--[[Script start]]--

function creatureSayCallback(cid, type, msg)

    if(not npcHandler:isFocused(cid)) then
        return false
    end
    if (msgcontains(msg, 'balance') or msgcontains(msg, 'yes')) and Topic[cid] ~= 1 and Topic[cid] ~= 2 then
     selfSay("Ok, You have "..getPoints(cid).." premium points on your account!",cid)
    end
    return true
end
npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


-- BALANCE CHECK TALKACTION !BALANCE--


This allows you to check points balance by say !balance

First go to data/talkactions/scripts and make new file name it balance.lua and paste :

Code:
function onSay(cid, words, param)
if getPlayerLevel(cid) > 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You currently have "..getPoints(cid).." points on your account!")
end
return TRUE
end

function getPoints(cid)
    local res = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `name` = '"..getPlayerAccount(cid).."' LIMIT 1 ;")
    local value = 0
    if(res:getID() ~= -1) then
        value = res:getDataInt("premium_points")
        res:free()
    end
return value
end

After go to data/talkactions and open talkactions.xml and paste:

Code:
<talkaction log="yes" words="!balance" access="1" event="script" value="balance.lua"/>

Thanks for me :d
 
Last edited:
Keep comment / rep? (A)
 
Ok, and I need view my account points.

Who I do it?

What do you mean?

You can check your points into the site etc. But you gave me idea of making some "Balance checking"..

Will be added later =)

--Update--
Update V.1 added balance check script!

Also added to main script to show how much points you have after buy something, like etc:

16:50 You have buy a arcane staff for 100 points! Your current balance is 934 points!
16:50 You have buy a arcane staff for 100 points! Your current balance is 834 points!
 
Last edited:
Cool :p
I actually used a system like this back in 08 or something ^^ think the functions is still in /request

That way you won't need to call to SQL inside the script, makes it easier :)
 
Cool :p
I actually used a system like this back in 08 or something ^^ think the functions is still in /request

That way you won't need to call to SQL inside the script, makes it easier :)


Thanks for your comment. Agree with you! :)

I have "check balance" but to npc if someone prefer that.
etc

Godiskungen [793]: hi
Balance: Hello Godiskungen. Would you like to balance points?.
Godiskungen [793]: balance
Balance: Ok, You have 434 premium points on your account!
 
maybe a command just for balance
!balance or so
its simple but its easier and u can check it anytime and anywhere then :D
 
maybe a command just for balance
!balance or so
its simple but its easier and u can check it anytime and anywhere then :D

Thanks, i added !balance to main post! :)
 
what if i want the lever to pay with a custom item instead of premium points? say for instance a christmas token? ItemID: [6527]
 
Back
Top