Raised This Month: $ Target: $400
 0% 

Plugin like df_responses (executes server commands)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
terrum
AlliedModders Donor
Join Date: Apr 2006
Location: United Kingdom
Old 09-11-2009 , 18:27   Plugin like df_responses (executes server commands)
Reply With Quote #1

Hey, I need a plugin that basically reads an ini file and basically has this inside the ini

// "say command" "response" "level needed"
"admin noclip" "amx_noclip %s ;say You now have noclip!" "q"
"admin glow" "amx_glow random ;say You are now glowing a random colour!" "no admin needed"
"admin vip" "amx_vip 11 29 ;say You now have the VIP command executed!" "q"

Hope the ini file explains what i want as a plugin

Thanks.
__________________
Thanks,
Terrum.


terrum is offline
Send a message via AIM to terrum Send a message via MSN to terrum Send a message via Skype™ to terrum
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-11-2009 , 18:54   Re: Plugin like df_responses (executes server commands)
Reply With Quote #2

PHP Code:
#include < amxmodx >
#include < amxmisc >

new Trie:g_tArrayPos;
new Array:
g_aCommands;
new Array:
g_aFlags;

public 
plugin_init( ) {
    
register_plugin"Say Command Macro""0.0.1""Exolent" );
    
    
register_clcmd"say""CmdSay" );
    
    
g_tArrayPos TrieCreate( );
    
g_aCommands ArrayCreate128 );
    
g_aFlags ArrayCreate);
    
    
LoadCommands( );
}

public 
plugin_end( ) {
    
TrieDestroyg_tArrayPos );
    
ArrayDestroyg_aCommands );
    
ArrayDestroyg_aFlags );
}

LoadCommands( ) {
    new 
szFilename128 ];
    
get_configsdirszFilename127 );
    
addszFilename127"/say_macros.ini" );
    
    if( !
file_existsszFilename) ) {
        new 
iFile fopenszFilename"wt" );
        if( 
iFile ) {
            
fcloseiFile );
        }
        return;
    }
    
    new 
iFile fopenszFilename"rt" );
    if( !
iFile ) {
        return;
    }
    
    new 
szData512 ], szCommand32 ], szExecute128 ], szFlags], iPos;
    while( !
feofiFile ) ) {
        
fgetsiFileszData511 );
        
        if( !
szData]
        || 
szData] == '^n'
        
|| szData] == ';'
        
|| szData] == '/' && szData] == '/' ) {
            return;
        }
        
        
parseszDataszCommand31szExecute127szFlags);
        
strtolowerszCommand );
        
TrieSetCellg_tArrayPosszCommandiPos );
        
ArrayPushStringg_aCommandsszExecute );
        
ArrayPushCellg_aFlagsread_flagsszFlags ) );
        
iPos++;
    }
    
    
fcloseiFile );
}

public 
CmdSayclient ) {
    static 
szMessage194 ];
    
read_argsszMessage193 );
    
remove_quotesszMessage );
    
    
strtolowerszCommand );
    
    static 
iArrayPos;
    if( 
TrieGetCellg_tArrayPosszCommandiArrayPos ) ) {
        if( !
accessclientArrayGetCellg_aFlagsiArrayPos ) ) ) {
            
client_printclientprint_chat"* You have no access to that command!" );
        } else {
            static 
szExecute128 ];
            
ArrayGetStringg_aCommandsiArrayPosszExecute127 );
            
            static 
szName34 ];
            
get_user_nameclientszName31 );
            
formatszName33"^"%s^""szName );
            
            static 
szAuthid37 ];
            
get_user_authidclientszAuthid34 );
            
formatszAuthid36"^"%s^""szAuthid );
            
            static 
szIP34 ];
            
get_user_ipclientszIP31);
            
formatszIP33"^"%s^""szIP );
            
            static 
szUserid];
            
formatexszUserid5"#%i"get_user_useridclient ) );
            
            
replace_allszExecute127"$name"szName );
            
replace_allszExecute127"$steamid"szAuthid );
            
replace_allszExecute127"$ip"szIP );
            
replace_allszExecute127"$userid"szUserid );
            
            
server_cmd"%s"szExecute );
        }
    }

File path:
addons/amxmodx/configs/say_macros.ini

File format:
Code:
; "say command" "execute command" "admin flags"
; 
; Example:
; "menu" "amxmodxmenu" "u"
; This will work when you say:
; say "admin menu"
; 
; In the execute command, you can use these to pass yourself into the execute:
; - $name = your name
; - $steamid = your steamid
; - $ip = your ip
; - $userid = your userid
; 
; Example:
; "godon" "amx_godmode $userid 1" "m"
; "godoff" "amx_godmode $userid 0" "m"
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 09-28-2009 at 11:34.
Exolent[jNr] is offline
terrum
AlliedModders Donor
Join Date: Apr 2006
Location: United Kingdom
Old 09-12-2009 , 16:33   Re: Plugin like df_responses (executes server commands)
Reply With Quote #3

