--Selfkill penalty script --Infilicts penalties in ammo and health on players who selfkill --Soldiers immune to penalties in this version --many thanks to GhosT:Rabid for his help in building the class/weapon table --version: v1.1 --by GhosT:McSteve, 25/11/06 --set the selfkill limit here, if selfkills > selfkill_limit, penalties incurred selfkill_limit = 0 --on game initialise, get the maxclients and initialise the skcount array function et_InitGame( levelTime, randomSeed, restart ) --called on game initialise maxclients = tonumber( et.trap_Cvar_Get( "sv_maxClients" ) ) --gets the maxclients skcount = {} for i = 0, maxclients - 1 do skcount[i] = 0 end end --on client disconnect, empty the skcount for that slot function et_ClientDisconnect( clientNum ) skcount[clientNum] = 0 end --on a player death, check the meansofdeath and increment skcount if player selfkilled function et_Obituary( victim, killer, meansOfDeath ) --check the player's class (sess.playerType) cno_class = et.gentity_get(victim, "sess.playerType") if cno_class == 0 then return 0 end --do not add to skcount if player is a soldier --if selfkill (=37) then increment skcount for the client if meansOfDeath == 37 then skcount[victim] = skcount[victim] + 1 --issue warnings on death rather than on spawn as in previous version if skcount[victim] == 1 then et.trap_SendServerCommand( victim, "cp \"^1Warning, your next selfkill will incur a penalty.\n\"" ) elseif skcount[victim] > 1 then et.trap_SendServerCommand( victim, "cp \"^1Selfkills = " .. skcount[victim] .. " ^1, penalty incurred\n\" " ) end end end --on a player spawn, set any selfkill punishments function et_ClientSpawn(cno, revived) if skcount[cno] == 0 then return 0 end --if player's skcount = 0 then do nothing --check the player's class (sess.playerType) cno_class = et.gentity_get(cno, "sess.playerType") if cno_class == 0 then return 0 end --if a player's class is soldier (0) then do nothing if revived == 0 then -- if player was NOT revived then perform chunk -- check the player's weapon weapon = et.gentity_get(cno, "s.weapon") --check the player's ammo cno_ammo = et.gentity_get(cno, "ps.ammo", weapon) cno_ammoclip = et.gentity_get(cno, "ps.ammoclip", weapon) -- skcount = 1, warning only if skcount[cno] == (selfkill_limit + 1) then --nothing needed here end -- skcount = 2, -1/2 clip of ammo if skcount[cno] == (selfkill_limit + 2) then --set the new conditions pen_ammoclip = cno_ammoclip - (cno_ammoclip/2) pen_ammo = cno_ammo et.gentity_set(cno, "ps.ammoclip", weapon, pen_ammoclip) et.gentity_set(cno, "ps.ammo", weapon, pen_ammo) end -- skcount = 3, -1 clip of ammo if skcount[cno] == (selfkill_limit + 3) then --set the new conditions pen_ammoclip = 0 pen_ammo = cno_ammo et.gentity_set(cno, "ps.ammoclip", weapon, pen_ammoclip) et.gentity_set(cno, "ps.ammo", weapon, pen_ammo) end -- skcount = 4, -1 1/2 clips of ammo if skcount[cno] == (selfkill_limit + 4) then --set the new conditions pen_ammoclip = 0 pen_ammo = cno_ammo - (cno_ammo/2) et.gentity_set(cno, "ps.ammoclip", weapon, pen_ammoclip) et.gentity_set(cno, "ps.ammo", weapon, pen_ammo) end -- skcount = 5, -1 2/3 clips of ammo + set health to 70 HP if skcount[cno] == (selfkill_limit + 5) then --set the new conditions pen_ammoclip = 0 pen_ammo = cno_ammo - (2*cno_ammo/3) et.gentity_set(cno, "ps.ammoclip", weapon, pen_ammoclip) et.gentity_set(cno, "ps.ammo", weapon, pen_ammo) et.gentity_set(cno, "health", 70) end -- skcount = 6, - all ammo + set health to 10 HP if skcount[cno] == (selfkill_limit + 6) then --set the new conditions pen_ammoclip = 0 pen_ammo = 0 et.gentity_set(cno, "ps.ammoclip", weapon, pen_ammoclip) et.gentity_set(cno, "ps.ammo", weapon, pen_ammo) et.gentity_set(cno, "health", 10) end -- skcount > 6, - all ammo + set health to 10 HP if skcount[cno] > (selfkill_limit + 6) then --set the new conditions pen_ammoclip = 0 pen_ammo = 0 et.gentity_set(cno, "ps.ammoclip", weapon, pen_ammoclip) et.gentity_set(cno, "ps.ammo", weapon, pen_ammo) et.gentity_set(cno, "health", 10) end end end