Please somebody HELP ME!
How do I set a storage_value to set VIP on players intead of premdays?
Im running SQL
-- Credits StreamSide, Empty and Kaorus
function onUse(cid, item, fromPosition, itemEx, toPosition)
local name = getCreatureName(cid)
-- if getPlayerStorageValue(cid,11551) < 1 then
if getPlayerLevel(cid) > 1 then
getPlayerStorageValue(cid, 11551)
doSendAnimatedText(getPlayerPosition(cid), "Welcome!", TEXTCOLOR_RED)
doCreatureSay(cid, "CONGRATULATIONS! You are now a VIP for 30 days! You can now enter the VIP-area and use unique features!. ", TALKTYPE_ORANGE_1)
doBroadcastMessage("" .. name .. " is now a VIP member. For more details, go to our website shop: xx.xx.xx")
setPlayerStorageValue(cid, 11551, (getPlayerStorageValue(cid,11551) + 15))
doRemoveItem(item.uid, 1)
else
doPlayerSendCancel(cid,"You need to be at least level 2 to use this.")
doRemoveItem(item.uid, 1)
end
-- else
-- doPlayerSendCancel(cid,"You are already a donator.")
-- end
return TRUE
end
Just make an item that gives them VIP in actions:
Code:-- Credits StreamSide, Empty and Kaorus function onUse(cid, item, fromPosition, itemEx, toPosition) local name = getCreatureName(cid) -- if getPlayerStorageValue(cid,11551) < 1 then if getPlayerLevel(cid) > 1 then getPlayerStorageValue(cid, 11551) doSendAnimatedText(getPlayerPosition(cid), "Welcome!", TEXTCOLOR_RED) doCreatureSay(cid, "CONGRATULATIONS! You are now a VIP for 30 days! You can now enter the VIP-area and use unique features!. ", TALKTYPE_ORANGE_1) doBroadcastMessage("" .. name .. " is now a VIP member. For more details, go to our website shop: xx.xx.xx") setPlayerStorageValue(cid, 11551, (getPlayerStorageValue(cid,11551) + 15)) doRemoveItem(item.uid, 1) else doPlayerSendCancel(cid,"You need to be at least level 2 to use this.") doRemoveItem(item.uid, 1) end -- else -- doPlayerSendCancel(cid,"You are already a donator.") -- end return TRUE end
Then sell that item, 30 days of VIP.
Lua Script Error: [GlobalEvent Interface]
data/globalevents/scripts/shop.luanThink
luaDoPlayerAddItemEx(). Item not found
New error
PHP:[25/07/2009 14:13:28] Lua Script Error: [CreatureScript Interface] [25/07/2009 14:13:28] in a timer event called from: [25/07/2009 14:13:28] data/creaturescripts/scripts/login.lua:onLogin [25/07/2009 14:13:28] data/creaturescripts/scripts/login.lua:47: attempt to index global 'luasql' (a nil value) [25/07/2009 14:13:28] stack traceback: [25/07/2009 14:13:28] data/creaturescripts/scripts/login.lua:47: in function <data/creaturescripts/scripts/login.lua:45>
TFS 0.3 or TFS 0.2.13 npc? You must know LUAsql or new method to connect to database if you use TFS 0.3. I can make function to add points for you.
If you use TFS 0.3 rev. 840+ add this at end of .../data/functions.lua file:
return TRUE if changed premium days valueCode:function addPremiumPoints(cid, value) local player_account_id = db.getResult("SELECT `account_id` FROM `players` WHERE `name` = " .. db.escapeString(getCreatureName(cid)) .. ";") if(player_account_id:getID() ~= -1) then local account_id = player_account_id:getDataInt("account_id") player_account_id:free() local player_account = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. account_id .. ";") if(player_account:getID() ~= -1) then local setpoints = player_account:getDataInt("premium_points") + value db.executeQuery("UPDATE `accounts` SET `premium_points` = " .. setpoints .. " WHERE `id` = " .. account_id .. ";") player_account:free() return TRUE end end return FALSE end
return FALSE if not
Use in talkaction:
(tested on TFS 0.3 rev. 900)Code:function onSay(cid, words, param) if getPlayerMoney(cid) >= 5000 then if addPremiumPoints(cid, 10) == TRUE then doPlayerRemoveMoney(cid, 5000) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You received 10 premium points for 5000gp.") else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Error ocurred you don't receive 10 points.") end else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "10 points cost 5000 gp, you don't have enought money.") end end
<talkaction words="!points" event="script" value="points.lua"/>
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/points.lua:onSay
data/talkactions/scripts/points.lua:3:attempt to call global 'addPremiumPoints' ( a nil value)
stack traceback:
data/talkactions/scripts/points.lua:3:in function <data/talkactions/scripts/points.lua:1>