• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Points System.

president vankk

Web Developer & AuraOT Owner
Joined
Jul 10, 2009
Messages
5,719
Solutions
9
Reaction score
339
I wanted a script that the admin will talk /addpoints name, quantity.
And then the player will speak !Buy1cc and he will win a crystal coins.
 
/addpoints John, 100

Code:
function onSay(cid, words, param, channel)
	local v = string.explode(param, ',')
	local player, points = getPlayerByNameWildcard(v[1]), tonumber(v[2])
	return player and points and db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccount(player) .. ";") or doPlayerSendCancel(cid, "Sorry, not possible.")
end


Code:
function onSay(cid, words, param, channel)
	local shop = {
		["cc"] = {
			id = 2160, count = 1, points = 10
		}
	}
	local v = shop[param]
	local check = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = '" .. getPlayerAccountId(cid) .. "' LIMIT 1;")
	if check >= v.points then
		local item = doCreateItemEx(v.id, v.count)
		if doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR then
			doPlayerSendCancel(cid, "Sorry, you do not have the ability to carry this.")
		else
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Shop: Added " .. v.count .."x " .. getItemInfo(v.id).name .. " to your inventory.")
			db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. v.points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
		end
	else
		doPlayerSendCancel(cid, "Sorry, you do not have enough premium points.")
	end
	return true
end
 
Last edited:
LUA:
		["cc"] = {
			id = 2160, count = 1, points = 10
		}
		["cc"] = {
			id = 2160, count = 1, points = 10
		}
	}
correct?
 
Last edited:
no, after a first value you need a "comma (,)" so
LUA:
                ["cc"] = {
                        id = 2160, count = 1, points = 10
                },
                ["cc"] = {
                        id = 2160, count = 1, points = 10
                }
        }
 
LUA:
function onSay(cid, words, param, channel)
	local shop = {
		["100cc"] = {
			id = 2160, count = 100, points = 3
		},
		["fire"] = {
			id = 9933, count = 1, points = 4
		},
		["blood"] = {
			id = 2798, count = 100, points = 1
		},
		["50cc"] = {
			id = 2160, count = 50, points = 2
		},
		["soft"] = {
			id = 6132, count = 1, points = 3
		},
		["haste"] = {
			id = 2195, count = 1, points = 2
		},
		["demolegs"] = {
			id = 2495, count = 1, points = 5
		},
		["solar"] = {
			id = 2495, count = 1, points = 5
		},
		["long"] = {
			id = 2390, count = 1, points = 3
		},
		["spellbook"] = {
			id = 8918, count = 1, points = 3
		}
	}
	local v = shop[param]
	local check = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = '" .. getPlayerAccountId(cid) .. "' LIMIT 1;")
	if check >= v.points then
		local item = doCreateItemEx(v.id, v.count)
		if doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR then
			doPlayerSendCancel(cid, "Sorry, you do not have the ability to carry this.")
		else
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Shop: Added " .. v.count .."x " .. getItemInfo(v.id).name .. " to your inventory.")
			db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. v.points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
		end
	else
		doPlayerSendCancel(cid, "Sorry, you do not have enough premium points.")
	end
	return true
end
correct?
 
Code:
function onSay(cid, words, param, channel)
	local v = string.explode(param, ',')
	local player, points = getPlayerByNameWildcard(v[1]), tonumber(v[2])
	return player and points and db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` + " .. points .. " WHERE `id` = " .. getPlayerAccount(player) .. ";") or doPlayerSendCancel(cid, "Sorry, not possible.")
end



Code:
function onSay(cid, words, param, channel)
	local shop = {
		["cc"] = {
			id = 2160, count = 1, points = 10
		}
	}
	local v = shop[param]
	local check = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = '" .. getPlayerAccountId(cid) .. "' LIMIT 1;")
	if check >= v.points then
		local item = doCreateItemEx(v.id, v.count)
		if doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR then
			doPlayerSendCancel(cid, "Sorry, you do not have the ability to carry this.")
		else
			doSendMagicEffect(getThingPos(cid), CONST_ME_GIFT_WRAPS)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Shop: Added " .. v.count .."x " .. getItemInfo(v.id).name .. " to your inventory.")
			db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` - " .. v.points .. " WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
		end
	else
		doPlayerSendCancel(cid, "Sorry, you do not have enough premium points.")
	end
	return true
end
what did you do? you just copied >>812184 this guy's query and said its yours
 
Back
Top