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

RSSServer crashes amx_giveexp command on War3ft


MYGO.pl
 Udostępnij

Rekomendowane odpowiedzi

  • RSSy
Can it be fixed when I use the admin command "amx_givexp" to give someone EXP and the server crashes?

admin.inl
PHP Code:

/*
*    Admin Functions
*/

// Advanced Swear Filter and Punishment plugin uses this function
public ADMIN_ServerHandler()
{
    
// Make sure WC3 is loaded
    
if ( !WC3_Check() )
    {
        return 
PLUGIN_HANDLED;
    }

    new 
szCmd[32], szArg1[32], szArg2[32];
    
read_argv0szCmd31 );
    
read_argv1szArg131 );
    
read_argv2szArg231 );
    
    new 
id    str_to_numszArg1 );
    new 
iXP str_to_numszArg2 );

    if ( 
equalszCmd"amx_takexp" ) )
    {
        
iXP *= -1;

        
iXP += p_data[id][P_XP];
    }

    else if ( 
equalszCmd"changexp" ) )
    {
        
iXP += p_data[id][P_XP];
    }

    
ADMIN_SetXPidiXP );

    return 
PLUGIN_HANDLED;
}

// This will handle every admin client command
public ADMIN_Handlerid )
{
    new 
szCmd[32];
    
read_argv(0szCmd31);

    
// Make sure WC3 is loaded
    
if (!WC3_Check() && !equal(szCmd"wc3_disable") && !equal(szCmd"wc3_enable"))
    {
        
ADMIN_Print(id"%s WC3 has been disabled by an admin of this server"g_MODclient);
        return 
PLUGIN_HANDLED;
    }

    
// Make sure the user is an admin
    
if (!(get_user_flags(id) & XP_GetAdminFlag()))
    {
        
client_print(idprint_console"%L"id"YOU_HAVE_NO_ACCESS"g_MODclient);
        return 
PLUGIN_HANDLED;
    }

    
// OK we're free to go!!!

    
new szArg1[32], szArg2[32];
    
read_argv(1szArg131);
    
read_argv(2szArg231);

    
// Give the user XP
    
if (equal(szCmd"wc3_givexp") || equal(szCmd"amx_givexp"))
    {
        if ( 
read_argc() < )
        {
            
ADMIN_Printid"Format: %s <name|#id|auth|@TEAM|@ALL> <xp>"szCmd );

            return 
PLUGIN_HANDLED;
        }

        
ADMIN_GiveXPidszArg1str_to_numszArg2 ) );
    }

    
// Set the level of a user's race
    
else if ( equalszCmd"wc3_setlevel" ) )
    {
        if ( 
read_argc() < )
        {
            
ADMIN_Printid"Format: %s <name|#id|auth|@TEAM|@ALL> <level>"szCmd );

            return 
PLUGIN_HANDLED;
        }
        
        new 
iLevel str_to_numszArg2 );

        if ( 
iLevel || iLevel >= 11 )
        {
            
ADMIN_Printid"%s Error, level must be in between (or equal to) 0 and 10"g_MODclient );

            return 
PLUGIN_HANDLED;
        }

        
ADMIN_SetLevelidszArg1iLevel );
    }

    
// Give the user an item
    
else if ( equalszCmd"wc3_giveitem" ) )
    {
        if ( 
read_argc() < )
        {
            
ADMIN_Printid"Format: %s <name|#id|auth|@TEAM|@ALL> <item id or name>"szCmd );

            return 
PLUGIN_HANDLED;
        }

        new 
iItemID;
        if ( 
is_str_numszArg2 ) )
        {
            
iItemID str_to_numszArg2 );
            if ( 
iItemID 17 || iItemID )
            {
                
ADMIN_Printid"%s Error, item id must be in between (or equal to) 0 and 17"g_MODclient );

                return 
PLUGIN_HANDLED;
            }
        }

        
ADMIN_GiveItemidszArg1iItemID );
    }

    
// Enable the plugin
    
else if ( equalszCmd"wc3_enable" ) )
    {

        
// Plugin was already enabled, why re-enable?
        
if ( warcraft3 )
        {
            
ADMIN_Printid"%s The plugin was already enabled!"g_MODclient );
        }

        
// Enable the plugin!
        
else
        {
            
warcraft3 true;
            
ADMIN_Printid"%s Plugin enabled!"g_MODclient );
        }

    }

    
// Disable the plugin
    
else if ( equalszCmd"wc3_disable" ) )
    {
        
// Plugin was already enabled, why re-enable?
        
if ( !warcraft3 )
        {
            
ADMIN_Printid"%s The plugin was already disabled!"g_MODclient );
        }

        
// Disable the plugin!
        
