Raised This Month: $ Target: $400
 0% 

Help editing script


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
|FMS|*KENNY
Junior Member
Join Date: Jan 2008
Old 05-29-2009 , 17:29   Help editing script
Reply With Quote #1

Well I know absolutely nothing about scripting plugins, I have been using a plugin that blocks a certain cvar from being used in game. I downloaded the source and edited out the cvar it was originally blocking with the one I wanted to block. The plugin works great. I just wanted to know what code to add so when someone is banned for using the cvar a message is shown to the users on the server. Currently it just gives the user the reason why they were banned. (Banned for using a prohibited command) I want it to show up in chat and say "Player [playername] has been permanently banned for using an illegal command."

This is for a L4D server if that makes a difference.

Here is the original code from the flytrap plugin. I take no credit for this plugin or code, it belongs to floor_master. Thanks
Code:
// vim: set filetype=c :

#include <sourcemod>

#define CVAR_BAN_MSG        0
#define CVAR_VERSION        1
#define CVAR_NUM_CVARS        2

#define FLYTRAP_VERSION        "1.1"

public Plugin:myinfo = {
    name = "Command Exploit Flytrap",
    author = "FLOOR_MASTER",
    description = "Automatically ban anyone attempting server-crashing debug commands",
    version = FLYTRAP_VERSION,
    url = "http://www.2fort2furious.com"
};

new Handle:g_cvars[CVAR_NUM_CVARS];

public OnPluginStart() {
    RegConsoleCmd("sv_benchmark_force_start", Command_CrashAttempt);
    RegConsoleCmd("sv_soundscape_printdebuginfo", Command_CrashAttempt);
    RegConsoleCmd("ai_test_los", Command_CrashAttempt);

    g_cvars[CVAR_BAN_MSG] = CreateConVar(
    "flytrap_banmsg",
    "Banned for using a prohibited command",
    "Message to display when kicking/banning the player",
    FCVAR_PLUGIN);

    g_cvars[CVAR_VERSION] = CreateConVar(
    "flytrap_version",
    FLYTRAP_VERSION,
    "Command Exploit Flytrap Version",
    FCVAR_PLUGIN|FCVAR_REPLICATED|FCVAR_NOTIFY);
}

public Action:Command_CrashAttempt(client, args) {
    if (client) {
    decl String:ban_msg[128];
        decl String:command[32];
        GetConVarString(g_cvars[CVAR_BAN_MSG], ban_msg, sizeof(ban_msg));

        GetCmdArg(0, command, sizeof(command));

        LogAction(client, -1, "%L attempted %s, banning", client, command);
        BanClient(client, 0, BANFLAG_AUTHID, ban_msg, ban_msg);
    }
    return Plugin_Handled;
}
__________________
|FMS|*KENNY is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 05-30-2009 , 09:45   Re: Help editing script
Reply With Quote #2

PHP Code:
public Action:Command_CrashAttempt(clientargs) {
    if (
client) {
    
decl String:ban_msg[128];
        
decl String:command[32];
        
GetConVarString(g_cvars[CVAR_BAN_MSG], ban_msgsizeof(ban_msg));

        
GetCmdArg(0commandsizeof(command));

        
LogAction(client, -1"%L attempted %s, banning"clientcommand);
        
BanClient(client0BANFLAG_AUTHIDban_msgban_msg);
        
PrintToChatAll("Player %N has been permanently banned for using an illegal command."client); 
    }
    return 
Plugin_Handled;

That should do it.
Wazz is offline
|FMS|*KENNY
Junior Member
Join Date: Jan 2008
Old 05-30-2009 , 19:37   Re: Help editing script
Reply With Quote #3

Quote:
Originally Posted by Wazz View Post
PHP Code:
public Action:Command_CrashAttempt(clientargs) {
    if (
client) {
    
decl String:ban_msg[128];
        
decl String:command[32];
        
GetConVarString(g_cvars[CVAR_BAN_MSG], ban_msgsizeof(ban_msg));

        
GetCmdArg(0commandsizeof(command));

        
LogAction(client, -1"%L attempted %s, banning"clientcommand);
        
BanClient(client0BANFLAG_AUTHIDban_msgban_msg);
        
PrintToChatAll("Player %N has been permanently banned for using an illegal command."client); 
    }
    return 
Plugin_Handled;

That should do it.
I tried it out but it didn't work. Instead of it banning instantly and not allowing the command to be executed it allows the command to be executed then it bans the user, but still no message.
__________________
|FMS|*KENNY is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 05-30-2009 , 21:05   Re: Help editing script
Reply With Quote #4

In the block of code I gave you I mearly added one line, it should not change any of the plugins actions. Make sure you havent made a typo somewhere or inserted the wrong thing. If it's still going wrong paste the whole, new code again.

I presume the plugin was working properly before you tried adding a message to it?
Wazz is offline
|FMS|*KENNY
Junior Member
Join Date: Jan 2008
Old 05-31-2009 , 00:21   Re: Help editing script
Reply With Quote #5

Not sure what went wrong when I first tried it but I did it all over and it bans them without allowing the command to be executed but still no display message. Also for some reason it doesn't show the person the ban message anymore. Now when you type in the command you just lose connection and get the countdown in the corner and when you try to rejoin it tells you your banned.

I removed the printtochatall line recompiled and it works normally again. It seems to be that one line that makes it act up.
__________________
|FMS|*KENNY is offline
Wazz
SourceMod Donor
Join Date: Mar 2009
Old 06-03-2009 , 15:53   Re: Help editing script
Reply With Quote #6

PHP Code:
public Action:Command_CrashAttempt(clientargs) {
    if (
client) {
    
decl String:ban_msg[128];
        
decl String:command[32];
        
GetConVarString(g_cvars[CVAR_BAN_MSG], ban_msgsizeof(ban_msg));

        
GetCmdArg(0commandsizeof(command));

        
PrintToChatAll("Player %N has been permanently banned for using an illegal command."client); 
        
LogAction(client, -1"%L attempted %s, banning"clientcommand);
        
BanClient(client0BANFLAG_AUTHIDban_msgban_msg);
     }
    return 
Plugin_Handled;

Sorry for the delay in response. I made a stupid error anywho try that.
Wazz 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 00:51.


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