fewdox
New Member
when update come ?
<?xml version="1.0" encoding="UTF-8"?>
<mod name="Cyber's REP System" revision="5.1" author="Cybermaster" web="otland.net" enabled="yes"
released="August2010" credits="Sync;Shawak;Chris;nsanee"><config name="repSystem"><![CDATA[
rep = {
--[[ CONFIG ]]--
interval = 180, --This is [3] hours, in minutes. Time to be online to gain [1] Opinion Point.
minLevel = 20, --From this level onwards player can use commands
pvpLevel = 30, --Minimum level for PVP Rep'ing
required = 5, --Opinion points required to repute with talkaction command
--[[ STORAGES ]]--
update = 9234, --Global Storage used to verify database at server startup
lastName = 5036, --Used to store the last repped's GUID
lastKilled = 5037, --Used to store the last killed's GUID
opinion = 5038, --Used to store the opinion points
online = 5039, --Used to store online minutes
autoOpinion = function(cid)
if not isPlayer(cid) then return true end
doCreatureSetStorage(cid, rep.online, getCreatureStorage(cid, rep.online)+1)
if getCreatureStorage(cid, rep.online) >= rep.interval then
doCreatureSetStorage(cid, rep.online, 0)
doSendAnimatedText(getThingPos(cid), '+1', TEXTCOLOR_LIGHTBLUE)
doCreatureSetStorage(cid, rep.opinion, getCreatureStorage(cid, rep.opinion)+1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You have just obtained an opinion point.')
end
repEvent = addEvent(rep.autoOpinion, 60 * 1000, cid)
end,
getArticle = function(cid, uppercase)
return (getPlayerSex(cid) == 0 and (uppercase and 'Sh' or 'sh') or (uppercase and 'H' or 'h')) .. 'e'
end,
getPoints = function(cid)
local result = db.getResult('SELECT `rep` FROM `players` WHERE `id` = '.. getPlayerGUID(cid))
local data = result:getDataInt('rep')
result:free()
return data
end,
getPower = function(points)
local power = {{0,1},{300,2},{500,3},{1000,4},{1500,5},{2000,6},{5000,7}}
table.sort(power, function(a, b) return a[1] > b[1] end)
for _, t in ipairs(power) do
if math.abs(points) >= t[1] then
return t[2]
end
end
return power[1][2]
end,
getRank = function(points)
local ranks = {
{-5000, 'Power Abuser (*<<==========)'},
{-2000, 'Evil (=*<==========)'},
{-1500, 'Slayer (==*==========)'},
{-1000, 'Killer (===|=========)'},
{-500, 'Villain (====|========)'},
{-300, 'Creeping (=====|=======)'},
{0, 'Unknown (======|======)'},
{300, 'Avowed (=======|=====)'},
{500, 'Popular (========|====)'},
{1000, 'Hailed (=========|===)'},
{1500, 'Acclaimed (==========+==)'},
{2000, 'Hero (==========>+=)'},
{5000, 'Legend (==========>>+)'}
}
if points > -1 then
table.sort(ranks, function(a, b) return a[1] > b[1] end)
for _, t in ipairs(ranks) do if points >= t[1] then return t[2] end end
else
table.sort(ranks, function(a, b) return a[1] < b[1] end)
for _, t in ipairs(ranks) do if points <= t[1] then return t[2] end end
end
return ranks[1][2]
end,
set = function(cid, points)
db.executeQuery('UPDATE `players` SET `rep` = ' .. points .. ' WHERE `id` = ' .. getPlayerGUID(cid))
end,
add = function(cid, amount, color)
db.executeQuery('UPDATE `players` SET `rep` = `rep` + ' .. amount .. ' WHERE `id` = ' .. getPlayerGUID(cid))
doSendAnimatedText(getThingPos(cid), '+REP', color and color or math.random(255))
doPlayerSendCancel(cid, 'You have just been hailed and gained '.. amount ..' reputation points.')
end,
remove = function(cid, amount, color)
db.executeQuery('UPDATE `players` SET `rep` = `rep` - ' .. amount .. ' WHERE `id` = ' .. getPlayerGUID(cid))
doSendAnimatedText(getThingPos(cid), '-REP', color and color or math.random(255))
doPlayerSendCancel(cid, 'You have just been repudiated and lost '.. amount ..' reputation points.')
end,
format = function(str)
str = tostring(str):reverse()
str = str:gsub("(%d)(%d)(%d)", '%1%2%3' .. (',' or ' '), math.ceil(str:len() / 3)-1)
return str:reverse()
end,
}
]]></config>
<globalevent name="rep_start" type="start" event="script"><![CDATA[
domodlib('repSystem')
function onStartup()
if getGlobalStorageValue(rep.update) == EMPTY_STORAGE then
setGlobalStorageValue(rep.update, 1)
local query = db.getResult("SELECT `rep` FROM `players` LIMIT 1;")
if isInArray({-1,'',nil,false},query:getID()) then
print('>> [REP_SYSTEM] Installing Reputation System...Ignore error from above...')
db.executeQuery("ALTER TABLE `players` ADD COLUMN `rep` INT( 11 ) NOT NULL DEFAULT '0' COMMENT 'Cyber''s REPSystem © OTLand.net';")
print('>> [REP_SYSTEM] System successfully installed.')
else
print('>> [REP_SYSTEM] Updating Reputation System...')
db.executeQuery("ALTER TABLE `players` CHANGE COLUMN `rep` `rep` INT( 11 ) NOT NULL DEFAULT '0' COMMENT 'Cyber''s REPSystem © OTLand.net';")
print('>> [REP_SYSTEM] System successfully updated.')
end
query:free()
end
print('>> [REP_SYSTEM] Current Revision: 5.1')
print('>> [REP_SYSTEM] Reputation System successfully loaded.')
return true
end
]]></globalevent>
<event type="login" name="repRegister" event="script"><![CDATA[
domodlib('repSystem')
function onLogin(cid)
addEvent(rep.autoOpinion, 60 * 1000, cid)
if getCreatureStorage(cid, rep.opinion) == EMPTY_STORAGE then
doCreatureSetStorage(cid, rep.online, 0)
doCreatureSetStorage(cid, rep.opinion, 0)
end
registerCreatureEvent(cid, "repLook")
registerCreatureEvent(cid, "repKill")
registerCreatureEvent(cid, "repMonster")
return true
end
]]></event>
<event type="logout" name="repCancel" event="script"><![CDATA[
domodlib('repSystem')
function onLogout(cid)
stopEvent(repEvent)
return true
end
]]></event>
<event type="look" name="repLook" event="script"><![CDATA[
domodlib('repSystem')
function onLook(cid, thing, position, lookDistance)
if isPlayer(thing.uid) then
doPlayerSetSpecialDescription(thing.uid,'\n' .. (thing.uid == cid and 'You are' or rep.getArticle(thing.uid, true) .. ' is') .. ' ' .. rep.getRank(rep.getPoints(thing.uid)))
end
return true
end]]>
</event>
<event type="kill" name="repKill" event="script"><![CDATA[
domodlib('repSystem')
local t = {
[SKULL_WHITE] = 15,
[SKULL_RED] = 30,
[SKULL_BLACK] = 45,
[SKULL_NONE] = -30,
}
function onKill(cid, target, lastHit)
if isPlayer(cid) and isPlayer(target) and getPlayerIp(cid) ~= getPlayerIp(target) and getCreatureStorage(cid, rep.lastKilled) ~= getPlayerGUID(target) then
--THE KILLER
if t[getCreatureSkullType(target)] and getPlayerLevel(target) >= rep.pvpLevel then
doSendAnimatedText(getThingPos(cid), getCreatureSkullType(target) == 0 and '-REP' or '+REP', math.random(255))
doCreatureSetStorage(cid, rep.lastKilled, getPlayerGUID(target))
rep.set(cid, rep.getPoints(cid)+t[getCreatureSkullType(target)])
doPlayerSendCancel(cid, 'You '.. (getCreatureSkullType(target) == 0 and 'lose' or 'gain') ..' reputation because you killed a player.')
end
--THE VICTIM
if rep.getPoints(target) == 0 then
return true
elseif rep.getPoints(target) > 0 then
rep.remove(target, 5, TEXTCOLOR_RED)
doPlayerSendCancel(target, 'You lose reputation because you were killed by a player.')
else
rep.add(target, 5, TEXTCOLOR_LIGHTBLUE)
doPlayerSendCancel(target, 'You lose reputation because you were killed by a player.')
end
end
return true
end]]>
</event>
<event type="kill" name="repMonster" event="script"><![CDATA[
domodlib('repSystem')
local monster = {
['demon'] = 3,
['behemoth'] = 4,
['hellfire fighter'] = 5,
['orshabaal'] = 10,
}
function onKill(cid, target, lastHit)
if not isPlayer(cid) or not isMonster(target) or not monster[string.lower(getCreatureName(target))] then
return true
end
rep.add(cid, monster[string.lower(getCreatureName(target))])
return true
end]]>
</event>
<talkaction log="yes" words="/hail;/fuck;/set" access="4" event="buffer">
<![CDATA[
domodlib('repSystem')
if param == '' then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,'[REP_SYSTEM] You must write a player\'s name.')
return true
end
local t = string.explode(param, ',')
local tid = getPlayerByNameWildcard(t[1])
if not isPlayer(tid) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] Player ' .. param .. ' not found.')
return true
end
if not t[2] and isPlayer(tid) then
if words == '/hail' then
rep.add(tid, 5, TEXTCOLOR_TEAL)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] You added +5 rep points to ' .. getPlayerName(tid) .. ', and now ' .. rep.getArticle(tid, false) .. ' has ' .. rep.getPoints(tid) .. ' points.')
return true
end
if words == '/fuck' then
rep.remove(tid, 5, TEXTCOLOR_RED)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] You removed -5 rep points to ' .. getPlayerName(tid) .. ', and now ' .. rep.getArticle(tid, false) .. ' has ' .. rep.getPoints(tid) .. ' points.')
return true
end
end
if t[2] and isInArray({'/set','/hail','fuck'}, words) then
if not tonumber(t[2]) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] Reputation amount is invalid.')
return true
end
end
if words == '/hail' then
rep.add(tid, t[2], TEXTCOLOR_TEAL)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] You added ' .. t[2] .. ' rep points to ' .. getPlayerName(tid) .. ', and now ' .. rep.getArticle(tid, false) .. ' has ' .. rep.getPoints(tid) .. ' points.')
return true
end
if words == '/fuck' then
rep.remove(tid, t[2], TEXTCOLOR_RED)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] You removed ' .. t[2] .. ' rep points to ' .. getPlayerName(tid) .. ', and now ' .. rep.getArticle(tid, false) .. ' has ' .. rep.getPoints(tid) .. ' points.')
return true
end
if t[2] and words == '/set' then
rep.set(tid, t[2])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] You have set ' .. getPlayerName(tid) .. '\'s points to ' .. rep.getPoints(tid))
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] Absolute reputation amount not specified.')
return true
end
if not t[2] then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, '[REP_SYSTEM] Absolute reputation amount not specified.')
return true
end
return true]]>
</talkaction>
<talkaction words="!ranks" event="buffer"><![CDATA[
domodlib('repSystem')
local str, value, name, result, forbidden = '','','',0,nil,'Account Manager'
if isInArray({'hero','pos','1','+'}, param) then
str,value,name = '[#]-[Name]-[Points]-[Rank]\n--[Positive Reputation Highscores]--\n','rep','name'
result = db.getResult('SELECT `name`, `rep` FROM `players` WHERE `rep` > 0 AND `name` NOT LIKE "%Sample" AND `name`!= "Account Manager" AND `deleted` = 0 AND `group_id` = 1 ORDER BY `rep` DESC LIMIT 10;')
elseif isInArray({'evil','neg','2','-'}, param) then
str,value,name = '[#]-[Name]-[Points]-[Rank]\n--[Negative Reputation Highscores]--\n','rep','name'
result = db.getResult('SELECT `name`, `rep` FROM `players` WHERE `rep` < 0 AND `name` NOT LIKE "%Sample" AND `name`!= "Account Manager" AND `deleted` = 0 AND `group_id` = 1 ORDER BY `rep` ASC LIMIT 10;')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Unknown parameter, use only +, -, 1, 2.')
return true
end
if isInArray({-1,nil,false,''},result:getID()) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'No results were found.')
return true
end
local i = 1
while true do
str = str .. '\n ' .. i .. '. ' .. result:getDataString('name') .. ' - [' .. result:getDataInt(value) .. '] - ' .. rep.getRank(result:getDataInt(value))
i = i + 1
if not(result:next()) then
break
end
end
result:free()
doPlayerPopupFYI(cid, str)
return true]]>
</talkaction>
<talkaction words="!rep" event="buffer"><![CDATA[
domodlib('repSystem')
local points, action, name = rep.getPoints(cid), false, getPlayerNameByGUID(getCreatureStorage(cid, rep.lastName), false, false)
doPlayerSendTextMessage(cid, 19, 'You have ' .. rep.format(points) .. ' reputation points. You are ' .. rep.getRank(points) .. '. Your Rep Power is ' .. rep.getPower(points) ..'.\nYou have ' .. getCreatureStorage(cid, rep.opinion) .. ' opinion points and you will gain one '.. (getCreatureStorage(cid, rep.opinion) > 0 and 'more ' or '') ..'in '.. rep.interval - getCreatureStorage(cid, rep.online) ..' minutes.' .. (name ~= nil and ' You last reputed ' .. name .. '.' or ''))
if points > 4999 then --female rep+++ queen outfit
disguise, text, action = getPlayerSex(cid) == 0 and 331 or 332, getPlayerSex(cid) == 0 and 'Queen!!' or 'King!!', true
elseif points > 1999 then --rep++ cm outfit
disguise, text, action = 73, 'Hero!!', true
elseif points > 1499 then --rep+ hero outfit
disguise, text, action = 63, 'Acclaimed!!', true
elseif points < -4999 then --rep*** devil outfit
disguise, text, action = 334, 'P.O.!', true
elseif points < -1999 then --rep** pig outfit
disguise, text, action = 306, 'Evil!!', true
elseif points < -1499 then --rep* orc outfit
disguise, text, action = 5, "Slayer!!", true
end
if action and getCreatureOutfit(cid).lookType ~= disguise then
doSetCreatureOutfit(cid, {lookType = disguise}, -1)
doSendAnimatedText(getThingPos(cid), text, math.random(255))
return true
end
return true]]>
</talkaction>
<talkaction words="!hail;!fuck" event="buffer"><![CDATA[
domodlib('repSystem')
if param == '' then
doPlayerSendCancel(cid, 'Command requires a player\'s name.')
return true
end
local target = getPlayerByNameWildcard(param)
if not isPlayer(target) then
doPlayerSendCancel(cid, 'That player does not exist or is offline.')
return true
end
if getPlayerLevel(cid) < rep.minLevel then
doPlayerSendCancel(cid,'You may repute from level ' .. rep.minLevel ..' onwards.')
return true
end
if getPlayerIp(cid) == getPlayerIp(target) then
doPlayerSendCancel(cid, 'You may not repute neither yourself nor anyone in your IP.')
return true
end
if getPlayerGUID(target) == getCreatureStorage(cid, rep.lastName) then
doPlayerSendCancel(cid, 'You may not repute that player two times in a row.')
return true
end
if getCreatureStorage(cid, rep.opinion) < rep.required then
doPlayerSendCancel(cid, 'You do not have enough opinion points to repute.')
return true
end
if words == '!hail' then
rep.add(target, rep.getPower(rep.getPoints(cid)), TEXTCOLOR_LIGHTBLUE)
doCreatureSetStorage(cid, rep.lastName, getPlayerGUID(target))
doCreatureSetStorage(cid, rep.opinion, getCreatureStorage(cid, rep.opinion)-rep.required)
doPlayerSendCancel(cid, 'You have just reputed ' .. getCreatureName(target) .. '. You have ' .. getCreatureStorage(cid, rep.opinion) .. ' opinion points left.')
elseif words == '!fuck' then
rep.remove(target, rep.getPower(rep.getPoints(cid)), TEXTCOLOR_RED)
doCreatureSetStorage(cid, rep.lastName, getPlayerGUID(target))
doCreatureSetStorage(cid, rep.opinion, getCreatureStorage(cid, rep.opinion)-rep.required)
doPlayerSendCancel(cid, 'You have just reputed ' .. getCreatureName(target) .. '. You have ' .. getCreatureStorage(cid, rep.opinion) .. ' opinion points left.')
end
return true
]]></talkaction>
</mod>
[==============================================================]
|Cyber's REPutation System. Rev6.0 |
|Scripted for TFS 0.3.6 && 0.4, by Cybermaster |
|Credits: Sync,Shawak,Chris,nsanee |
|© OTLand.net |
|==============================================================|
Revision 6.0 Update Log
======================>
-Code slightly reduced.
-Deprecated Rep getTime function.
-New feature: Opinion Points.
-Function onLook updated, to show your rep at your description.
-Added exhaust for commands.
-Rep Power Feature is optional by default.
-Added autosetup globalevent, no need to execute queries at phpmyadmin.
-Deprecated Skulls Limitation when killing for rep.
-Added "SameIP" when killing for rep.
-Fixed Rep Highscores talkaction command.
-Added "lastKilled" when killing for rep.
-Added Modern AAC compat., highscores and injection included.
-New Rep Stripes made by 5mok3.
-Pictures for PHP Scripts are hosted at Cyber's tinypic repository.
-Upgraded highscores queries, players with 0 rep are not ranked.
-Enhanced PHP Script for Gesior AAC.
donewith so much changes and new feature, it should be 6.0
I shall post it now