Raised This Month: $ Target: $400
 0% 

FakeClientCommand(entity,"kill") Crashes


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ersatz
New Member
Join Date: Jun 2007
Old 06-18-2007 , 19:58   FakeClientCommand(entity,"kill") Crashes
Reply With Quote #1

Hello:

Let me first say that I've been playing around with SourceMod and I truly appreciate all the time and hard work that has been put into this project! I'll also say that I am a hobbyist programmer but I am typically a DIY type of person so asking for help means I'm at the end of my rope...

Trying to "slay" players through FakeClientCommand(entity, "kill") has been a wild ride with crashing on two of my test systems. I've trolled around these forums for the past week, checked the flyspray bug tracker, and racked my brain on teh Google trying to find a reason for this.

My test systems (one x64 doze, the other a fairly stock Debian GNU/Linux Etch box) are devoid of all VSP/MMS plugins when trying this and I'm baffled why this code seems to compile and run on both systems:

Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
        RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
}

public Action:Command_Slay(client, args)
{
        if (args < 1)
        {
                ReplyToCommand(client, "[SM] Usage: sm_slay <#userid|name>");
                return Plugin_Handled;
        }

        new String:arg[65];

        GetCmdArg(1, arg, sizeof(arg));

        new targets[2];
        SearchForClients(arg, targets[0], 2);

        CommitSuicide(targets[0]);
        //FakeClientCommand(targets[0], "kill");

        return Plugin_Handled;
}

stock CommitSuicide(entity)
{
        FakeClientCommand(entity, "kill");
}
...and yet this compiles but causes a crash:

Code:
#include <sourcemod>

#pragma semicolon 1

public OnPluginStart()
{
        RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
}

public Action:Command_Slay(client, args)
{
        if (args < 1)
        {
                ReplyToCommand(client, "[SM] Usage: sm_slay <#userid|name>");
                return Plugin_Handled;
        }

        new String:arg[65];

        GetCmdArg(1, arg, sizeof(arg));

        new targets[2];
        SearchForClients(arg, targets[0], 2);

        FakeClientCommand(targets[0], "kill");

        return Plugin_Handled;
}
My debugging knowledge on Windows isn't quite up to par but this is the backtrace on my Debian system:

Code:
#0  0xb6815d5b in GetDeathPoseActivity ()
   from /usr/local/games/srcds1/cstrike/bin/server_i486.so
#1  0xb6815ed0 in SelectDeathPoseActivityAndFrame ()
   from /usr/local/games/srcds1/cstrike/bin/server_i486.so
#2  0xb6947059 in CCSPlayer::SelectDeathPose ()
   from /usr/local/games/srcds1/cstrike/bin/server_i486.so
#3  0xb69569da in CCSPlayer::Event_Killed ()
   from /usr/local/games/srcds1/cstrike/bin/server_i486.so
#4  0xb66cbb62 in CBasePlayer::CommitSuicide ()
   from /usr/local/games/srcds1/cstrike/bin/server_i486.so
#5  0xb6584d0b in CC_Player_Kill ()
   from /usr/local/games/srcds1/cstrike/bin/server_i486.so
#6  0xb16bd6ad in __SourceHook_FHCls_ConCommandDispatchfalse::Func ()
   from /usr/local/games/srcds1/cstrike/addons/sourcemod/bin/sourcemod_mm_i486.so
#7  0xb724255a in CGameClient::ExecuteStringCommand () from bin/engine_i686.so
#8  0xb16f83c9 in FakeClientCommand ()
   from /usr/local/games/srcds1/cstrike/addons/sourcemod/bin/sourcemod_mm_i486.so
#9  0xb1500a5f in operator new ()
   from /usr/local/games/srcds1/cstrike/addons/sourcemod/bin/sourcepawn.jit.x86.so
Has anyone else experienced this, and if so, do you know a workaround or fix for it?

Here is some relevant information about both of my testing platforms:
  • No other VSP/MMS plugins
  • Both SRCDS's are on 3140 build
  • SourceMod plugins show as 1.0.0.982
Thanks for any help, and feel free to ask me for more system information, debugging info, or anything else to try to fix this. Of course, there is always the possibility that I've missed a glaringly obvious problem with this -- if that's that case please let me know!
ersatz is offline
BAILOPAN
Join Date: Jan 2004
Old 06-18-2007 , 23:41   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #2

Just because it compiles doesn't mean it will run flawlessly ;)

I think sending "kill" through FakeClientCommand is one of the ways to upset HL2. I may be wrong though. There are certain commands that simply crash through it.
__________________
egg
BAILOPAN is offline
FlyingMongoose
Veteran Member
Join Date: Mar 2004
Old 06-19-2007 , 00:07   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #3

FakeClientCommand(entity,"kill"); works fine (I use it for all of my slay functionality) it's a networked command so it will always work (othwerwise other people wouldn't see a client as commiting suicide...ever)
__________________
Please do NOT PM for support.

