Skocz do zawartości

Nowy szablon forum

mygo.pl

Stworzyliśmy dla Was nowy wygląd forum. Z pewnością znajdziesz rzeczy, które wg Ciebie mogą zostać zmienione - wspomnij o tym w specjalnym wątku.

Czytaj więcej

Jak założyć własną sieć

serwerów CS

Zastanawiasz się nad prowadzeniem własnej sieci serwerów? Przeczytaj podstawowe informacje, na które należy zwrócić uwagę, przy takim projekcie.

Czytaj więcej

Tworzymy spis sieci

dodaj swoją

Dodaj sieć do której należysz, pozwoli to na promocję i budowę ogólnopolskiej bazy sieci CS.

Czytaj więcej

RSSExecute server commands


MYGO.pl
 Udostępnij

Rekomendowane odpowiedzi

  • RSSy
Hi,

I found a plugin online, and I don't remember exactly where I took it (here or from other communities) and now I can't find it, and I'd like to make a small modification to .sma if it is possible, but I'm not a AMXX Developer, so I want someone to do it from for me.

.SMA File
Code:

#include < amxmodx >
#include < amxmisc >
#include < celltrie >

#define MAX_ARGS 5
#define MAX_ARG_LEN 64

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

public plugin_init( ) {
    register_plugin( "Say Command Macro", "0.0.2", "Exolent" );
   
    register_clcmd( "say", "CmdSay" );
   
    g_tArrayPos = TrieCreate( );
    g_aCommands = ArrayCreate( 128 );
    g_aFlags = ArrayCreate( 1 );
    g_aHideCmd = ArrayCreate( 1 );
   
    LoadCommands( );
}

public plugin_end( ) {
    TrieDestroy( g_tArrayPos );
    ArrayDestroy( g_aCommands );
    ArrayDestroy( g_aFlags );
    ArrayDestroy( g_aHideCmd );
}

LoadCommands( ) {
    new szFilename[ 128 ];
    get_configsdir( szFilename, 127 );
    add( szFilename, 127, "/say_macros.ini" );
   
    if( !file_exists( szFilename) ) {
        new iFile = fopen( szFilename, "wt" );
        if( iFile ) {
            fclose( iFile );
        }
        return;
    }
   
    new iFile = fopen( szFilename, "rt" );
    if( !iFile ) {
        return;
    }
   
    new szData[ 512 ], szCommand[ 32 ], szExecute[ 128 ], szFlags[ 27 ], szHide[ 2 ], iPos;
    while( !feof( iFile ) ) {
        fgets( iFile, szData, 511 );
        trim( szData );
       
        if( !szData[ 0 ]
        || szData[ 0 ] == ';'
        || szData[ 0 ] == '/' && szData[ 1 ] == '/' ) {
            continue;
        }
       
        parse( szData, szCommand, 31, szExecute, 127, szFlags, 26, szHide, 1 );
        strtolower( szCommand );
        TrieSetCell( g_tArrayPos, szCommand, iPos );
        ArrayPushString( g_aCommands, szExecute );
        ArrayPushCell( g_aFlags, read_flags( szFlags ) );
        ArrayPushCell( g_aHideCmd, str_to_num( szHide ) );
        iPos++;
    }
   
    fclose( iFile );
}


