ULX

Author Topic: Anti-suicide plugin  (Read 16066 times)

0 Members and 1 Guest are viewing this topic.

Offline Vakaris

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Anti-suicide plugin
« on: September 25, 2009, 04:19:28 AM »
I noticed that in my server the suicide command, kill, is just annoying. I made a small lua script to return false to the suicide atempt along with a messange to contact an admin if they're stuck. My small script got broken recently and I couldn't get it to work propperly again. This is where ULX comes in, I am here to request a plugin made for ULX/Ulib to disable the kill command by default for all users and admins alike (we still have the slay and the sslay commands and cna use them if nesessary).

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Anti-suicide plugin
« Reply #1 on: September 25, 2009, 03:26:41 PM »
I'm curious.... why do you find suicide in a Gmod game server annoying?
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Vakaris

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Re: Anti-suicide plugin
« Reply #2 on: September 25, 2009, 03:29:05 PM »
I'm curious.... why do you find suicide in a Gmod game server annoying?

I host a SB2 server with PvP damage enabled. It's annying for someone to bind kill to a key and use it just before death. Also I like to make bases, tarps, all sorts of player manipulation gizmoes, the suicide command sort of ruins most of this...

Offline atomicspark

  • Full Member
  • ***
  • Posts: 196
  • Karma: 12
Re: Anti-suicide plugin
« Reply #3 on: September 25, 2009, 03:58:40 PM »
I've seen this before... somewhere. In any case, an add-on like this wouldn't require ULX, let alone ULib (unless you wanted group overrides). Maybe you could post your original code and people that know Lua could take a look at it?

Offline Vakaris

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Re: Anti-suicide plugin
« Reply #4 on: September 25, 2009, 04:02:49 PM »
Sure... I'll find it in a minute...

Ok here it is:
C:\Program Files\Steam\SteamApps\MyUserName\Garrysmod\Garrysmod\Lua\Autorun\Server\blocksuicide.lua

Code: [Select]
function NoSuicide( ply )
ply:PrintMessage( HUD_PRINTTALK, "Suicide has been disabled, contact an online admin for support if needed.")
return false
end

hook.Add( "CanPlayerSuicide", "Suicide", NoSuicide )
« Last Edit: September 25, 2009, 04:05:46 PM by Vakaris »

Offline atomicspark

  • Full Member
  • ***
  • Posts: 196
  • Karma: 12
Re: Anti-suicide plugin
« Reply #5 on: September 25, 2009, 04:46:10 PM »
I can't remember where I saw this before. It might even be a gamemode setting...

Offline Vakaris

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Re: Anti-suicide plugin
« Reply #6 on: September 25, 2009, 04:56:46 PM »
I got a part of this code from some german website (used a translator), the other part I made up by my self and added the notification messange. It worked perfectly, but later I think an update broke the code... Same as Uclip...

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Anti-suicide plugin
« Reply #7 on: September 25, 2009, 05:59:21 PM »
See ULX's lib.lua file. It has a function that prevents death.
Use it's function along with a message.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Vakaris

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Re: Anti-suicide plugin
« Reply #8 on: September 25, 2009, 06:08:39 PM »
See ULX's lib.lua file. It has a function that prevents death.
Use it's function along with a message.

Looked at the file, it seems it's on what the wonders sslay feeds on for power... But I couldn't figure out how to properly merge it with my function (look above for refference). Also, jsut that we're clear, I'm looking for a script or something the could prevent suicide command, but would still allow the player to die from prop physics, PvP damage, suffocation in space, etc. and most imporatantly wouldn't be immune to (s)slay commands. It's getting late here... Ok basicly it's morning - 04:07, I'm going to get some sleep and continue on the matter after that, feel free to post sugestiongs, help, etc. I'll check when I wake up.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Anti-suicide plugin
« Reply #9 on: September 25, 2009, 07:25:28 PM »
You're script should work.
Only reason I can think would be another mod that uses the same hook being done badly.
You mentioned in another post Gcombat. I've seen posts of Gcombat breaking certain functions of ULX, and atomicspark mentioned it being a mess.
Gcombat may not be the issue, but, search your other mods for the text "CanPlayerSuicide"
I'm betting one of them is returning something when it shouldn't be.

The function I was talking about in lib.lua are checkDeath and checkSuicide.
We use them both for during punishments where we don't want the person to kill themselves.
Jail, Maul, just to name a few. :)
« Last Edit: September 25, 2009, 07:31:02 PM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline atomicspark

  • Full Member
  • ***
  • Posts: 196
  • Karma: 12
Re: Anti-suicide plugin
« Reply #10 on: September 25, 2009, 08:01:40 PM »
Gcombat doesn't break... oh nevermind. Are we sure that Garry's Mod doesn't have a gamemode setting for this?

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Anti-suicide plugin
« Reply #11 on: September 25, 2009, 09:50:37 PM »
Gcombat doesn't break... oh nevermind. Are we sure that Garry's Mod doesn't have a gamemode setting for this?
Old versions _did_ break some ULX features...at the time.
http://forums.ulyssesmod.net/index.php/topic,4000.0.html
I only imagine the nightmare of one contributor adding on then another then another.
It's one thing to have one main lead guide several developers (as in Ulysses projects), totally another to have possibly bad re-writes.

Either way, I'm not familiar enough with the gamemode functions off the top of my head... it is possible.
My first inclination though would be that some mod is quite possibly returning true on the CanPlayerSuicide hook, breaking all others.

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline atomicspark

  • Full Member
  • ***
  • Posts: 196
  • Karma: 12
Re: Anti-suicide plugin
« Reply #12 on: September 25, 2009, 11:16:17 PM »
Is "CanPlayerSuicide" built into GMod?

Offline [WCA]AIDS

  • Jr. Member
  • **
  • Posts: 58
  • Karma: 7
    • PlanetWCA Forums
Re: Anti-suicide plugin
« Reply #13 on: September 26, 2009, 01:29:10 AM »

Offline Vakaris

  • Newbie
  • *
  • Posts: 31
  • Karma: 0
Re: Anti-suicide plugin
« Reply #14 on: September 26, 2009, 03:07:18 AM »
Ok so you think my GCombat may break the part? I use GCombat8 because GCombat9 (and GCX and TiberiumMod that came with it) are only a pain in the ass to reedit and/or delete. I run a ton of mods on my server - over 50 to be precise, easily any of them may conflict with the others, but unless anyone else can confirm the script works for them I don't know if I should do a searth on over a million files stacking up to over 5 GB. If anyone needs the full list of my mods then say so.