else
        {
            
// What needs to happen here?
            //    - all skills set to 0 for each player
            //    - call SHARED_SetGravity
            //    - call SHARED_SetInvis
            //    - call SHARED_SetSpeed
            //    - stop tasks - like money task for dod
            //      - ULT_ClearIcons( id )


            
warcraft3 false;
            
ADMIN_Printid"%s Plugin disabled!"g_MODclient );
        }
    }
    
    new 
szArgs[128];
    
read_argsszArgs127 );

    
ADMIN_LogidszCmd"%s"szArgs );

    return 
PLUGIN_HANDLED;
}

// Actually set the user's XP
ADMIN_SetXPidiXP )
{
    if ( 
iXP )
    {
        
iXP 0;
    }

    
p_data[id][P_XP] = iXP;

    
XP_Checkid );

    
set_task0.3"WC3_GetUserInput"TASK_GETINPUT id );
}

// Set the user's level
ADMIN_SetLevelidszTarget[], iLevel )
{

    new 
iXP XP_GetByLeveliLevel );

    new 
iTarget 0bool:bTargetFound false;

    
// Do this while we continue having a target!
    
while ( ( iTarget FindTargetiTargetszTarget ) ) > )
    {
        
ADMIN_SetXPiTargetiXP );

        
client_printiTargetprint_chat"%s The admin has set your race's level to %d"g_MODclientiLevel );

        
bTargetFound true;
    }
    
    
// No target found :/
    
if ( !bTargetFound )
    {
        
ADMIN_NoTargetFoundidszTarget, ( iTarget == -) );
    }
}

// Give the user some XP
ADMIN_GiveXPidszTarget[], iXP )
{
    new 
iTarget 0bool:bTargetFound false;
    
    
// Do this while we continue having a target!
    
while ( ( iTarget FindTargetiTargetszTarget ) ) > )
    {
        
ADMIN_SetXPiTargetp_data[iTarget][P_XP] + iXP );

        
client_printiTargetprint_chat"%s %L"g_MODclientiTarget"THE_ADMIN_GAVE_YOU_EXPERIENCE"iXP );

        
bTargetFound true;
    }

    
// No target found :/
    
if ( !bTargetFound )
    {
        
ADMIN_NoTargetFoundidszTarget, ( iTarget == -) );
    }
}

// Give the user an item
ADMIN_GiveItemidszTarget[], iItemID )
{
    new 
szItemName[32];
    
LANG_GetItemName iItemIDidszItemName31 );

    new 
iTarget 0bool:bTargetFound false;

    
// Do this while we continue having a target!
    
while ( ( iTarget FindTargetiTargetszTarget ) ) > )
    {
        
client_printiTargetprint_chat"%s The admin has given you the item '%s'"g_MODclientszItemName );
        
        
ITEM_GiveItemiTargetiItemID );

        
bTargetFound true;
    }

    
// No target found :/
    
if ( !bTargetFound )
    {
        
ADMIN_NoTargetFoundidszTarget, ( iTarget == -) );
    }
}

// Find a user based on szTarget
FindTargetiLastIDszTarget[] )
{
    
    new 
iTarget = -1;

    
// Then we want to basically return everyone!
    
if ( equaliszTarget"@ALL" ) )
    {
        new 
players[32], iTotalPlayersi;
        
get_playersplayersiTotalPlayers );
        
        
// Loop through and search for the next target
        
for ( 0iTotalPlayersi++ )
        {
            
// Target found, so lets return the next one (if possible)!!
            
if ( players[i] == iLastID && != iTotalPlayers )
            {
                
iTarget players[i+1];
            }
        }

        
// No target was found so return the first one
        
if ( iTotalPlayers && iLastID == )
        {
            
iTarget players[0];
        }
    }

    
// Find a target based on the team
    
else if ( szTarget[0] == '@' )
    {
        new 
iTeam = -1;
        
        
// Counter-Strike and Condition Zero Checks
        
if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
        {
            if ( 
equaliszTarget"@T" ) )
            {
                
iTeam TEAM_T;
            }
            else if ( 
equaliszTarget"@CT" ) )
            {
                
iTeam TEAM_CT;
            }
        }
        
        
// Day of Defeat check
        
else if ( g_MOD == GAME_DOD )
        {
            if ( 
equaliszTarget"@ALLIES" ) )
            {
                
iTeam ALLIES;
            }
            else if ( 
equaliszTarget"@AXIS" ) )
            {
                
iTeam AXIS;
            }
        }

        
// Make sure a team was found
        
if ( iTeam != -)
        {
            new 
players[32], iTotalPlayersiiFirstPlayer = -1bool:bSaveNext false;
            
get_playersplayersiTotalPlayers );

            
// Loop through and search for the next target
            
