PDA

View Full Version : [CSS] Slay those who throw the bomb


banania
11-12-2011, 18:38
Hello,

I wonder if it was possible to make a script that slay people who throw the bomb.
I have a rush server and it's very disabling when someone throws the bomb, so I'd like to end this problem.



Sorry for my bad english :oops:

Impact123
11-12-2011, 21:43
I dont't think this is a good idea, but this should work for you.
Note: untested.

Yours sincerely
Impact

TnTSCS
11-13-2011, 00:05
Impact123 - that's a good one... You don't need Action: for your OnBombDropped though - just FYI


#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.0"

public Plugin:myinfo =
{
name = "Bomb Drop Slay",
author = "Impact123",
description = "Slays a player if they drop the bomb while alive",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
}

public OnPluginStart()
{
CreateConVar("sm_dropbombslay_version", PLUGIN_VERSION, "Drop Bomb Slay Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FC VAR_NOTIFY|FCVAR_DONTRECORD);

HookEvent("bomb_dropped", OnBombDropped);
}

public OnBombDropped(Handle:event, String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));

if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
{
ForcePlayerSuicide(client);
}
}


banania - might I suggest using a timer... if a player drops the bomb, have a msg displayed to the user that dropping the bomb is not allowed and they have X seconds to pick it back up or they will get slayed?

And what if the player is just giving the bomb to another player?

I'll work on it more tomorrow, but here's something close... I just need to code to kill the timer when the bomb is picked up by another player instead of using the bool... or maybe Impact can finish it :)


#pragma semicolon 1

#include <sourcemod>
#include <sdktools>

#define PLUGIN_VERSION "1.0"

new Handle:ClientTimer[MAXPLAYERS+1] = INVALID_HANDLE;

new bool:BombDropped = false;

public Plugin:myinfo =
{
name = "Bomb Drop Slay",
author = "Impact123",
description = "Slays a player if they drop the bomb while alive",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net"
}

public OnPluginStart()
{
CreateConVar("sm_dropbombslay_version", PLUGIN_VERSION, "Drop Bomb Slay Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FC VAR_NOTIFY|FCVAR_DONTRECORD);

HookEvent("bomb_dropped", OnBombDropped);
HookEvent("bomb_pickup", OnBombPickedup);
HookEvent("player_death", OnPlayerDeath);
}

public OnBombDropped(Handle:event, String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));

if(IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client))
{
//ForcePlayerSuicide(client);
ClientTimer[client] = CreateTimer(10.0, t_BombDropSlay, client);
PrintToChat(client, "[SM] The bomb must be picked back up in 10 seconds or you will be slayed");
BombDropped = true;
}
}

public OnBombPickedup(Handle:event, String:name[], bool:dontBroadcast)
{
BombDropped = false;
}

public Action:t_BombDropSlay(Handle:timer, any:client)
{
if(IsClientInGame(client) && IsClientConnected(client) && BombDropped && ClientTimer[client] != INVALID_HANDLE)
{
ForcePlayerSuicide(client);
ClientTimer[client] = INVALID_HANDLE;
}
}

public OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));

if(ClientTimer[client] != INVALID_HANDLE)
{
KillTimer(ClientTimer[client]);
ClientTimer[client] = INVALID_HANDLE;
}
}


public OnClientDisconnect(client)
{
if(IsClientInGame(client) && IsClientConnected(client) && ClientTimer[client] != INVALID_HANDLE)
{
KillTimer(ClientTimer[client]);
ClientTimer[client] = INVALID_HANDLE;
}
}

banania
11-13-2011, 12:43
Thank you for your help

Regarding the timer and the message WARNING in my case I do not want to have for the simple reason that the rules change as soon as the bomb and thrown or given (CSS not being the difference) I must so just a script for people giving or throwing the bomb.

TnTSCS
11-13-2011, 13:18
then you can use Impact's posted plugin... his will do what you want, slay the person if they drop the bomb

I was just thinking of those players who don't like having the bomb and they "give" it to another player. With Impact's plugin, it would slay me... that's why Impact said this wasn't the best idea and I was just trying to enhance it for that exact reason.

banania
11-13-2011, 13:37
Yes yes I understand, if not it will be possible to make sure to have a sentence that appears at the slay to configure so that it can take several languages?

Impact123
11-13-2011, 16:57
Yes yes I understand, if not it will be possible to make sure to have a sentence that appears at the slay to configure so that it can take several languages?
Do you mean Translationphrases?
I wrote somethink up what might help if you mean what i might.
"Phrases"
{
"Bomb_Dropped"
{
"#format" "{1:d}"
"en" "The bomb must be picked up in {1} seconds or you will be slayed."
"de" "Die Bombe muss innerhalb von {1} Sekunden aufgehoben werden, oder du wirst getoetet."
}
"T_Killed"
{
"en" "You were killed because you did not picked up the bomb in time."
"de" "Du wurdest getoetet weil du die Bombe nicht rechtzeitig aufgehoben hast."
}
"Bomb_Pickup_Team"
{
"#format" "{1:s}"
"en" "{1} picked up your bomb."
"de" "{1} hat deine Bombe aufgehoben."
}
}
This is just a suggestion.


