LucasFerraz
Systems Analyst
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: