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

Something is wrong in this script

narko

vertrauenswürdig ~
Joined
Oct 19, 2008
Messages
1,317
Solutions
2
Reaction score
132
Location
Unknown
Need help because if I'm buy a item and i have 10 points it say me: You dont have points. And the item costs 10 points

And get error need to fix this thing

Please need very easy HELP

LUA:
<?xml version="1.0" encoding="UTF-8"?>
<mod name="shop-items" version="1.0" author="martyx" contact="[email protected]" enabled="yes">
	<config name="command-shop-points-config"><![CDATA[ config = {
			logFile = "data/logs/points.log"
		}
	]]></config>

	<lib name="command-shop-points-lib"><![CDATA[ domodlib('command-shop-points-config')
		function getPlayerPoints(cid)
			return getAccountPoints(getPlayerAccountId(cid))
		end

		function doPlayerAddPoints(cid, points)
			return doAccountAddPoints(getPlayerAccountId(cid), points)
		end

		function doPlayerRemovePoints(cid, points)
			return doPlayerAddPoints(cid, -points)
		end

		function getAccountPoints(accountId)
			local result = db.getResult('SELECT premium_points FROM accounts WHERE id = ' .. accountId)
			local v = 0
			if(result:getID() ~= -1) then
				v = tonumber(result:getDataInt("premium_points"))
				result:free()
			end

			return v
		end

		function doAccountAddPoints(accountId, points)
			if(points < 0 and getAccountPoints(accountId) < math.abs(points)) then
				return false
			end

			return db.executeQuery('UPDATE accounts SET premium_points = premium_points + ' .. points .. ' WHERE id = ' .. accountId)
		end

		command_points = {
			config = config,
			logAction = function (str)
				if(command_points.config.logFile:trim() == '') then
					return
				end

				doWriteLogFile(command_points.config.logFile, str)
			end,

			shopitems = {
				["crystal coins"] = {id = 2160, cost = 4, charges = 100},
				["firewalker boots"] = {id = 9933, cost = 15, charges = 1},
				["soft boots"] = {id = 2640, cost = 8, charges = 1},
				["the stomper"] = {id = 8929, cost = 10, charges = 1},
				["solar sword"] = {id = 8931, cost = 10, charges = 1},
				["star tear"] = {id = 7735, cost = 12, charges = 1},
				["solar axe"] = {id = 8925, cost = 10, charges = 1},
				["elite draken helmet"] = {id = 12606, cost = 10, charges = 1},
				["royal draken mail"] = {id = 12603, cost = 10, charges = 1},
				["royal scale robe"] = {id = 12604, cost = 10, charges = 1},
				["yalahari mask"] = {id = 9778, cost = 8, charges = 1},
				["yalahari armor"] = {id = 9776, cost = 8, charges = 1},
				["yalahari legs"] = {id = 9777, cost = 8, charges = 1},
				["nightmare shield"] = {id = 6391, cost = 10, charges = 1},
				["necromancer shield"] = {id = 6433, cost = 10, charges = 1},
				["master archers armor"] = {id = 8888, cost = 10, charges = 1},
				["robe of the underworld"] = {id = 8890, cost = 10, charges = 1},
				["shield of corruption"] = {id = 12605, cost = 10, charges = 1},
				["snake god's wristguard"] = {id = 12608, cost = 10, charges = 1},
				["earthborn titan armor"] = {id = 8882, cost = 8, charges = 1},
				["fireborn giant armor"] = {id = 8881, cost = 8, charges = 1},
				["windborn collosus armor"] = {id = 8883, cost = 8, charges = 1},
				["royal tapestry"] = {id = 9958, cost = 1, charges = 1},
				["demon legs"] = {id = 2495, cost = 10, charges = 1},
				["rainbow shield"] = {id = 8905, cost = 10, charges = 1},
				["stamina refuel"] = {id = 2348, cost = 10, charges = 1},
				["spellbook of dark mysteries"] = {id = 8918, cost = 10, charges = 1},
				["spellbook of lost souls"] = {id = 8903, cost = 10, charges = 1},
				["dwarven helmet"] = {id = 2502, cost = 5, charges = 1},
				["dwarven armor"] = {id = 2503, cost = 5, charges = 1},
				["dwarven legs"] = {id = 2502, cost = 5, charges = 1},
				["skull remover"] = {id = 2345, cost = 10, charges = 1},
				["addon doll"] = {id = 9693, cost = 6, charges = 1}
			}
		}
	]]></lib>

	<talkaction words="!buy" event="script"><![CDATA[ domodlib('command-shop-points-lib')
		function onSay(cid, words, param, channel)
			if(param == '') then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have " .. getPlayerPoints(cid) .. " points on your account.")
				return true
			end

			local v = command-shop-points-lib.command_points.config.shopitems[param]
			if (not v) then
				doPlayerSendCancel(cid,"Item not found.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
				return true
			end

			local itemm = getItemWeightById(v.id, v.charges)
			if getPlayerFreeCap(cid) < itemm then
				doPlayerSendCancel(cid, "Sorry, you do not have enough cap. You need "..itemm.." oz to carry "..param..".")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			end

			if (getAccountPoints(cid) < v.cost) then
				doPlayerSendCancel(cid, "Sorry, you need "..v.cost.." points to buy this item.")
				doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
			else
				doPlayerAddItem(cid,v.id,v.charges)
				doRemovePoints(cid,v.cost)
				doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Thanks for buying!")
				doWriteLogFile("data/logs/buyeditems.txt", "[".. os.date('%d %B %y - %H:%M') .."] ".. getCreatureName(cid) .." bought "..param.." for "..v.cost.." points.")
			end

			return true 
		end
	]]></talkaction>
</mod>
 
Back
Top