Thanks alot. +karma but it doesn't seem to work I added the .ini to plugins, it loads fine, added the ini to configs and the main tfc folder but i dont know where else to put it, i wrote admin test and nothing happened

this is what my ini looks like

; "say command" "execute command" "admin flags"
;
; Example:
; "menu" "amxmodxmenu" "u"
; This will work when you say:
; say "admin menu"
;
; In the execute command, you can use these to pass yourself into the execute:
; - $name = your name
; - $steamid = your steamid
; - $ip = your ip
; - $userid = your userid
;
; Example:
; "godon" "amx_godmode $userid 1" "m"
; "godoff" "amx_godmode $userid 0" "m"

"test" "say LOL $name YOUR STEAMID IS $steamid AND USERID IS $userid" "u"
__________________
Thanks,
Terrum.


terrum is offline
Send a message via AIM to terrum Send a message via MSN to terrum Send a message via Skype™ to terrum
terrum
AlliedModders Donor
Join Date: Apr 2006
Location: United Kingdom
Old 09-27-2009 , 17:16   Re: Plugin like df_responses (executes server commands)
Reply With Quote #4

Bump -- It's been about 2 weeks now, and i should be able to bump it now since the last reply. I really can't get this to work. Please help? Also i still don't know where the .ini goes etc. I think this script needs testing lol
__________________
Thanks,
Terrum.



Last edited by terrum; 09-27-2009 at 17:17. Reason: edit
terrum is offline
Send a message via AIM to terrum Send a message via MSN to terrum Send a message via Skype™ to terrum
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 09-27-2009 , 19:03   Re: Plugin like df_responses (executes server commands)
Reply With Quote #5

.ini file goes to amxmodx\configs
Now it will be automatically created if it does not exist.
say command is now exactly the same as in .ini file and you don't need to use "admin" prefix.
PHP Code:
#include < amxmodx >
#include < amxmisc >


new Trie:g_tArrayPos;
new Array:
g_aCommands;
new Array:
g_aFlags;

public 
plugin_init( ) {
    
register_plugin"Say Command Macro""0.0.2""Exolent" );

    
register_clcmd"say""CmdSay" );
    
    
g_tArrayPos TrieCreate( );
    
g_aCommands ArrayCreate128 );
    
g_aFlags ArrayCreate);

    
LoadCommands( );
}

public 
plugin_end( ) {
    
TrieDestroyg_tArrayPos );
    
ArrayDestroyg_aCommands );
    
ArrayDestroyg_aFlags );
}

LoadCommands( ) {
    new 
szFilename128 ], iFile;
    
get_configsdirszFilename127 );
    
addszFilename127"/say_macros.ini" );
    
    if( !
file_existsszFilename) ) {
        
iFile fopenszFilename"wt" );
        if( !
iFile )
            return;
        
fcloseiFile );
    }
    
    
iFile fopenszFilename"rt" );
    if( !
iFile ) {
        return;
    }
    
    new 
szData512 ], szCommand32 ], szExecute128 ], szFlags], iPos;
    while( !
feofiFile ) ) {
        
fgetsiFileszData511 );
        
        if( !
szData]
        || 
szData] == '^n'
        
|| szData] == ';'
        
|| szData] == '/' && szData] == '/' ) {
            return;
        }
        
        
parseszDataszCommand31szExecute127szFlags);
        
strtolowerszCommand );
        
TrieSetCellg_tArrayPosszCommandiPos );
        
ArrayPushStringg_aCommandsszExecute );
        
ArrayPushCellg_aFlagsread_flagsszFlags ) );
        
iPos++;
    }
    
    
fcloseiFile );
}

public 
CmdSayclient ) {
    static 
szCommand194 ];
    
read_argsszCommand193 );
    
remove_quotesszCommand );

    
strtolowerszCommand );
    static 
iArrayPos;
    if( 
TrieGetCellg_tArrayPosszCommandiArrayPos ) ) {
        if( !
accessclientArrayGetCellg_aFlagsiArrayPos ) ) ) {
            
client_printclientprint_chat"* You have no access to that command!" );
        } else {
            static 
szExecute128 ];
            
ArrayGetStringg_aCommandsiArrayPosszExecute127 );
                
            static 
szName34 ];
            
get_user_nameclientszName31 );
            
formatszName33"^"%s^""szName );
                
            static 
szAuthid37 ];
            
get_user_authidclientszAuthid34 );
            