I just need to code to kill the timer when the bomb is picked up by another player instead of using the bool... or maybe Impact can finish it :)
I will watch and learn :)

Yours sincerely
Impact

banania
11-13-2011, 18:35
yes I speak of translationphrases but that you did work with the tntscs's script

Impact123
11-13-2011, 19:22
yes I speak of translationphrases but that you did work with the tntscs's script
Well, he need to customize his script a lil bitm but that should not be a big thing :)

Yours sincerely
Impact

TnTSCS
11-13-2011, 20:08
okay - I'll fix it up...

I won't be adding any different languages as I only speak english, but you can add them as long as you follow the format Impact has...

I'll try and get this done tonight - have a few other plugins I'm working on too...

TnTSCS
11-14-2011, 18:48
Here's a good start. I've tested it and didn't see any issues with the plugin. It seems to be working just fine.

A config file will be created where you can turn on/off notifications if you want.


SOLUTION:
This plugin will do the following if a player drops the bomb:

1. If a player merely gives the bomb to another player, it will not do anything
- It allows 1/2 seconds for the bomb to be picked up by another (or the same) player before anything starts to happen

2. If configured with the cvar sm_dropbombslay_dropwarn, this plugin will warn the player that they have X seconds
to pick the bomb up or they will get slayed.
- The message is in a translation file, so just add new languages as you see fit. Just follow the same format for the messages
and don't change anything other than adding a new language line for each event you want.

3. The amount of time before the player is slayed is controlled via the cvar sm_dropbombslay_timer

4. If the bomb is picked up within the allotted time, no slay will happen. If configured with the cvar sm_dropbombslay_advisepickup,
the player will be notified that someone picked up the bomb for them. If they pick it back up themselves, no notification happens.

5. If the bomb is not picked up in the allotted time the player is slayed - if they're still alive.

All cvars are configured through the config file BombDropSlay.plugin.cfg

All translation text is maintained in the BombDropSlay.phrases.txt



To install, put the SMX in your plugins folder and the TXT in your translations folder. Right now, the translations only have what Impact put in there (English and German I think). If you want more, you'll have to add it.

Give thanks to Impact :)

banania
11-14-2011, 19:10
In my case, it does not match what I'm looking for: s

even if a person passes the bomb to another person, I want it because I slay another script that indicates when the bomb is down and when you give it to someone or when thrown and catches it he said that the bomb is down and suddenly this crazy shit on the server because when the bomb is down there isn't rush.

TnTSCS
11-14-2011, 19:14
So, you want it to slay as soon as the player drops the bomb - whether they drop it on the ground or pass it to another player - you want that player who dropped it to get slayed immediately?

banania
11-14-2011, 19:18
Yes exactly,
also with the translationphrases system that the phrase appears in the language of the player.

Impact123
11-14-2011, 21:09
Next time be more accurate, sad about the work which ​​TnTSCS has made.
Anyway, this should be what you want.
To add more languages just follow the format, and/or read here (http://wiki.alliedmods.net/Translations_%28SourceMod_Scripting%29).

.smx goes to plugins/, *phrases.txt goes to translations/.

Edit: For some reason the message appears 2 times, atm i dont know why.

Yours sincerely
Impact

TnTSCS
11-14-2011, 21:55
For some reason the message appears 2 times, atm i dont know why.

Ya, before I left for work (over 2 damn hours ago - love Los Angeles freeway traffic) I noticed it ran twice with the code I came up with (prolly same as yours)

Might want to have it call another function to slay and reply to client using a bool to indicate the bomb was dropped.

Impact123
11-14-2011, 22:47
For some Reason the event is triggered two times, but i got it working now.
I've updated my previous post.

Yours sincerely
Impact

banania
11-15-2011, 09:20
Thank you very much, I will test the script on the bug that shows 2 times the same sentence, I had the same problem with another script and it is clear that this was due to EventScript.
If it is installed on the same server, try disabling it.

banania
10-30-2012, 15:27
Hi,

I've had a lot of time errors in logs

L 10/30/2012 - 18:23:11: SourceMod error session started
L 10/30/2012 - 18:23:11: Info (map "de_dust2") (file "errors_20121030.log")
L 10/30/2012 - 18:23:11: [SM] Native "IsClientConnected" reported: Client index 0 is invalid
L 10/30/2012 - 18:23:11: [SM] Displaying call stack trace for plugin "BombDropSlay.smx":
L 10/30/2012 - 18:23:11: [SM] [0] Line 27, /home/groups/alliedmodders/forums/files/1/5/7/9/6/4/95285.attach::OnBombDropped()

TnTSCS
10-30-2012, 18:51
who's plugin did you end up using?

banania
10-31-2012, 10:09
i use this one
https://forums.alliedmods.net/showpost.php?p=1596675&postcount=15

Impact123
10-31-2012, 10:51
I've attached an fixed version.

Yours sincerely
Impact

banania
11-01-2012, 09:48
thank you very much ;)