Raised This Month: $ Target: $400
 0% 

Kill a player without taking away a frag


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SilentBr
Veteran Member
Join Date: Jan 2009
Old 01-31-2013 , 23:58   Kill a player without taking away a frag
Reply With Quote #1

I am using this plugin to slay players that don't complete the objectives. But players are complaining when losing frags. I did ask the author to put a way to not lose a frag but he didn't answer yet.

So, is there a way to kill the player without losing a frag? I tried FakeCommandClient, Explode, ForcePlayerSuicide, all of them take away a frag.

PHP Code:
/**
 * Slays losers on round timer end AND round end (default)
 * (didnt plant and time was up, didnt touch / rescue all hostage when time was up)
 * (bomb exploded or defused triggers this round end!)
 *
 * OR:
 *
 * Slay losers on objectives lost/completed ONLY
 * (such as bomb explode, defuse, and all hostages rescued)
 * If bomb wasnt planted then this will not do anything.
 *
 * Admins can be immune to the slay
 */

#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#undef REQUIRE_EXTENSIONS
#include <sdkhooks>
#define REQUIRE_EXTENSIONS
#include <cstrike>
#include <colors>

#define PLUGIN_VERSION "1.4b2"

// Globals
new bool:g_bHostageTouched false;

// Convars
new Handle:g_hCvarEnabled INVALID_HANDLE;
new 
Handle:g_hCvarAdminsImmune INVALID_HANDLE;
new 
Handle:g_hCvarSlayOnObjectives INVALID_HANDLE;
new 
Handle:g_hCvarSlayOnRoundTimeUp INVALID_HANDLE;
new 
Handle:g_hCvarDNSIfTouchHostage INVALID_HANDLE//DNS==Do Not Slay
new Handle:g_hCvarDNSIfQuickDefuseWireUsed INVALID_HANDLE//DNS==Do Not Slay
new Handle:g_hCvarQuickDefuseWireUsed INVALID_HANDLE;
new 
Handle:g_hCvarDisarmInsteadOfSlay INVALID_HANDLE;
new 
bool:g_bCvarEnabled true;
new 
bool:g_bCvarAdminsImmune true;
new 
bool:g_bCvarSlayOnObjectives false;
new 
bool:g_bCvarSlayOnRoundTimeUp true;
new 
bool:g_bCvarDNSIfTouchHostage true//DNS==Do Not Slay, not domain name system
new bool:g_bCvarDNSIfQuickDefuseWireUsed true//DNS==Do Not Slay, not domain name system
new bool:g_bCvarQuickDefuseWireUsed false;
new 
bool:g_bCvarDisarmInsteadOfSlay false;

new 
bool:bCanSlay=false;
new 
bool:g_bDisarmed[MAXPLAYERS+1];
new 
bool:g_bSdkHooksLoaded false;

public 
Plugin:myinfo = {
  
name "Slay Losers",
  
author "DarkEnergy - Ownz and Frezzy",
  
description "Slays losers on timer round end and or objectives lost",
  
version PLUGIN_VERSION,
  
url "www.ownageclan.com"
};