formatszAuthid36"^"%s^""szAuthid );
                
            static 
szIP34 ];
            
get_user_ipclientszIP31);
            
formatszIP33"^"%s^""szIP );
                
            static 
szUserid];
            
formatexszUserid5"#%i"get_user_useridclient ) );
                
            
replace_allszExecute127"$name"szName );
            
replace_allszExecute127"$steamid"szAuthid );
            
replace_allszExecute127"$ip"szIP );
            
replace_allszExecute127"$userid"szUserid );
                
            
client_cmdclient"%s"szExecute );
                
            return 
PLUGIN_HANDLED;
        }
    }

    return 
PLUGIN_CONTINUE;

__________________
Impossible is Nothing

Last edited by Sylwester; 09-27-2009 at 19:15.
Sylwester is offline
terrum
AlliedModders Donor
Join Date: Apr 2006
Location: United Kingdom
Old 09-27-2009 , 20:04   Re: Plugin like df_responses (executes server commands)
Reply With Quote #6

Quote:
Originally Posted by Sylwester View Post
.ini file goes to amxmodx\configs
Now it will be automatically created if it does not exist.
say command is now exactly the same as in .ini file and you don't need to use "admin" prefix.
PHP Code:
#include < amxmodx >
#include < amxmisc >


new Trie:g_tArrayPos;
new Array:
g_aCommands;
new Array:
g_aFlags;

public 
plugin_init( ) {
    
register_plugin"Say Command Macro""0.0.2""Exolent" );

    
register_clcmd"say""CmdSay" );
    
    
g_tArrayPos TrieCreate( );
    
g_aCommands ArrayCreate128 );
    
g_aFlags ArrayCreate);

    
LoadCommands( );
}

public 
plugin_end( ) {
    
TrieDestroyg_tArrayPos );
    
ArrayDestroyg_aCommands );
    
ArrayDestroyg_aFlags );
}

LoadCommands( ) {
    new 
szFilename128 ], iFile;
    
get_configsdirszFilename127 );
    
addszFilename127"/say_macros.ini" );
    
    if( !
file_existsszFilename) ) {
        
iFile fopenszFilename"wt" );
        if( !
iFile )
            return;
        
fcloseiFile );
    }
    
    
iFile fopenszFilename"rt" );
    if( !
iFile ) {
        return;
    }
    
    new 
szData512 ], szCommand32 ], szExecute128 ], szFlags], iPos;
    while( !
feofiFile ) ) {
        
fgetsiFileszData511 );
        
        if( !
szData]
        || 
szData] == '^n'
        
|| szData] == ';'
        
|| szData] == '/' && szData] == '/' ) {
            return;
        }
        
        
parseszDataszCommand31szExecute127szFlags);
        
strtolowerszCommand );
        
TrieSetCellg_tArrayPosszCommandiPos );
        
ArrayPushStringg_aCommandsszExecute );
        
ArrayPushCellg_aFlagsread_flagsszFlags ) );
        
iPos++;
    }
    
    
fcloseiFile );
}

public 
CmdSayclient ) {
    static 
szCommand194 ];
    
read_argsszCommand193 );
    
remove_quotesszCommand );

    
strtolowerszCommand );
    static 
iArrayPos;
    if( 
TrieGetCellg_tArrayPosszCommandiArrayPos ) ) {
        if( !
accessclientArrayGetCellg_aFlagsiArrayPos ) ) ) {
            
client_printclientprint_chat"* You have no access to that command!" );
        } else {
            static 
szExecute128 ];
            
ArrayGetStringg_aCommandsiArrayPosszExecute127 );
                
            static 
szName34 ];
            
get_user_nameclientszName31 );
            
formatszName33"^"%s^""szName );
                
            static 
szAuthid37 ];
            
get_user_authidclientszAuthid34 );
            
formatszAuthid36"^"%s^""szAuthid );
                
            static 
szIP34 ];
            
get_user_ipclientszIP31);
            
formatszIP33"^"%s^""szIP );
                
            static 
szUserid];
            
formatexszUserid5"#%i"get_user_useridclient ) );
                
            
replace_allszExecute127"$name"szName );
            
replace_allszExecute127"$steamid"szAuthid );
            
replace_allszExecute127"$ip"szIP );
            
replace_allszExecute127"$userid"szUserid );
                
            
client_cmdclient"%s"szExecute );
                
            return 
PLUGIN_HANDLED;
        }
    }

    return 
PLUGIN_CONTINUE;

Thanks very much Works like a charm. Just a few things i want changed:
1. Can i have it so it executes the command on the server console instead of the client?
2. When someone types the message in chat, it doesn't show the message. I know people prefer to have it so they can't see the message but I like to see what is typed.

