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

HELP! I know its easy for you lua scripters!

scarface77

New Member
Joined
Dec 12, 2008
Messages
53
Reaction score
1
hello I got VIP coins script (when you use it gives you 1 point to SQL database and the item dissapear) and it works good, but I want to make it able to use only if you have 10+ vip coins and it takes 10 vip voins and adds 10 points to SQL.

the script

PHP:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid >= 1 then
local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";")

local points = query:getDataInt("premium_points")

db.executeQuery("UPDATE `accounts` SET `premium_points`= "..(points + 1).." WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")



doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have added 1 points to site shop.")


end

doRemoveItem(cid, item.uid, 1)
return true
end
 
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if item.type >= 10 then
    local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
      local points = query:getDataInt("premium_points")
      db.executeQuery("UPDATE `accounts` SET `premium_points`= "..(points + 10).." WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
                        doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
                                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have added 10 points to site shop.")
                             doRemoveItem(cid, item.itemid, 10)
                  elseif item.type <= 9 then
                      doSendMagicEffect(getThingPos(cid), CONST_ME_PUFF)
                      doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don\'t have the required items.")
                 end
      
return true
end
 
Last edited:
@OP
Is the Item stackable?

@Bogart
Code:
item.itemid >= 10?   item.type >= 10 <<< only if the item is stackable, if not then you have to use
getPlayerItemCount(cid, item.itemid) >= 10 then
 
got this error:
[18/04/2011 19:31:29] [Error - LuaScriptInterface::loadFile] data/actions/scripts/other/pkt.lua:16: 'end' expected (to close 'function' at line 2) near '<eof>'
[18/04/2011 19:31:29] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/pkt.lua)
[18/04/2011 19:31:29] data/actions/scripts/other/pkt.lua:16: 'end' expected (to close 'function' at line 2) near '<eof>'

and lua script:

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerItemCount(cid, item.itemid) >= 10 then
local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
local points = query:getDataInt("premium_points")
db.executeQuery("UPDATE `accounts` SET `premium_points`= "..(points + 10).." WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have added 10 points to site shop.")
doRemoveItem(cid, item.itemid, 10)
else
doSendMagicEffect(getThingPos(cid), CONST_ME_PUFF)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don\'t have the required items.")
end

return true
 
Ok it works!

Edit:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.type >= 100 then
local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
local points = query:getDataInt("premium_points")
db.executeQuery("UPDATE `accounts` SET `premium_points`= "..(points + 100).." WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have added 100 points to site shop.")
doRemoveItem(cid, item.uid, 100)
elseif item.type <= 99 then
doSendMagicEffect(getThingPos(cid), CONST_ME_PUFF)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You need 100 VIP coins to add it to shop.")
end

return true
end
 
got this error:
[18/04/2011 19:31:29] [Error - LuaScriptInterface::loadFile] data/actions/scripts/other/pkt.lua:16: 'end' expected (to close 'function' at line 2) near '<eof>'
[18/04/2011 19:31:29] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/other/pkt.lua)
[18/04/2011 19:31:29] data/actions/scripts/other/pkt.lua:16: 'end' expected (to close 'function' at line 2) near '<eof>'

and lua script:

function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerItemCount(cid, item.itemid) >= 10 then
local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
local points = query:getDataInt("premium_points")
db.executeQuery("UPDATE `accounts` SET `premium_points`= "..(points + 10).." WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")
doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You have added 10 points to site shop.")
doRemoveItem(cid, item.itemid, 10)
else
doSendMagicEffect(getThingPos(cid), CONST_ME_PUFF)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You don\'t have the required items.")
end

return true

fail copying and pasting :p
 
Back
Top