Only ask for support in plugin threads.

TunedChaos.com - Precision Tuned Game Servers
FlyingMongoose is offline
BAILOPAN
Join Date: Jan 2004
Old 06-19-2007 , 00:10   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #4

Maybe you should validate the SearchForClients function. It has documented return values that should be accounted for. I.e. you don't want to be calling "kill" on the world entity.
__________________
egg
BAILOPAN is offline
c0ldfyr3
AlliedModders Donor
Join Date: Aug 2005
Location: Ireland
Old 06-19-2007 , 08:28   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #5

Very easy to alias over the "kill" command and so render your method useless.

Event_Dieing (Dying?) and Event_Dead are the two functions you need to call to slay perfectly.
__________________
c0ldfyr3 is offline
Send a message via MSN to c0ldfyr3 Send a message via Yahoo to c0ldfyr3
L. Duke
Veteran Member
Join Date: Apr 2005
Location: Walla Walla
Old 06-19-2007 , 10:27   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #6

Can you alias over a command that is only being run server-side and not sent to the client? I think it will work no matter what the alias is becuase it's using the fake client command (IServerPluginHelpers::ClientCommand ???) which never gets sent to the client instead of IVEngineServer::ClientCommand.

I always call CBasePlayer::CommitSuicide to slay in my plugins since it's a virtual function. You'd need an extension that can call virtual functions by their offset for that to work though.

Last edited by L. Duke; 06-19-2007 at 10:32.
L. Duke is offline
ersatz
New Member
Join Date: Jun 2007
Old 06-19-2007 , 18:16   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #7

Quote:
Originally Posted by BAILOPAN View Post
Just because it compiles doesn't mean it will run flawlessly ;)

I think sending "kill" through FakeClientCommand is one of the ways to upset HL2. I may be wrong though. There are certain commands that simply crash through it.
I understand what you mean, but in the two examples above one ALWAYS works (provided the SearchForClients returns a player entity) and the other ALWAYS crashes!

Quote:
Originally Posted by FlyingMongoose View Post
FakeClientCommand(entity,"kill"); works fine (I use it for all of my slay functionality) it's a networked command so it will always work (othwerwise other people wouldn't see a client as commiting suicide...ever)
Yes, I know you use this because I got the idea from looking at your ATAC code. ;) One thing to note is that when I tried to run FakeClientCommand(entity, "hurtme 1000") [where 1000 could be almost any number] I would see the exact same backtrace ending with GetDeathPoseActivity().

As much as I'd like to believe that FakeClientCommand(entity,"kill") is 100% kosher I don't see how such a simple script above can crash both a (relatively) vanilla Windoze and GNU/Linux SRCDS...

Quote:
Originally Posted by BAILOPAN View Post
Maybe you should validate the SearchForClients function. It has documented return values that should be accounted for. I.e. you don't want to be calling "kill" on the world entity.
I understand what you mean, but the crashes occur on both bots and human players. The above scripts are stripped down and I had lots of informational LogMessages() in there showing what name was matched and what the entity number really was... still crashed.

Quote:
Originally Posted by c0ldfyr3 View Post
Very easy to alias over the "kill" command and so render your method useless.

Event_Dieing (Dying?) and Event_Dead are the two functions you need to call to slay perfectly.
Quote:
Originally Posted by L. Duke View Post
Can you alias over a command that is only being run server-side and not sent to the client? I think it will work no matter what the alias is becuase it's using the fake client command (IServerPluginHelpers::ClientCommand ???) which never gets sent to the client instead of IVEngineServer::ClientCommand.

I always call CBasePlayer::CommitSuicide to slay in my plugins since it's a virtual function. You'd need an extension that can call virtual functions by their offset for that to work though.
I will look at using those virtual functions and start playing around with sigscanning and/or SDKtools to get them working. Thanks to everyone for the responses, and I'm definitely going to stay the hell away from FakeClientCommand() !!!
ersatz is offline
BAILOPAN
Join Date: Jan 2004
Old 06-19-2007 , 18:27   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #8

I can't imagine why your code would work with that insignificant change. You may want to try posting a bug report and we can look at it further.
__________________
egg
BAILOPAN is offline
ferret
SourceMod Developer
Join Date: Dec 2004
Location: Atlanta, GA
Old 06-19-2007 , 18:40   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #9

So does it work I need an sm_slay
__________________
I'm a blast from the past!
ferret is offline
FlyingMongoose
Veteran Member
Join Date: Mar 2004
Old 06-19-2007 , 20:29   Re: FakeClientCommand(entity,"kill") Crashes
Reply With Quote #10

I gave you stocks ferret! Make one.
__________________
Please do NOT PM for support.

Only ask for support in plugin threads.

TunedChaos.com - Precision Tuned Game Servers
FlyingMongoose 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 19:37.


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