• Hook not called
    4 replies, posted
The code itself worked in single player, so I'm suspecting the file was not properly included serverside? [B]lua/autorun/q3points.lua:[/B] [CODE]if SERVER then AddCSLuaFile() include "q3points/sv_init.lua" end[/CODE] [B]lua/q3points/sv_init.lua:[/B] [CODE]--======================= GIVE POINTS AFTER MATCH ENDS ====================================== function scorePoints( pl, attacker, dmginfo ) if ( attacker:IsValid() && attacker:IsPlayer() ) then if ( attacker == pl ) or (GAMEMODE.TeamBased and attacker:Team() == pl:Team()) then if(attacker ~= pl) then attacker:PS_TakePoints(5) v:PS_Notify("-5 " .. PS.Config.PointsName .. " for team killing") end else local frags = attacker:Frags() if GAMEMODE.TeamBased then frags = team.TotalFrags(attacker:Team()) end local fraglimit = GetConVarNumber("q3_fraglimit") if( frags >= fraglimit ) then --If a player reaches fraglimit and the match ends for k,v in ipairs(player.GetAll()) do --Find all players and give points frags = v:Frags() if frags > 0 then --praise player and give points if score is good local points = math.Round( frags/fraglimit * (fraglimit+5) * 4 ) --max +60 on 10 fraglimit, +100 on 20, +140 on 30, and so on if( frags >= fraglimit) then points = points + fraglimit * 2 --bonus if player wins v:PS_Notify("+" .. points .. " " .. PS.Config.PointsName .. " for winning the match!") else v:PS_Notify("+" .. points .. " " .. PS.Config.PointsName .. " for your performance this match") end v:PS_GivePoints(points) else local points = math.Clamp(frags*10, -10, 0) v:PS_TakePoints(math.abs(points)) v:PS_Notify(points .. " " .. PS.Config.PointsName .. " for your poor performance this match") end end --player for loop ends here-- end end end end hook.Add( "DoPlayerDeath", "givePointsOnScore", scorePoints )[/CODE]
Are you getting any AddCSLuaFile/include errors? This has happened to me before, it thinks the file doesn't exist.
I had the same thought, but did not see any errors in the server log.
Try calling AddCSLuaFile from different locations
I found the issue: The hook was being called, however the function was called before the gamemode function that gives the player frags, so the "frags" variable in my script was 1 lower. A short timer should fix it
Sorry, you need to Log In to post a reply to this thread.