public 
OnPluginStart()
{
  
LoadTranslations("slaylosers.phrases");
  
  
HookEvent("round_start"EventRoundStart); //before freezetime
  
HookEvent("round_end"EventRoundEnd);
  
HookEvent("bomb_defused"EventBombDefused);
  
HookEvent("bomb_exploded"EventBombExploded);
  
HookEvent("hostage_rescued_all"EventAllHostagesRescued);
  
HookEvent("hostage_follows"EventHostageTouched);
  
  
CreateConVar("oc_slaylosers_version"PLUGIN_VERSION"Slay Losers version"FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  
g_hCvarEnabled CreateConVar("slaylosers_enabled""1""Is this plugin enabled, the master on off switch");
  
g_hCvarAdminsImmune CreateConVar("slaylosers_admin_immunity""1""Admins should not be slayed");
  
g_hCvarSlayOnObjectives CreateConVar("slaylosers_slay_objectives""0""Slay losers if an objective is completed (bomb, defuse, all hostages)");
  
g_hCvarSlayOnRoundTimeUp CreateConVar("slaylosers_slay_round_timer""1""Slay losers if round timer is up (didnt plant and time was up etc)");
  
g_hCvarDNSIfTouchHostage CreateConVar("slaylosers_skipiftouchedhostage""1""CTs should not be slayed if they touched a hostage");
  
g_hCvarDNSIfQuickDefuseWireUsed CreateConVar("slaylosers_skipifquickdefusewireused""1""Losers should not be slayed if quick defuse wire is used");
  
g_hCvarDisarmInsteadOfSlay CreateConVar("slaylosers_disarminsteadofslay""0""Disarm instead of slay");
  
  
g_hCvarQuickDefuseWireUsed FindConVar("qd_wireused");
  
  
HookConVarChange(g_hCvarEnabledOnConVarChange);
  
HookConVarChange(g_hCvarAdminsImmuneOnConVarChange);
  
HookConVarChange(g_hCvarSlayOnObjectivesOnConVarChange);
  
HookConVarChange(g_hCvarSlayOnRoundTimeUpOnConVarChange);
  
HookConVarChange(g_hCvarDNSIfTouchHostageOnConVarChange);
  
  if (
g_hCvarQuickDefuseWireUsed != INVALID_HANDLE)
  {
    
HookConVarChange(g_hCvarQuickDefuseWireUsedOnConVarChange);
  }
  
  
AutoExecConfig(false"slaylosers");
  
GetConVars();
  
  for (new 
client 1client <= MaxClientsclient++)
  {
      if (
IsClientInGame(client))
      {
          
OnClientPutInServer(client);
      }
  }
}

public 
APLRes:AskPluginLoad2(Handle:myselfbool:lateString:error[], err_max)
{
  
MarkNativeAsOptional("SDKHook");
  
MarkNativeAsOptional("SDKUnhook");
  
MarkNativeAsOptional("SDKHook_WeaponCanUse");
  return 
APLRes_Success;
}

public 
OnAllPluginsLoaded()
{
  if(
LibraryExists("sdkhooks"))
    
g_bSdkHooksLoaded true;
}

public 
OnLibraryAdded(const String:name[])
{
  if(
StrEqual(name"sdkhooks"))
    
g_bSdkHooksLoaded true;
}

public 
OnPluginEnd()
{
    for (new 
client 1client <= MaxClientsclient++)
    {
        if (
IsClientInGame(client))
        {
            
OnClientDisconnect_Post(client);
        }
    }
}

public 
OnClientPutInServer(client)
{
  if (
g_bSdkHooksLoaded)
    
SDKHook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
}

public 
OnClientDisconnect_Post(client)
{
  if (
g_bSdkHooksLoaded)
    
SDKUnhook(clientSDKHook_WeaponCanUseOnWeaponCanUse);
}

public 
Action:EventRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
  
g_bHostageTouched false;
  
bCanSlay=false;
  
//PrintToServer("RRRRS");
  
for (new 1<= MaxClientsi++)
  {
    
g_bDisarmed[i] = false;
  }
}

