Hello, well i posted this on Facepunch but they are such helpers..no one replied..so i'll try to post here, hoping someone could help me:
I'm trying to modify the ratings (the icons in the scoreboard).
So i did this in gamemode/rating.lua:
local function CCRateUser( player, command, arguments )
...
// Don't rate self
//original if ( Rater == Target ) then return end
if ( Rater == Target ) then
SendNotify( Rater, "You can't rate yourself, dude :)", ERROR )
return
end
...
And to get it working i did that in gamemode/scoreboard/vote_button.lua:
function PANEL:DoClick( x, y )
local ply = self:GetParent().Player
//original if ( !ply || !ply:IsValid() || ply == LocalPlayer() ) then return end
if ( !ply || !ply:IsValid() ) then return end
LocalPlayer():ConCommand( "rateuser ".. ply:EntIndex().. " "..self.VoteName.."\n" )
end
My function SendNotify is in the file in gamemode/rating.lua:
//define types
SUCCESS = 1
ERROR = 2
local function SendNotify( ply, message, type )
if (!type) then type = SUCCESS end
if (type == SUCCESS) then
notify_type = "NOTIFY_GENERIC"
notify_sound = "ambient/water/drip" .. math.random(1, 4) .. ".wav"
elseif (type == ERROR) then
notify_type = "NOTIFY_ERROR"
notify_sound = "buttons/button10.wav"
end
ply:SendLua( "GAMEMODE:AddNotify( \"" .. message .. "\", " .. notify_type .. ", 5 ); surface.PlaySound( \"" .. notify_sound .. "\" )" )
end
All seems to work fine, however as i said in the topic title, there is a bug. And even two bugs.
The first bug: i go in the spawn menu and i choose any tool that contain a box where we can enter numbers or whatever. Whenever i write a number in this box, then press Enter, it brings the message "You can't rate yourself, dude
"...pretty annoying.
The second bug is more annoying..for some reasons, ratings stop working after a moment, and i can't find how to reproduce this bug. Like if the rating.lua has crashed, when i press a rating button nothing happen, not even a 'rateuser: unknow command' in the console.
I'm beginner with lua. For the first bug, i think about a way to check if the player is in the spawn menu, like 'if player:InSpawnMenu() then return end'..is it possible? What i do wrong?
If there is nothing wrong in that code and you want to see full files, they are in my pastebin:
gamemode/rating.lua gamemode/scoreboard/vote_button.luaPlease help, thanks in advance.
PS: also, the first bug exists in ULX too (almost the same bug), i mean : try to double click a file in the advanced duplicator file list, it will execute the last ULX command you did.
REPS: after reading this topic
http://forums.ulyssesmod.net/index.php/topic,1073.0/topicseen.html i believe it's the bug i'm talking about