potinho
Intermediate OT User
Hello everyone, everything good? I put a reputation system on my server, to encourage the creation of a friendly atmosphere among players, giving rewards to those who achieve more points in this system, but players are managing to circumvent it, using VPN for example. The system checks the player's IP at first, are we able to put in other checks (like the player's own account) to ensure that a player only uses the reputation system once a day? Follow my system:
Lua:
local function file_exists(f)
local f = io.open("data/logs/repsystem/"..f..".txt", "rb")
if f then
f:close()
end
return f ~= nil
end
local function create_file(f, mode)
return io.open("data/logs/repsystem/"..f..".txt", mode)
end
local function convertTime(value)
local text = ""
if value then
local time = value
local hours, minutes, seconds = math.floor (time / 3600), math.floor ((time - ((math.floor (time / 3600)) * 3600))/ 60), time - ((math.floor (time/60)) * 60)
if time >= 3600 then
text = hours.." hour and "..minutes.." minutes"
elseif time >= 60 then
text = minutes.." minutes and "..seconds.." seconds"
else
text = seconds.." seconds"
end
end
return text
end
function onSay(cid, words, param, channel)
local blockTime = 1 * 24 * 60 * 60
if(param == '') then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Player name is missing.")
return true
end
local reputationStr = 144712
local pid = getCreatureByName(param)
if not isPlayer(pid) then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Player "..param.." not found.")
end
if cid == pid then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You cannot add reputation to yourself.")
end
local playerIP = getPlayerIp(cid)
if file_exists(playerIP) then
local file = create_file(playerIP, "r")
local lastReputation = tonumber(file:read())
file:close()
if lastReputation > os.time() then
local remainTime = lastReputation - os.time()
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "You have to wait "..convertTime(remainTime).." to add reputation again.")
end
end
local file = create_file(playerIP, "w")
file:write(os.time() + blockTime)
file:close()
-- save player to update storages on website
doPlayerSave(pid)
setPlayerStorageValue(pid, reputationStr, math.max(0, tonumber(getPlayerStorageValue(pid, reputationStr))) + 1)
doPlayerSendTextMessage(pid, MESSAGE_STATUS_CONSOLE_BLUE, getCreatureName(cid).." has been sent you +1 reputation.")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have sent +1 reputation to "..getCreatureName(pid)..".")
return true
end