Raised This Month: $51 Target: $400
 12% 

Top 15 for deathrun timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
WTFSkizo
Junior Member
Join Date: Jun 2016
Old 07-01-2016 , 06:35   Top 15 for deathrun timer
Reply With Quote #1

As the title says, i have a deathrun timer, it's that polish deathrun timer, it's possible a plugin that shows the best times on map? The plugin has the command /best which shows the best time, but i want to show the first 15 times, it's possible?
Code:
 /*
* DeathRunTimer
*
* Site : http://amxx.pl/deathrun-timer-save-records-t31649.html
* Author : Knopers
*/
#include <amxmodx>
#include <engine>
#include <hamsandwich>

#define _CustomButtons

#include "timer/buttons.inl"

#define RecordsSaveTo 1 // 1 - Nvault, 2 - MySQL 

#define TaskID 3456
#define DeadID 3356
new sMap[35];
new HudObj, StatusText, TimerType = 2;
new TimerS[33] = 0; 
new iBest, sBest[64] = "";
new g_iMaxPlayers;

#if RecordsSaveTo == 1
    #include "timer/nvault.inl" // -= Nvault =-
    #else 
    #if RecordsSaveTo == 2
        #include "timer/mysql.inl" // -= MySQL =-
    #endif
#endif

public plugin_init()
{
    register_plugin("DeathRun Timer + Save Record", "2.1", "Knopers");//Edited by Owner (Owner123);
    get_mapname(sMap, 34);
    
    RegisterHam(Ham_Spawn, "player", "EvSpawn", 1);
    RegisterHam(Ham_Killed, "player", "EvPlayerKilled", 1);
    register_logevent("eventResetTime", 2, "1=Round_Start");

    register_concmd("say /best", "ShowBest");
    
    register_cvar("amx_timer_type", "2"); // 1 - Hud, 2 - Status
    
    HudObj = CreateHudSyncObj();
    StatusText = get_user_msgid("StatusText");
    
    //
    // Buttons 
    //
    register_concmd("say /drtimermenu", "ShowMenu");
    RegisterHam(Ham_Use, "func_button", "EvUse", 0);
    entButton = engfunc(EngFunc_AllocString, "func_button");
    readButtons();
    
    #if defined _Timer_Save2Nvault
        h_vault = nvault_open("dr_records");
        LoadRecord();
    #else
    #if defined _Timer_Save2SQL
        register_cvar("timer_sql_host","127.0.0.1",FCVAR_PROTECTED)
        register_cvar("timer_sql_user","root",FCVAR_PROTECTED)
        register_cvar("timer_sql_pass","password",FCVAR_PROTECTED)
        register_cvar("timer_sql_database","baza123",FCVAR_PROTECTED)
        
        ConnectSql();
        //server_print("Loading Record ... [Step 1/4]"); //ForDebug
        set_task(10.0, "CheckRecord");
    #endif
    #endif
    
    g_iMaxPlayers = get_maxplayers();
}
public plugin_precache()
{
    #if defined _CustomButtons
    precache_model(gszButtonModels[0]);
    precache_model(gszButtonModels[1]);
    #else
    engfunc(EngFunc_PrecacheModel, "models/w_c4.mdl");
    #endif
}
public plugin_end()
{
    #if defined _Timer_Save2Nvault
        nvault_close(h_vault);
    #else
    #if defined _Timer_Save2SQL
        SQL_FreeHandle(SQL_TUPLE);
    #endif
    #endif
}
public client_disconnect(id)
{
    if(task_exists(id + TaskID))
        remove_task(id + TaskID);
    if(task_exists(id + DeadID))
        remove_task(id + DeadID);
}
public EvSpawn(id)
{
    TimerS[id] = 0;
    if(task_exists(TaskID + id))
        remove_task(TaskID + id);
    if(task_exists(id + DeadID))
        remove_task(id + DeadID);
    if(get_user_team(id) == 2 && !iOption[0])
        Start(id);
}
public EvPlayerKilled(iVictim, iAttacker)
{
    if(task_exists(TaskID + iVictim))
        remove_task(TaskID + iVictim);
    set_task(1.0, "DeadTask", iVictim + DeadID, _, _, "b");
    if(get_user_team(iVictim) == 1 && get_user_team(iAttacker) == 2 && !iOption[1])
        Finish(iAttacker, iVictim);
}
public Start(id)
{
    TimerS[id] = 0;
    if(get_user_team(id) == 2)
    {
        if(task_exists(id + TaskID))
            remove_task(id + TaskID);
        fnShowTimer(id + TaskID);
        set_task(1.0, "fnShowTimer", id + TaskID, _, _, "b");
    }
}
public Finish(id, idTT)
{
    if(TimerS[id] <= 10 || !task_exists(TaskID + id))
        return PLUGIN_CONTINUE;
    
    if(idTT > 0 && idTT < 33 && !iOption[1])
    {
        remove_task(TaskID + id);
        new svName[32], skName[32];
        get_user_name(idTT, svName, 31);
        get_user_name(id, skName, 31);
        new sMsg[128];
        format(sMsg, 127, "^x03%s ^x04finished the map in ^x03%02d:%02d ^x04and killed the terrorist ^1%s.", skName, TimerS[id] / 60, TimerS[id] % 60, svName);
        ColorChat(0, sMsg);
        if(TimerS[id] < iBest || iBest < 1)
        {
            iBest = TimerS[id];
            sBest = skName;
            
            format(sMsg, 127, "^x03%s ^x04made a new record on the map ^x03%02d:%02d", skName, TimerS[id] / 60, TimerS[id] % 60);
            ColorChat(0, sMsg);
            
            #if defined _Timer_Save2Nvault
                replace_all(sBest, 63, "^"", "''");
                SaveRecord();
            #else
            #if defined _Timer_Save2SQL
                //ColorChat(0, "^x04 Please Wait ... Saving record ... [Step 1/4]"); //ForDebug
                replace_all(sBest, 63, "'", "\'");
                replace_all(sBest, 63, "`", "\`");
                //ColorChat(0, "^x04 Please Wait ... Saving record ... [Step 2/4]"); //ForDebug
                Save2SQL();
            #endif
            #endif
        }
        else
        {
            format(sMsg, 127, "^x03%s ^x04didn't beat the best record. Best Record is: ^x03%02d:%02d", skName, iBest / 60, iBest % 60);
            ColorChat(0, sMsg);
        }
    }
    else
    {
        remove_task(TaskID + id);
        new sName[32];
        get_user_name(id, sName, 31);
        new sMsg[128];
        format(sMsg, 127, "^x03%s ^x04finished the map in: ^x03%02d:%02d", sName, TimerS[id] / 60, TimerS[id] % 60);
        ColorChat(0, sMsg);
        if(TimerS[id] < iBest || iBest < 1)
        {
            iBest = TimerS[id];
            sBest = sName;
            
            format(sMsg, 127, "^x03%s ^x04made a new record on the map: ^x03%02d:%02d ", sName, TimerS[id] / 60, TimerS[id] % 60);
            ColorChat(0, sMsg);
            
            #if defined _Timer_Save2Nvault
                replace_all(sBest, 63, "^"", "''");
                SaveRecord();
            #else
            #if defined _Timer_Save2SQL
                //ColorChat(0, "^x04 Please Wait ... Saving record ... [Step 1/4]"); //ForDebug
                replace_all(sBest, 63, "'", "\'");
                replace_all(sBest, 63, "`", "\`");
                //ColorChat(0, "^x04 Please Wait ... Saving record ... [Step 2/4]"); //ForDebug
                Save2SQL();
            #endif
            #endif
        }
        else
        {
            format(sMsg, 127, "^x03%s ^x04didn't beat the best record. Best Record is: ^x03%02d:%02d ", sName, iBest / 60, iBest % 60);
            ColorChat(0, sMsg);
        }
    }
    TimerType = get_cvar_num("amx_timer_type");
    return PLUGIN_CONTINUE;
}
public fnShowTimer(idTask)
{
    new id = idTask - TaskID;
    TimerS[id] ++;
    if(TimerType == 1)
    {
        set_hudmessage(255, 255, 255, 0.1, 0.9, 2, 0.05, 1000.0, 0.1, 3.0, -1);
        ShowSyncHudMsg(id, HudObj, "Timer: %02d:%02d", TimerS[id] / 60, TimerS[id] % 60);
    }
    else
    {
        new sSMsg[32];
        format(sSMsg, 31, "Timer: %02d:%02d", TimerS[id] / 60, TimerS[id] % 60);
        message_begin(MSG_ONE, StatusText, {0,0,0}, id);
        write_byte(0);
        write_string(sSMsg);
        message_end();
    }
}

public eventResetTime()
{
    for(new id = 1; id < g_iMaxPlayers; id++)
    {
        if(!is_user_connected(id) || !is_user_alive(id))
            continue;
        
        if(!task_exists(id + TaskID))
            continue;
        
        remove_task(id + TaskID);
        TimerS[id] = 0;
        set_task(1.0, "fnShowTimer", id + TaskID, _, _, "b");
    }
}

public ShowBest(id)
{
    new sMsg[128];
    
    if(!sBest[0])
        format(sMsg, 127, "^x04There is no record on this map.");
    else
        format(sMsg, 127, "^x04Map Record : ^x03%s ^1-- ^x04%02d:%02d", sBest, iBest / 60, iBest % 60);
    
    #if defined _Timer_Save2SQL
    if(!g_bRecordLoaded)
        format(sMsg, 127, "^x04Loading records, please wait ...");
    #endif
    
    ColorChat(0, sMsg);
}
stock ColorChat(id, sMessage[])
{
    new SayText = get_user_msgid("SayText");
    if(id == 0)
    {
        for(new i = 1; i < 33; i++)
        {
            if(is_user_connected(i))
            {
                message_begin(MSG_ONE, SayText, { 0, 0, 0 }, i);
                write_byte(i);
                write_string(sMessage);
                message_end();
            }
        }
    }
    else
    {
        message_begin(MSG_ONE, SayText, { 0, 0, 0 }, id);
        write_byte(id);
        write_string(sMessage);
        message_end();
    }
}
public DeadTask(Spect)
{
    Spect -= DeadID;
    if(!is_user_connected(Spect) || is_user_alive(Spect))
    {
        remove_task(Spect + DeadID);
        return PLUGIN_CONTINUE;
    }
    new id = entity_get_int(Spect, EV_INT_iuser2);
    if(id <= 0 || id >= 33 || !is_user_alive(id))
        return PLUGIN_CONTINUE;
    new Name[32];
    get_user_name(id, Name, 31);
    
    set_hudmessage(255, 255, 255, -1.0, 0.2, 2, 0.05, 1.0, 0.1, 3.0, -1);
    ShowSyncHudMsg(Spect, HudObj, "Player: %s ^nPlayer time: %02d:%02d", Name, TimerS[id] / 60, TimerS[id] % 60);
    
    return PLUGIN_CONTINUE;
}

Last edited by WTFSkizo; 07-01-2016 at 06:38.
WTFSkizo is offline
WTFSkizo
Junior Member
Join Date: Jun 2016
Old 07-02-2016 , 18:59   Re: Top 15 for deathrun timer
Reply With Quote #2

UP !
WTFSkizo is offline
Amine Belokda
Senior Member
Join Date: Oct 2015
Location: ML_NOT_FOUND
Old 07-05-2016 , 01:50   Re: Top 15 for deathrun timer
Reply With Quote #3

goto kz plugin and download kz_top15
__________________
Amine Belokda is offline
Send a message via MSN to Amine Belokda
WTFSkizo
Junior Member
Join Date: Jun 2016
Old 08-01-2016 , 10:45   Re: Top 15 for deathrun timer
Reply With Quote #4

UP !
WTFSkizo 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 19:02.


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