AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Extensions (https://forums.alliedmods.net/forumdisplay.php?f=134)
-   -   [EXTENSION][Any?] PointDetour (https://forums.alliedmods.net/showthread.php?t=184270)

KyleS 05-03-2012 01:11

[EXTENSION][Any?] PointDetour
 
5 Attachment(s)
This would not have been possible at all without Dr!fter (Or Dr. !fter, as I'm sure no one calls him).

What is this?

This is a simple detour of PointServerCommand::InsertCommand, which allows you to block, modify or listen to point_servercommand entities firing (and get the command they're running).

Why would you write this?
Well, I've been wanting to do this for a while for VIPMod (L. Duke used convars instead of the actual brush entities :(). But recently it was made clear to my community by a mapper that they're ultimately in control. How? Through the use of this one horrible entity called point_servercommand. With this, they can change your server rcon password, set a server password, change the map, change timeleft, do whatever they want. The same can be done with clients using point_clientcommand, and that's coming to this extension Soon™. Voogru warned people in the past about randomly running maps (or so I vaguely recall), but it still happens often so that's why this is here.

What does this do?
See What is this?. But if you're an end user, this allows for plugin developers to hook the firing of point_servercommand.

THIS CRASHES MY WINDOWS SERVER.
Welp, Sorry. Since Valve doesn't release Symbols for Windows, I can't ever support it. With this being said, thanks to Dr!fter, there's a untested Windows Build, and gamedata to go with it. If it works, great! I can't ever support this, though.

THIS CRASHES MY LINUX SERVER :(
Oh no! Tragic! Please post a stack trace in the thread.

Special Thanks to:
Drifter
- Holding my hand through a lot of this.
Psychonic - Suggesting a Hack, then providing a less hacky way :P

Asherkin - I learned a lot from ZombieFix, which appears to be based off of SDKHooks.
Sammy-ROCK! - Learned about Forwards from CSS Speed Mod.

KyleS 05-03-2012 01:17

Re: [EXTENSION][Any?] PointDetour
 
Example:

PHP Code:

#pragma semicolon 1
#include <sourcemod>
#include <pscd>

public Action:PointServerCommandForward(const String:sCommand[])
{
    
PrintToServer("DetourCalled!!!!!");
    
PrintToServer("Command Trying to be Called: %s"sCommand);
    return 
Plugin_Continue;


Quote:

Originally Posted by Server
DetourCalled!!!!!
Command Trying to be Called: vip_escapezone2 2080 50 -115 2400 280 -17
DetourCalled!!!!!
Command Trying to be Called: vip_escapezone 2100 -825 32 2515 -378 308
Unknown command "vip_escapezone2"
Unknown command "vip_escapezone"


GoD-Tony 05-03-2012 02:11

Re: [EXTENSION][Any?] PointDetour
 
Nice job! I always thought these entities needed some kind of whitelist for their commands. This will do nicely.

Quote:

Originally Posted by KyleS (Post 1700933)
The same can be done with clients using point_clientcommand, and that's coming to this extension Soon™.

Am I mistaken or is this already functional in the ext/gamedata but missing from the include file?

asherkin 05-03-2012 05:04

Re: [EXTENSION][Any?] PointDetour
 
Quote:

Originally Posted by KyleS (Post 1700933)
I want to execute my own commands using this!
Ok there hot shot. I should warn you that if you write over the max length, you're treading into unknown waters. Besides that though, I've yet to crash using this (Writing within the boundaries), so by all means go right ahead!

You should probably just const-qualify that param and not invoke the copyback stuff.
It's slow, and the ServerCommand native exists for that purpose.

KyleS 05-03-2012 09:51

Re: [EXTENSION][Any?] PointDetour
 
Quote:

Originally Posted by GoD-Tony (Post 1700947)
Am I mistaken or is this already functional in the ext/gamedata but missing from the include file?

I haven't tested it :wink:

Dr!fter 05-03-2012 12:16

Re: [EXTENSION][Any?] PointDetour
 
I tested windows it works fine :). Only problem you should add the block to the include that forces the extension to load :P I had to create an autoload file or else it wouldnt load (You can look for this in dhooks include or sdkhooks include). But after it loaded it worked, and nice job!

Also, ventrilo used to call me "Doctor Fter" Until i added a phonetic :P

Edit: as for the "ANY?" Im almost 100% positive that any orangebox-valve game yes. After that its very likely the others work too, but not as sure :P. I doubt that function changes much if at all between games.

Blowst 05-03-2012 12:20

Re: [EXTENSION][Any?] PointDetour
 
I appreciate your job.

Thx!

KyleS 05-03-2012 12:59

Re: [EXTENSION][Any?] PointDetour
 
Quote:

Originally Posted by asherkin (Post 1700972)
You should probably just const-qualify that param and not invoke the copyback stuff.
It's slow, and the ServerCommand native exists for that purpose.

There's no detour for ServerCommand :P Alright though, I'll kill it.

The include is going to change!

Plugin_Stop = Don't fire.
Plugin_Handled = Null the String, the output will still fire.
Plugin_Changed <= Continue.

Quote:

Originally Posted by Dr!fter (Post 1701229)
I tested windows it works fine :). Only problem you should add the block to the include that forces the extension to load :P I had to create an autoload file or else it wouldnt load (You can look for this in dhooks include or sdkhooks include). But after it loaded it worked, and nice job!

Awesome! and :oops: Oops! Will fix when I get home.

Dr!fter 05-03-2012 13:13

Re: [EXTENSION][Any?] PointDetour
 
Quote:

Originally Posted by KyleS (Post 1701265)
There's no detour for ServerCommand :P Alright though, I'll kill it.

The include is going to change!

Plugin_Stop = Don't fire.
Plugin_Handled = Null the String, the output will still fire.
Plugin_Changed <= Continue.


Awesome! and :oops: Oops! Will fix when I get home.

It makes sense to remove the copyback since if you really needed to change it you could just use (I didnt think of this heh) ServerCommand native and block it the function from calling.

I would just make Continue fire else block. Since Nulling it wont make any difference since it would just pass an empty string to ServerCommand :P

KyleS 05-03-2012 13:39

Re: [EXTENSION][Any?] PointDetour
 
Quote:

Originally Posted by Dr!fter (Post 1701271)
It makes sense to remove the copyback since if you really needed to change it you could just use (I didnt think of this heh) ServerCommand native and block it the function from calling.

I would just make Continue fire else block. Since Nulling it wont make any difference since it would just pass an empty string to ServerCommand :P

That does indeed make more sense :wink: I don't know what I was thinking before rukia

const it is!


All times are GMT -4. The time now is 12:03.

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