Okay first of all this appears only on mysql storing of userranks. We need this because of many ranks which were given to the user.txt (~20k entries), causing huge lags when promoting someone.
The problem is that when we changed to some specific maps we encountered the promotion of our staff and vips to other ranks because they were still declared as user (which will be promoted after some hours) while connecting to the server. This was saved in the database.
I changed checkPlayer() and added an initial spawn hook in sv_apromote.lua to pass some time before the promotion system handles the freshly connected user
local function checkPlayer( ply )
if ply.check_time < 6 then
ply.check_time = ply.check_time + 1
else
local plyhours = math.floor( ply:GetUTimeTotalTime() / 3600 )
local usrgrp = ply:GetUserGroup()
local Rank = ""
local Hours = 0
for k, v in pairs( APromote["grp"] ) do
if plyhours >= tonumber( v ) and tonumber( v ) >= Hours then
if tonumber( v ) >= 0 then
Rank = k
Hours = tonumber( v )
end
end
end
if (!ply:IsUserGroup(Rank) and Rank != "") then
if tonumber( APromote["grp"][usrgrp]) != -1 then
if not tobool( GetConVarNumber( "ap_auto_demote" ) ) and APromote["grp"][usrgrp] != nil
and Hours < tonumber( APromote["grp"][usrgrp] ) then
return
else
if ply:IsConnected() then
RunConsoleCommand( "ulx", "adduser", ply:Nick(), Rank )
PlayRankSound( ply )
end
end
end
end
end
end
hook.Add( "PlayerInitialSpawn", "check_time_set", function( ply )
ply.check_time = 0
end)
May not be very professional but its working for us scince 3 days now. Please tell me if I just had luck and I'm writing bullshit right now xD