• Killstreak Modifier| A Garry's Mod Killstreak System
    2 replies, posted
Welcome to KSM, a simple Killstreak addon that comes with pre-downloaded sounds for all players when reaching a certain killing streak. If you don't know what a STREAK is, its something that happens over and over again, for example; someone kills another player and continues killing other players without dying (Kill Streak) This addon allows you to add custom sounds, custom functions after a player gets a kill and a very simple kill streak tracker. The github repository explains how to use this addon, download below. [URL="https://github.com/JacobsReturn/KillstreakModifier"]https://github.com/JacobsReturn/KillstreakModifier[/URL] Please leave feedback! Thanks, Jacob.
Good start, but a few suggestions to improve the script: [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua"] This file should be in lua/autorun/server, or ran serverside in some fashion.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L1-L4"]You don't have to include/AddCSLuaFile files in lua/autorun/*.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L8-L10"]You only have to resource.AddSingleFile the sound/ directory files - not all three paths.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L16"]You also have to check if the attacker is a player in this function - it could be the world, an NPC, or even NULL if the attacker was not set in the damage info.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L23-L24"]string.Replace already handles if the sub-string wasn't found - you don't have to have the string.find checks.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L28"]Just network directly to the client and tell them to play the sound - sending the code string is unneeded.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L34"]You can cache this since the table shouldn't change during gameplay.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L42"]You can also just ping the client to display the message since the config table is shared.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sh_ksm.lua#L87"]If you allow this to repeat, once a player reach 12 kills, they'll easily be able to snowball and get a ton of health.[/URL] Really, the entire loop can be eliminated if at hook creation time you re-arrange the config table into a separate numerically-indexed array that contains the kill data into tModifiers[streak] = {display message, sound}. You'll also want to consider if you want [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSilentDeath]GM:PlayerSilentDeath[/url] to be included in resetting the streak.
[QUOTE=code_gs;52847116]Good start, but a few suggestions to improve the script: [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua"] This file should be in lua/autorun/server, or ran serverside in some fashion.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L1-L4"]You don't have to include/AddCSLuaFile files in lua/autorun/*.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L8-L10"]You only have to resource.AddSingleFile the sound/ directory files - not all three paths.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L16"]You also have to check if the attacker is a player in this function - it could be the world, an NPC, or even NULL if the attacker was not set in the damage info.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L23-L24"]string.Replace already handles if the sub-string wasn't found - you don't have to have the string.find checks.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L28"]Just network directly to the client and tell them to play the sound - sending the code string is unneeded.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L34"]You can cache this since the table shouldn't change during gameplay.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sv_ksm.lua#L42"]You can also just ping the client to display the message since the config table is shared.[/URL] [URL="https://github.com/JacobsReturn/KillstreakModifier/blob/master/lua/autorun/sh_ksm.lua#L87"]If you allow this to repeat, once a player reach 12 kills, they'll easily be able to snowball and get a ton of health.[/URL] Really, the entire loop can be eliminated if at hook creation time you re-arrange the config table into a separate numerically-indexed array that contains the kill data into tModifiers[streak] = {display message, sound}. You'll also want to consider if you want [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/PlayerSilentDeath]GM:PlayerSilentDeath[/url] to be included in resetting the streak.[/QUOTE] Thanks for the feedback! I'll fix some things up. And the 12 kills is just an example of what the player can do :P, thanks Code.
Sorry, you need to Log In to post a reply to this thread.