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

[Function] Event points

LucasFerraz

Systems Analyst
Joined
Jun 10, 2010
Messages
2,858
Reaction score
96
Location
Brazil
Code:
Type: Function
Author: Antharaz
Tested Version: 0.4.0

Execute this query:
PHP:
ALTER TABLE `accounts` ADD `event_points` INT NOT NULL DEFAULT '0'
ALTER TABLE `players` ADD `event_points` INT NOT NULL DEFAULT '0'

in data/lib create 027-events.lua and add:
Lua:
function getEventPoints(cid,type)
    local pid = type == "accounts" and getPlayerAccountId(cid) or getPlayerGUID(cid)
    local hname = db.getResult("SELECT `event_points` FROM `"..type.."` WHERE `id` = "..pid.." ;")
    return hname:getID() ~= -1 and hname:getDataInt("event_points") or false
end
 
function addEventPoints(cid,points)
    local pid = getPlayerGUID(cid)
    local aid = getPlayerAccountId(cid)
    local point = (getEventPoints(cid,"accounts") + points) 
    local point = point > 0 and point or 0
    db.executeQuery("UPDATE `accounts` SET `event_points` = "..point.." WHERE `id` = "..aid..";")
    point = (getEventPoints(cid,"players") + points) 
    point = point > 0 and point or 0
    db.executeQuery("UPDATE `players` SET `event_points` = "..point.." WHERE `id` = "..pid..";")
end

How to use:
getEventPoints(cid,type) return how much events points player/account has.
getEventPoints(cid,"players") events will return the player points that he did.
getEventPoints(cid,"accounts") will return the sum of events points to all players that this account has.
addEventPoints(cid, 145) will add 145 event points
addEventPoints(cid, -145) will remove 145 event points


------------
Talkaction

made by VirrageS
XML:
<talkaction access="5" words="/addpoints" event="script" value="addEventPoints.lua"/>

Lua:
function onSay(cid, words, param)
	local t = param.explode(param, ',')
	local pid = getPlayerByNameWildcard(t[1])
	if pid ~= nil then
		addEventPoints(pid, t[2])
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You added '..t[2]..' points to '..t[1]..'.')
		return true
	end
	doPlayerSendCancel(cid, 'Player with name '..t[1]..' doesn\'t exist or isn\'t online.')
	return true
end


Use:
Code:
/addpoints [B]NAME[/B], [B]POINTS[/B]
 
Last edited:
XML:
<talkaction access="5" words="/addpoints" event="script" value="addEventPoints.lua"/>

Lua:
function onSay(cid, words, param)
	local t = param.explode(param, ',')
	local pid = getPlayerByNameWildcard(t[1])
	if pid ~= nil then
		addEventPoints(pid, t[2])
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You added '..t[2]..' points to '..t[1]..'.')
		return true
	end
	doPlayerSendCancel(cid, 'Player with name '..t[1]..' doesn\'t exist or isn\'t online.')
	return true
end


Use:
Code:
/addpoints [B]NAME[/B], [B]POINTS[/B]
 
Last edited:
[9/4/2017 15:0:58] OTSYS_SQLITE3_PREPARE(): SQLITE ERROR: near "LIMIT": syntax error (UPDATE "accounts" SET "premium_points" = 50 WHERE "name"='jibran' LIMIT 1;)
 
Hello who helps me with that error that I get when I give points and the other when I add the script to the sql

[9/4/2017 15:0:58] OTSYS_SQLITE3_PREPARE(): SQLITE ERROR: near "LIMIT": syntax error (UPDATE "accounts" SET "premium_points" = 50 WHERE "name"='jibran' LIMIT 1;)

Error ejecutando consulta: near "ALTER": syntax error
<simple query executor>
 
how can i create a custom shop in znote acc with some differents items, i mean, Classic Shop with Premium Points and Events Points...
for znote 1.5
 
Back
Top