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

Donation points rewarded based on account

fish04k

Member
Joined
Mar 23, 2008
Messages
102
Reaction score
19
Well I tried to get this working but I just can't seem to no matter what I do. Would love if someone could tell me what I am doing wrong.

Here is the function I added from Cyto
Lua:
function hasAccountStorage(cid, key, value)
	if isPlayer(cid) == false then
		error("[hasAccountStorage] Player not found (cid=" .. tostring(cid) .. ")")
	elseif tonumber(key) == nil then
		error("[hasAccountStorage] Invalid key (key=" .. tostring(key) .. ")")
	else
		local q = db.getResult('SELECT player_id FROM player_storage LEFT JOIN players ON player_storage.player_id=players.id WHERE players.account_id=' .. getPlayerAccountId(cid) .. ' AND `key`=' .. key .. (value and ' AND value=' .. db.escapeString(value) or '') .. ' LIMIT 1')
		if q:getID() ~= -1 then
			q:free()
			return true
		end
	end
end

And here is what I've come up with after a million and one tries.
Lua:
function onAdvance(cid, skill, oldLevel, newLevel)
        if newLevel == 250 then
		if (hasAccountStorageValue(cid, 46284, 4)) then
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, 'Congratulations on reaching 250! Unfortunately, You already have a character over this level and will not receive any points!')
		
		else
				db.executeQuery('UPDATE accounts SET premium_points=premium_points+'.. 50 ..' WHERE id=' .. getPlayerAccountId(cid))
				setAccountStorageValue(cid, 46284, 4)
				doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Congratulations! You have advanced to level 250 and got 50 Points!')
				doBroadcastMessage('Congratulations! ' .. getCreatureName(cid) .. ' Advanced To Level 250 and got 50 Points!')
		end
	end
end

Thanks in advanced for anyone that can assist me!
 
Back
Top