public CmdSay( client ) {
    static szMessage[ 194 ], len, i, j, k, szTmp[ 5 ];
    static szArg[MAX_ARGS][MAX_ARG_LEN], argsCnt;
    read_args( szMessage, 193 );

    len = strlen(szMessage)-1
    argsCnt = i = j = 0
    k = -1
    while(++i<len){
        if(k>=0){
            if(szMessage[i] == '^"'){
                szArg[argsCnt++][k] = '^0';
                k=-1;
                j += formatex( szMessage[j], 193-j, "$%d", argsCnt );
            }else{
                if(k<MAX_ARG_LEN)
                    szArg[argsCnt][k++] = szMessage[i];
            }
        }else{
            if(szMessage[i] == '^"'){
                if(argsCnt<MAX_ARGS)
                    k=0;
            }else{
                szMessage[j++] = szMessage[i];
            }
        }
    }
    szMessage[j] = '^0';
    if(k!=-1){
        szArg[argsCnt++][k] = '^0';
    }
    strtolower( szMessage );

    static iArrayPos;
    if( TrieGetCell( g_tArrayPos, szMessage, iArrayPos ) ) {
        if( !access( client, ArrayGetCell( g_aFlags, iArrayPos ) ) ) {
            client_print( client, print_chat, "* You have no access to that command!" );
        } else {
            static szExecute[ 128 ];
            ArrayGetString( g_aCommands, iArrayPos, szExecute, 127 );
           
            static szName[ 32 ];
            get_user_name( client, szName, 31 );
            replace_all( szName, 31, "'", "" );
            replace_all( szName, 31, "^"", "" );
           
            static szAuthid[ 35 ];
            get_user_authid( client, szAuthid, 34 );
           
            static szIP[ 32 ];
            get_user_ip( client, szIP, 31, 1 );
           
            static szUserid[ 6 ];
            formatex( szUserid, 5, "#%i", get_user_userid( client ) );
           
            replace_all( szExecute, 127, "''", "^"" );
            replace_all( szExecute, 127, "$name", szName );
            replace_all( szExecute, 127, "$steamid", szAuthid );
            replace_all( szExecute, 127, "$ip", szIP );
            replace_all( szExecute, 127, "$userid", szUserid );
            for( i=0; i<argsCnt; i++ ) {
                format( szTmp, 4, "$%d", i+1);
                replace_all( szExecute, 127, szTmp, szArg[i] );
            }

            server_cmd( "%s", szExecute );
           
            if( ArrayGetCell( g_aHideCmd, iArrayPos ) ) {
                return PLUGIN_HANDLED;
            }
        }
    }
   
    return PLUGIN_CONTINUE;
}

I'll explain exactly what I need, and I think it won't be difficult for you to edit it.

I finished and used the config file for this plugin, and added what I want, but there is something I want to make it work differently.

This plugin mainly works when typing in chat:

!kick "nick" "reason"
!slap "name" "power"

But the problem now is that I need to write "" quotes to make the plugin work, but I want to make it work, with and without the quotes:

!kick nick reason, and !kick "nick" "reason"

Config File:
Code:

; "say command" "execute command" "admin flags" "hide command from chat"
;
; Example:
; "menu" "amxmodxmenu" "u" "1"
; This will work when you say:
; say "menu"
; And it will hide your text "menu" from chat
;
; To not hide the text, leave that part out, or set it to 0
; Example:
; "menu" "amxmodxmenu" "u"
; "kickmenu" "amx_kickmeu" "u" "0"
;
; 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"
;
; You can also use '' (two apostrophes) to represent quotes inside of the execute command,
; since (example) "amx_nick "name1" "name2"" would cause errors.
;
; Example:
; "gametype hns" "amx_gametype ''HideNSeek Mod''; exec ''addons/amxmodx/configs/hidenseek.cfg''; sv_restart 1" "a"
;
; If you are using the $name, $ip, or $steamid in a way that needs quotes,
; you will need to add them yourself.
;
; Example:
; "ban me" "amx_ban ''$steamid'' 0 ''lol banned myself :D''" ""
;
;
; Passing arguments from chat to execute command:
; before comparing chat input to defined say commands, all "CONTENT" are replaced with $1, $2, $3
; after that all $number in execute command are replaced with adequate CONTENT
;
; Example1:
; "csay $1 color $2" "amx_csay $2 $name said $1 using $2 color" ""
; now if player named Player1 write in chat: csay "some message" color "green"
; then it will trigger in server console: "amx_csay green Player1 said some message using green color"
;
; Example2;
; "!nick $1 $2" "amx_nick ''$1'' ''$2''" ""
; now writing in chat: !nick "player1" "test nick"
; will trigger in server console: "amx_nick ^"Player1^" ^"test nick^""
;
; More examples (you can use them all at the same time):
; "!kick $1" "amx_kick ''$1''" "c"    ;kick without reason
; "!kick $1 $2" "amx_kick ''$1'' ''$2''" "c"    ;kick with reason
; "!ban5 $1" "amx_ban ''$1'' 5" "d"    ;short ban without reason
; "!ban5 $1 $2" "amx_ban ''$1'' 5 ''$2''" "d"    ;short ban with reason
; "!pban $1 $2" "amx_ban ''$1'' 0 ''$2''" "d"    ;permanent ban with reason
; "!hostname $1" "hostname ''$1''" "a"    ;set hostname
---------------------------------------------------------------------------
"!amxmodmenu" "amxmodmenu"
"!banmenu" "amx_banmenu"
"!kickmenu" "amx_kickmenu"
"!gagmenu" "amx_gagmenu"
"!slapmenu" "amx_slapmenu"
"!slaymenu" "amx_slapmenu"
"!showloc" "amx_showloc"
"!who" "amx_who"
---------------------------------------------------------------------------
"!kick $1" "amx_kick ''$1''"
"!kick $1 $2" "amx_kick ''$1'' ''$2''"
"!slay $1" "amx_slay $1"
"!slap $1" "amx_slap ''$1''"
"!slap $1 $2" "amx_slap ''$1'' ''$2''"
---------------------------------------------------------------------------

Thanks for your time!

Przeczytaj cały wpis

Odnośnik do komentarza
Udostępnij na innych stronach

Gość
Ten temat został zamknięty. Brak możliwości dodania odpowiedzi.
 Udostępnij

  • Ostatnio przeglądający   0 użytkowników

    • Brak zarejestrowanych użytkowników przeglądających tę stronę.
×
×
  • Dodaj nową pozycję...