public 
Action:EventRoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
{
  new 
reason GetEventInt(event"reason");
  if (
reason == _:CSRoundEnd_TargetBombed || reason == _:CSRoundEnd_BombDefused || reason == _:CSRoundEnd_HostagesRescued)
  {
    return; 
// Avoid double messages
  
}
  if (
g_bCvarEnabled && g_bCvarSlayOnRoundTimeUp)
  {
    new 
winner GetEventInt(event"winner");
    if (
winner == CS_TEAM_CT || winner == CS_TEAM_T)
    {
      new 
bool:slay true;
      if (
winner == CS_TEAM_T && g_bHostageTouched && g_bCvarDNSIfTouchHostage//do not slay CT if CTs touched a hostage
      
{
        
slay false;
        
SlayLosersPrintToChat("%t""Counter Terrorists have been spared for touching at least one hostage");
      }
      if (
slay)
      {
        
CreateTimer(0.1SlayTeamwinner == CS_TEAM_CT CS_TEAM_T CS_TEAM_CT);
        
bCanSlay=true;
      }
    }
  }
}

public 
Action:EventBombDefused(Handle:event, const String:name[], bool:dontBroadcast)
{
  if (
g_bCvarEnabled && g_bCvarSlayOnObjectives)
  {
    if (
g_bCvarDNSIfQuickDefuseWireUsed && g_bCvarQuickDefuseWireUsed)
    {
      
SlayLosersPrintToChat("%t""Terrorists have been spared for wire used");
    }
    else
    {
      
CreateTimer(0.1SlayTeamCS_TEAM_T);
      
bCanSlay=true;
    }
  }
}

public 
Action:EventBombExploded(Handle:event, const String:name[], bool:dontBroadcast)
{
  if (
g_bCvarEnabled && g_bCvarSlayOnObjectives)
  {
    if (
g_bCvarDNSIfQuickDefuseWireUsed && g_bCvarQuickDefuseWireUsed)
    {
      
SlayLosersPrintToChat("%t""Counter Terrorists have been spared for wire used");
    }
    else
    {
      
CreateTimer(0.1SlayTeamCS_TEAM_CT);
      
bCanSlay=true;
    }
  }
}
public 
Action:EventAllHostagesRescued(Handle:event, const String:name[], bool:dontBroadcast)
{
  if (
g_bCvarEnabled && g_bCvarSlayOnObjectives)
  {
    
CreateTimer(0.1SlayTeamCS_TEAM_T);
    
bCanSlay=true;
  }
}

public 
Action:EventHostageTouched(Handle:event, const String:name[], bool:dontBroadcast)
{
  
g_bHostageTouched true;
}

public 
Action:SlayTeam(Handle:tany:team)
{
  if(
bCanSlay//avoid slaying right after round starts, if bomb explodes 0.1 seconds before a new round
  
{
    new 
slayedcount 0;
    for (new 
1<= MaxClientsi++)
    {
      if (
IsClientConnected(i) && IsClientInGame(i) && IsPlayerAlive(i) && GetClientTeam(i) == team && !IsAdminImmunity(i))
      {
        if(
g_bCvarDisarmInsteadOfSlay)
        {
          
Disarm(i);
        }
        else
        {
          
ForcePlayerSuicide(i);
        }
        
//PrintToChat(i, "You have been slayed for not completing the objectives");
        
slayedcount++;
      }
    }
    if (
slayedcount 0)
    {
      if (
team == CS_TEAM_CT)
      {
        if(
g_bCvarDisarmInsteadOfSlay)
        {
          
SlayLosersPrintToChat("%t""Counter Terrorists have been disarmed for not completing the objectives");
        }
        else
        {
          
SlayLosersPrintToChat("%t""Counter Terrorists have been slayed for not completing the objectives");
        }
      }
      else if (
team == CS_TEAM_T)
      {
        if(
g_bCvarDisarmInsteadOfSlay)
        {
          
SlayLosersPrintToChat("%t""Terrorists have been disarmed for not completing the objectives");
        }
        else
        {
          
SlayLosersPrintToChat("%t""Terrorists have been slayed for not completing the objectives");
        }
      }
    }
  }
}

bool:IsAdminImmunity(client)
{
  if (
g_bCvarAdminsImmune==false)
  {
    return 
false;
  }
  new 
AdminId:admin GetUserAdmin(client);
  if (
admin == INVALID_ADMIN_ID)
  {
    return 
false;
  }
  return 
true;
}

public 
SlayLosersPrintToChat(const String:szMessage[], any:...)
{
  
decl String:szBuffer[250];
  for (new 
1<= MaxClientsi++)
  {
    if (
IsClientInGame(i) && !IsFakeClient(i))
    {
      
SetGlobalTransTarget(i);
      
VFormat(szBuffersizeof(szBuffer), szMessage2);
      
Format(szBuffersizeof(szBuffer), "%T%s""[Slay Losers]"iszBuffer);
      
CPrintToChat(iszBuffer);
    }
  }
}

Disarm(client)
{
  
decl weapon;
  
decl slot;
  if (
client != 0)
  {
    for (
slot CS_SLOT_PRIMARY slot <= CS_SLOT_GRENADE slot++)
    {
      
weapon GetPlayerWeaponSlot(clientslot);
      while (
weapon != -&& (GetEntPropEnt(weaponProp_Data"m_hOwnerEntity") == client))
      {
        
RemovePlayerItem(clientweapon);
        
weapon GetPlayerWeaponSlot(clientslot);
      }
    }
    
GivePlayerItem(client"weapon_knife");
    
g_bDisarmed[client] = true;
  }
}

public 
Action:OnWeaponCanUse(clientweapon)
{
  if (
g_bDisarmed[client])
  {
    return 
Plugin_Stop;
  }
  return 
Plugin_Continue;
}

public 
OnConVarChange(Handle:convar_hndl, const String:oldValue[], const String:newValue[])
{
  
GetConVars();
}

public 
OnConfigsExecuted()
{
  
GetConVars();
}

public 
GetConVars()
{
  
g_bCvarEnabled GetConVarBool(g_hCvarEnabled);
  
g_bCvarAdminsImmune GetConVarBool(g_hCvarAdminsImmune);
  
g_bCvarSlayOnObjectives GetConVarBool(g_hCvarSlayOnObjectives);
  
g_bCvarSlayOnRoundTimeUp GetConVarBool(g_hCvarSlayOnRoundTimeUp);
  
g_bCvarDNSIfTouchHostage GetConVarBool(g_hCvarDNSIfTouchHostage);
  
g_bCvarDNSIfQuickDefuseWireUsed GetConVarBool(g_hCvarDNSIfQuickDefuseWireUsed);
  
g_bCvarDisarmInsteadOfSlay GetConVarBool(g_hCvarDisarmInsteadOfSlay);
  if (
g_hCvarQuickDefuseWireUsed != INVALID_HANDLE)
  {
    
g_bCvarQuickDefuseWireUsed GetConVarBool(g_hCvarQuickDefuseWireUsed);
  }

Thanks
SilentBr is offline
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 02-01-2013 , 00:04   Re: Kill a player without taking away a frag
Reply With Quote #2

Quote:
SetEntProp(client, Prop_Data, "m_iFrags", GetClientFrags(client) - 1);
Used this before on TF2, i don't know if it will work on CSS.
__________________

Last edited by Chaosxk; 02-01-2013 at 00:21.
Chaosxk is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 02-01-2013 , 02:25   Re: Kill a player without taking away a frag
Reply With Quote #3

Quote:
Originally Posted by Chaosxk View Post
Used this before on TF2, i don't know if it will work on CSS.
Where do I put this?

Thanks!!!
SilentBr is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 02-01-2013 , 03:12   Re: Kill a player without taking away a frag
Reply With Quote #4

Right below ForcePlayerSuicide is a good place.

Yours sincerely
Impact
__________________

Last edited by Impact123; 02-01-2013 at 03:14.
Impact123 is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 02-01-2013 , 03:33   Re: Kill a player without taking away a frag
Reply With Quote #5

Quote:
Originally Posted by Impact123 View Post
Right below ForcePlayerSuicide is a good place.

Yours sincerely
Impact
Yeah I put there but the server crashed. A lot erros:

Quote:
ForcePlayerSuicide(i);
SetEntProp(i, Prop_Data, "m_iFrags", GetClientFrags(i) + 1);
PHP Code:
L 02/01/2013 07:04:49: [SMPlugin encountered error 21Native is not bound
L 02
/01/2013 07:04:49: [SMNative "BfWriteByte" reported
L 02/01/2013 07:04:49: [SMDisplaying call stack trace for plugin "OCslaylosers.smx":
L 02/01/2013 07:04:49: [SM]   [0]  Line 347D:\SteamCMD\steamcmd\csgo-ds\csgo\addons\sourcemod\scripting\include\colors.inc::CSayText2()
L 02/01/2013 07:04:49: [SM]   [1]  Line 74D:\SteamCMD\steamcmd\csgo-ds\csgo\addons\sourcemod\scripting\include\colors.inc::CPrintToChat()
L 02/01/2013 07:04:49: [SM]   [2]  Line 304D:\SteamCMD\steamcmd\csgo-ds\csgo\addons\sourcemod\scripting\OCslaylosers.sp::SlayLosersPrintToChat()
L 02/01/2013 07:04:49: [SM]   [3]  Line 262D:\SteamCMD\steamcmd\csgo-ds\csgo\addons\sourcemod\scripting\OCslaylosers.sp::SlayTeam() 
Thanks

Last edited by SilentBr; 02-01-2013 at 04:06.
SilentBr is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 02-01-2013 , 04:03   Re: Kill a player without taking away a frag
Reply With Quote #6

Spoiler

SetEntProp isn't the one responsible for the errors at all. the problem resides at the include "colors", which is being used by the plugin. you have to download the lastest snapshot of sourcemod and change the include file according to this https://forums.alliedmods.net/showth...90#post1878490 in order to compile the plugin.

Spoiler

actually, that change was already made: https://forums.alliedmods.net/showpo...&postcount=311. use this at the place of the older one and be sure to be using the last sourcemod snapshot when compiling.

Last edited by Bimbo1; 02-01-2013 at 04:13. Reason: i'm dumb and i didn't use the preview.
Bimbo1 is offline
SilentBr
Veteran Member
Join Date: Jan 2009
Old 02-01-2013 , 04:28   Re: Kill a player without taking away a frag
Reply With Quote #7

Quote:
Originally Posted by Bimbo1 View Post
Spoiler

SetEntProp isn't the one responsible for the errors at all. the problem resides at the include "colors", which is being used by the plugin. you have to download the lastest snapshot of sourcemod and change the include file according to this https://forums.alliedmods.net/showth...90#post1878490 in order to compile the plugin.

Spoiler

actually, that change was already made: https://forums.alliedmods.net/showpo...&postcount=311. use this at the place of the older one and be sure to be using the last sourcemod snapshot when compiling.
I did compile the plugin with this color.inc and now the plugin is working fine, no errors neither crashes. But when compiling I got this warn:



EDIT: This warn appear only when I add the command to not lose the frag.

Last edited by SilentBr; 02-01-2013 at 04:29.
SilentBr is offline
Sheepdude
SourceMod Donor
Join Date: Aug 2012
Location: Chicago
Old 02-01-2013 , 06:08   Re: Kill a player without taking away a frag
Reply With Quote #8

On line 247 you probably are using a different indentation than the other lines (e.g. spaces instead of tabs), or something like that.
__________________
Sheepdude is offline
htcarnage
Senior Member
Join Date: Oct 2009
Old 02-05-2013 , 17:53   Re: Kill a player without taking away a frag
Reply With Quote #9

Why bother slaying the losers if you don't want to take away a frag? I just don't see the point
htcarnage is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 02-05-2013 , 18:24   Re: Kill a player without taking away a frag
Reply With Quote #10

it still counts as a death and makes them lose their weapons.
Bimbo1 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:16.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode