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:
Then open actions.xml and paste
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:
And don't forget to add the uniqueids to actions.xml etc:
-- 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 :
and in actions.xml paste
-- BALANCE CHECK NPC --
Go to data/npc and make xml file named by balance.xml and paste into :
and go to data/npc/scripts and make file named balance.lua and paste into:
-- 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 :
After go to data/talkactions and open talkactions.xml and paste:
Thanks for me :d
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: