Привязать функцию к эвенту в Timer

wayLANder

Где AlmazON?
Сообщения
1,742
Реакции
577
Здравствуйте. Имеется таймер
Суть редактирования плагина - нужно сделать так, чтобы при входе игроком в End Zone (прохождении карты) - выдавались кредиты в Shop и Store

Это нужно добавить к событию:
Shop:
Shop_SetClientCredits (client, 1000);
PrintToChatAll("\x05[MG Timer] \x02 \x04%N \x02прошёл карту и получил \x041000 \x04кредитов в !shop", client);

Store:
Store_SetClientCredits (client, 1000);
PrintToChatAll("\x05[MG Timer] \x02 \x04%N \x02completed a map and gained \x041000 \x04credits in !store", client);

P.s если есть какие-то ещё события в таймере, помимо простого прохождения карты (улучшение рекорда карты, личного рекорда итд) - то ценники можете слегка понизить по своему усмотрению.
 
Последнее редактирование:

Rostu

Добрая душа
Сообщения
986
Реакции
623
@Иванчо Бальбовски, Попробуй в influx_recchat.sp добавить выдачу в конце а точнее после Influx_PrintToChatEx.
Оффтоп
 
Последнее редактирование:

wayLANder

Где AlmazON?
Сообщения
1,742
Реакции
577
@Rostu, Оффтоп
Спасибо, попробую
--- Добавлено позже ---
@Rostu, я кстати туда и пробовал, но у меня были кучи ошибок, связанные с sz... итд
Можете проверить компиляцию? Я просто не дома сейчас, и не смогу лог компила скинуть :(
Ну и исходничек, если сможете скомпилить :)
--- Добавлено позже ---
@Rostu,
//SourceMod Batch Compiler
// by the SourceMod Dev Team


//// influx_recchat.sp
//
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(150) : warning 217: loose indentation
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(188 -- 189) : error 017: undefined symbol "iClient"
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(188 -- 189) : error 001: expected token: ",", but found ";"
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(190) : warning 217: loose indentation
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191 -- 192) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191 -- 193) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191 -- 194) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191 -- 195) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191 -- 196) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191 -- 197) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191 -- 198) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(191 -- 199) : warning 215: expression has no effect
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(199) : error 001: expected token: ";", but found ")"
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(199) : error 029: invalid expression, assumed zero
// C:\Users\wayLANder\Desktop\═ютр яряър\influx_recchat.sp(199) : warning 215: expression has no effect
//
// 4 Errors.
//
// Compilation Time: 0,87 sec
// ----------------------------------------

Press enter to exit ...


C-подобный:
#include <sourcemod>

#include <influx/core>

#undef REQUIRE_PLUGIN
#include <influx/hud>
#include <shop>

ConVar g_ConVar_MinTime;
ConVar g_ConVar_NumDecimals;

bool g_bLib_Hud;


public Plugin myinfo =
{
    author = INF_AUTHOR,
    url = INF_URL,
    name = INF_NAME..." - Chat Records",
    description = "Displays records in chat.",
    version = INF_VERSION
};

public void OnPluginStart()
{
    g_ConVar_MinTime = CreateConVar( "influx_recchat_mintimeformsg", "10", "If record is shorter than this, don't do a chat message.", FCVAR_NOTIFY );
    g_ConVar_NumDecimals = CreateConVar( "influx_recchat_numdecimals", "2", "Number of decimals to use when printing to chat.", FCVAR_NOTIFY, true, 0.0, true, 3.0 );
    
    
    AutoExecConfig( true, "recchat", "influx" );
    
    
    g_bLib_Hud = LibraryExists( INFLUX_LIB_HUD );
}

public void OnLibraryAdded( const char[] lib )
{
    if ( StrEqual( lib, INFLUX_LIB_HUD ) ) g_bLib_Hud = true;
}

public void OnLibraryRemoved( const char[] lib )
{
    if ( StrEqual( lib, INFLUX_LIB_HUD ) ) g_bLib_Hud = false;
}

public void Influx_OnRequestResultFlags()
{
    Influx_AddResultFlag( "Don't print record chat message", RES_CHAT_DONTPRINT );
}

stock bool ShouldPrint( float time, int flags )
{
    // We don't want to print for this run.
    if ( flags & RES_CHAT_DONTPRINT ) return false;
    
    
    // Let them see best records always!
    if ( flags & (RES_TIME_ISBEST | RES_TIME_FIRSTREC) ) return true;
    
    
    // Must be more than this.
    return ( time > g_ConVar_MinTime.FloatValue );
}