Thanks alot. +karma. Hope you can add the few things i wanted changed.
__________________
Thanks,
Terrum.


terrum is offline
Send a message via AIM to terrum Send a message via MSN to terrum Send a message via Skype™ to terrum
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-27-2009 , 21:28   Re: Plugin like df_responses (executes server commands)
Reply With Quote #7

Updated my post.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
terrum
AlliedModders Donor
Join Date: Apr 2006
Location: United Kingdom
Old 09-28-2009 , 11:11   Re: Plugin like df_responses (executes server commands)
Reply With Quote #8

Thanks. But now it doesn't work again lol
__________________
Thanks,
Terrum.


terrum is offline
Send a message via AIM to terrum Send a message via MSN to terrum Send a message via Skype™ to terrum
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 09-28-2009 , 11:13   Re: Plugin like df_responses (executes server commands)
Reply With Quote #9

lol

PHP Code:
#include < amxmodx >
#include < amxmisc >


new Trie:g_tArrayPos;
new Array:
g_aCommands;
new Array:
g_aFlags;

public 
plugin_init( ) {
    
register_plugin"Say Command Macro""0.0.3""Exolent" );

    
register_clcmd"say""CmdSay" );
    
    
g_tArrayPos TrieCreate( );
    
g_aCommands ArrayCreate128 );
    
g_aFlags ArrayCreate);

    
LoadCommands( );
}

public 
plugin_end( ) {
    
TrieDestroyg_tArrayPos );
    
ArrayDestroyg_aCommands );
    
ArrayDestroyg_aFlags );
}

LoadCommands( ) {
    new 
szFilename128 ], iFile;
    
get_configsdirszFilename127 );
    
addszFilename127"/say_macros.ini" );
    
    if( !
file_existsszFilename) ) {
        
iFile fopenszFilename"wt" );
        if( !
iFile )
            return;
        
fcloseiFile );
    }
    
    
iFile fopenszFilename"rt" );
    if( !
iFile ) {
        return;
    }
    
    new 
szData512 ], szCommand32 ], szExecute128 ], szFlags], iPos;
    while( !
feofiFile ) ) {
        
fgetsiFileszData511 );
        
        if( !
szData]
        || 
szData] == '^n'
        
|| szData] == ';'
        
|| szData] == '/' && szData] == '/' ) {
            return;
        }
        
        
parseszDataszCommand31szExecute127szFlags);
        
strtolowerszCommand );
        
TrieSetCellg_tArrayPosszCommandiPos );
        
ArrayPushStringg_aCommandsszExecute );
        
ArrayPushCellg_aFlagsread_flagsszFlags ) );
        
iPos++;
    }
    
    
fcloseiFile );
}

public 
CmdSayclient ) {
    static 
szCommand194 ];
    
read_argsszCommand193 );
    
remove_quotesszCommand );

    
strtolowerszCommand );
    static 
iArrayPos;
    if( 
TrieGetCellg_tArrayPosszCommandiArrayPos ) ) {
        if( !
accessclientArrayGetCellg_aFlagsiArrayPos ) ) ) {
            
client_printclientprint_chat"* You have no access to that command!" );
        } else {
            static 
szExecute128 ];
            
ArrayGetStringg_aCommandsiArrayPosszExecute127 );
                
            static 
szName34 ];
            
get_user_nameclientszName31 );
            
formatszName33"^"%s^""szName );
                
            static 
szAuthid37 ];
            
get_user_authidclientszAuthid34 );
            
formatszAuthid36"^"%s^""szAuthid );
                
            static 
szIP34 ];
            
get_user_ipclientszIP31);
            
formatszIP33"^"%s^""szIP );
                
            static 
szUserid];
            
formatexszUserid5"#%i"get_user_useridclient ) );
                
            
replace_allszExecute127"$name"szName );
            
replace_allszExecute127"$steamid"szAuthid );
            
replace_allszExecute127"$ip"szIP );
            
replace_allszExecute127"$userid"szUserid );
                
            
server_cmd"%s"szExecute );

            return 
PLUGIN_CONTINUE;
        }
    }

    return 
PLUGIN_CONTINUE;

__________________
Impossible is Nothing
Sylwester is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-28-2009 , 11:32   Re: Plugin like df_responses (executes server commands)
Reply With Quote #10

Quote:
Originally Posted by terrum View Post
Thanks. But now it doesn't work again lol
Are you doing this:
say "admin amx_cvar sv_password test"
Or:
say "amx_cvar sv_password test"
?


EDIT:

Nevermind. I know what I did wrong.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Old 09-28-2009, 14:10
terrum
This message has been deleted by terrum. Reason: Whoops, didn't see Sylwester's post before Exolent's :P
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 07:18.


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