Raised This Month: $12 Target: $400
 3% 

[REQ] Simple Redirection for Sourcemod


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
awek
Junior Member
Join Date: Apr 2010
Old 09-25-2010 , 23:49   [REQ] Simple Redirection for Sourcemod
Reply With Quote #1

Hi, I would like if this can be for https://forums.alliedmods.net/showthread.php?p=10072 can be for sourcemod

im sorry but my english is bad

Thanks
awek is offline
horazon
New Member
Join Date: Sep 2010
Old 09-26-2010 , 06:38   Re: [REQ] Simple Redirection for Sourcemod
Reply With Quote #2

PHP Code:
#include <sourcemod>

public Plugin:myinfo = {
    
name "Client Redirect",
    
author "horazon",
    
description "Simple Client Redirector",
    
version "0.2",
    
url ""
};

new 
Handle:RedirectEnabled;
new 
Handle:RedirectAddress;
new 
Handle:RedirectPassword;
new 
Handle:RedirectMaxPlrs;

public 
OnPluginStart()
{
    
RedirectEnabled  CreateConVar ("sm_redirect_enabled",  "1"""FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
RedirectAddress  CreateConVar ("sm_redirect_address",  "192.168.0.3:27015"""FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
RedirectPassword CreateConVar ("sm_redirect_password"""""FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
    
RedirectMaxPlrs  CreateConVar ("sm_redirect_maxplrs",  "20"""FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
}

public 
bool:OnClientConnect(clientString:rejectmsg[], maxlen)
{
    if (!
GetConVarBool (RedirectEnabled) || GetClientCount () <= GetConVarInt (RedirectMaxPlrs))
        return 
true;

    new 
String:address[128];
    
GetConVarString (RedirectAddressaddress128);

    new 
String:password[128];
    
GetConVarString (RedirectPasswordpassword128);

    if (!
StrEqual (password""))
        
ClientCommand (client"password %s"password);

    
ClientCommand (client"connect %s"address);

    return 
true;

horazon is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-26-2010 , 11:43   Re: [REQ] Simple Redirection for Sourcemod
Reply With Quote #3

Luckily for clients, the connect command is restricted in most games, so the server is unable to execute it on them.
psychonic is offline
Xsinthis
Senior Member
Join Date: Oct 2008
Location: Canadia, eh?
Old 09-26-2010 , 14:30   Re: [REQ] Simple Redirection for Sourcemod
Reply With Quote #4

not in source i don't think. At least not in tf2
__________________
Xsinthis is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-26-2010 , 14:30   Re: [REQ] Simple Redirection for Sourcemod
Reply With Quote #5

Quote:
Originally Posted by Xsinthis View Post
not in source i don't think. At least not in tf2
Yes, it's restricted in TF2.
psychonic is offline
Xsinthis
Senior Member
Join Date: Oct 2008
Location: Canadia, eh?
Old 09-26-2010 , 15:25   Re: [REQ] Simple Redirection for Sourcemod
Reply With Quote #6

Than how come i can join servers that redirect me? Or am i getting two different functions confused?
__________________
Xsinthis is offline
psychonic

BAFFLED
Join Date: May 2008
Old 09-26-2010 , 15:47   Re: [REQ] Simple Redirection for Sourcemod
Reply With Quote #7

Quote:
Originally Posted by Xsinthis View Post
Than how come i can join servers that redirect me? Or am i getting two different functions confused?
There are other ways to do it that won't be discussed here. I was just pointing out that the way mentioned above won't work.

The 'proper' way is the use the game's built-in functionality to ask the client if they want to be redirected, after which they can hit a button (default F3) to confirm.
psychonic is offline
awek
Junior Member
Join Date: Apr 2010
Old 09-26-2010 , 17:35   Re: [REQ] Simple Redirection for Sourcemod
Reply With Quote #8

thanks horazon

works perfect on l4d & l4d2
awek 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 14:22.


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