stock bool CanPrintToClient( int client, int finisher, int flags )
{
    int hideflags = Influx_GetClientHideFlags( client );
    
    // Allow my own sounds.
    if ( client == finisher )
    {
        return ( hideflags & HIDEFLAG_CHAT_PERSONAL ) ? false : true;
    }
    
    // Allow best sounds.
    if ( flags & (RES_TIME_ISBEST | RES_TIME_FIRSTREC) )
    {
        return ( hideflags & HIDEFLAG_CHAT_BEST ) ? false : true;
    }
    
    return ( hideflags & HIDEFLAG_CHAT_NORMAL ) ? false : true;
}

public void Influx_OnTimerFinishPost( int client, int runid, int mode, int style, float time, float prev_pb, float prev_best, int flags )
{
    if ( !ShouldPrint( time, flags ) ) return;
    
    
    int nClients = 0;
    int[] clients = new int[MaxClients];
    
    
    for ( int i = 1; i <= MaxClients; i++ )
    {
        if ( IsClientInGame( i ) && !IsFakeClient( i ) )
        {
            if ( g_bLib_Hud )
            {
                if ( !CanPrintToClient( i, client, flags ) ) continue;
            }
            
            clients[nClients++] = i;
        }
    }
    
    if ( !nClients ) return;
    
    
    bool isbest = ( flags & RES_TIME_ISBEST ) ? true : false;
    
    // Format our second formatting string.
    decl String:szFormSec[10];
    Inf_DecimalFormat( g_ConVar_NumDecimals.IntValue, szFormSec, sizeof( szFormSec ) );
    
    
    decl String:szName[MAX_NAME_LENGTH];
    decl String:szForm[10];
    decl String:szRun[MAX_RUN_NAME];
    decl String:szMode[64];
    decl String:szStyle[64];
    decl String:szRec[64];
    decl String:szImprove[64];
    
    if ( prev_best != INVALID_RUN_TIME )
    {
        int c;
        
        Inf_FormatSeconds( Inf_GetTimeDif( time, prev_best, c ), szForm, sizeof( szForm ), szFormSec );
        
        FormatEx( szRec, sizeof( szRec ), " {CHATCLR}({%s}%c%s{CHATCLR})",
            isbest ? "LIGHTRED" : "GREEN", // Is new best?
            c,
            szForm );
    }
    else
    {
        szRec[0] = '\0';
    }
    
    if ( time < prev_pb )
    {
        // Display more decimals if time is smaller than our formatting.
        decl String:sec[12];
        
        float dif = prev_pb - time;
        
        
        FormatEx( sec, sizeof( sec ), ( dif < 0.1 ) ? "%.3f" : "%.1f", dif );
        
        FormatEx( szImprove, sizeof( szImprove ), " {LIGHTYELLOW}Личный рекорд улучшен на %s сек.", sec );   
    }
    else
    {
        szImprove[0] = '\0';
    }
    
    Inf_FormatSeconds( time, szForm, sizeof( szForm ), szFormSec );
    
    if ( Influx_ShouldModeDisplay( mode ) )
    {
        Influx_GetModeShortName( mode, szMode, sizeof( szMode ) );
        Format( szMode, sizeof( szMode ), "{GREY}[{PINK}%s{GREY}]", szMode );
    }
    else
    {
        szMode[0] = '\0';
    }
    
    
    if ( Influx_ShouldStyleDisplay( style ) )
    {
        Influx_GetStyleShortName( style, szStyle, sizeof( szStyle ) );
        Format( szStyle, sizeof( szStyle ), "[{PINK}%s{GREY}]", szStyle ); // {CHATCLR}
    }
    else
    {
        szStyle[0] = '\0';
    }
    
    
    
    Influx_GetRunName( runid, szRun, sizeof( szRun ) );
    
    
    GetClientName( client, szName, sizeof( szName ) );
    Influx_RemoveChatColors( szName, sizeof( szName ) );
    
    Influx_PrintToChatEx( _, client, clients, nClients, "{MAINCLR1}%s{CHATCLR} finished {MAINCLR1}%s{CHATCLR} in %s!%s%s%s%s%s%s",
    Shop_GiveClientCredits(iClient,500,IGNORE_FORWARD_HOOK);
    PrintToChatAll("\x05[MG Timer] \x02 \x04%N \x02прошёл карту и получил \x04500 \x04кредитов в !shop", client);
        szName,
        szRun,
        szForm,
        szRec,
        szImprove,
        ( szMode[0] != '\0' ) ? " " : "",
        szMode,
        ( szStyle[0] != '\0' ) ? " " : "",
        szStyle );
}
 
Последнее редактирование:

Похожие темы

Ответы
606
Просмотры
99К
Сверху Снизу