for ( 0iTotalPlayersi++ )
            {            
                
// Make sure they're on the same team
                
if ( iTeam == get_user_teamplayers[i] ) )
                {
                    
                    
// This is the next available player
                    
if ( bSaveNext )
                    {
                        
iTarget players[i];
                        break;
                    }

                    
// If this is the previous target, we need to get the next one!
                    
if ( players[i] == iLastID )
                    {
                        
bSaveNext true;
                    }
                    
                    
// Save the FIRST player on this team
                    
if ( iFirstPlayer == -)
                    {
                        
iFirstPlayer players[i];
                    }
                }
            }

            
// No target was found so return the first one that matches the team (the target could still be -1 if iFirstPlayer wasn't found)
            
if ( iLastID == )
            {
                
iTarget iFirstPlayer;
            }
        }
    }

    
// Otherwise search for a player
    
else
    {
        
// Initial search is by player name
        
new iPlayer find_player"a"szTarget );
        
        
// If not found, search by partial match
        
if ( !iPlayer )
        {
            
iPlayer find_player"bl"szTarget );

            if ( 
iPlayer )
            {

                
// Then Multiple clients found
                
if ( iPlayer != find_player"blj"szTarget ) )
                {
                    return -
2;
                }
            }
        }

        
// If not found, search by auth id
        
if ( !iPlayer )
        {
            
iPlayer find_player"c" szTarget );
        }

        
// If not found, search by user id
        
if ( !iPlayer )
        {
            
// Make sure we have a user id
            
if ( szTarget[0] == '#' && szTarget[1] )
            {
                
iPlayer find_player"k"str_to_numszTarget[1] ) )
            }
        }
        
        
// Yay we have a match!!!
        
if ( iPlayer && iLastID != iPlayer )
        {
            
iTarget iPlayer;
        }
    }

    return 
iTarget;
}

ADMIN_NoTargetFoundidszTarget[], bool:bMulti )
{
    
// Multiple clients found
    
if ( bMulti )
    {
        
ADMIN_Printid"%s There is more than one client matching '%s'"g_MODclientszTarget );
    }

    else
    {
        
ADMIN_Printid"%s Unable to find target(s) '%s'"g_MODclientszTarget );
    }

    
// List what the available targets are
    
if ( g_MOD == GAME_CSTRIKE || g_MOD == GAME_CZERO )
    {
        
ADMIN_Printid"%s Available targets are: @ALL, @CT, @T or the player's name/auth/#id"g_MODclient );
    }

    else if ( 
g_MOD == GAME_DOD )
    {
        
ADMIN_Printid"%s Available targets are: @ALL, @ALLIES, @AXIS or the player's name/auth/#id"g_MODclient );
    }
}

// Function will print to server console or client console based on the ID number
ADMIN_Printidtext[], {Float,_}:...)
{    
    
// format the text as needed

    
new szFormattedText[128];
    
format_argsszFormattedText127);

    if ( 
id == )
    {
        
server_printszFormattedText );
    }
    else
    {
        
client_printidprint_consoleszFormattedText );
    }

    
// Gets rid of compiler warning
    
if ( text[0] == )
    {
        return;
    }
}  

// Adapted from war3x's log file (I was lazy)
ADMIN_LogidszCommand[], {Float,_}:... )
{

    new 
szLogFile[128];
    
get_configsdirszLogFile127 );
    
formatexszLogFile127"%s/war3ft/wc3_admin.log"szLogFile );

    new 
szFormattedText[128];
    
format_argsszFormattedText127);

    if ( !
file_existsszLogFile ) )
    {
        
write_fileszLogFile"WC3 : Frozen Throne", -);
        
write_fileszLogFile"Logging of admin commands", -);
        
write_fileszLogFile" ", -);
    }

    new 
szAdminName[32], szSteamID[32], szTeam[13];
    if ( 
id )
    {
        
get_user_nameidszAdminName31 );
        
get_user_authididszSteamID31 );
        
get_user_teamidszTeam12 );
    }
    else
    {
        
copyszAdminName31"SERVER" );
        
copyszSteamID31"SERVER" );
    }

    new 
szCurrentTime[32];
    
get_time"L %m/%d/%Y %H:%M:%:S"szCurrentTime31 );

    new 
szLogEntry[256];
    
formatexszLogEntry255"%s Cmd: ^"%s<%d><%s><%s>^" '%s %s'"szCurrentTimeszAdminNameget_user_useridid ), szSteamIDszTeamszCommandszFormattedText );

    
write_fileszLogFileszLogEntry, -);

    
// Gets rid of compiler warning
    
if ( szCommand[0] == )
    {
        return;
    }



Attached Files
File Type: sma Get Plugin or Get Source (war3ft.sma - 20.4 KB)

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ę...