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

Plugin Change


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jgtyui
Junior Member
Join Date: Jun 2010
Old 05-09-2020 , 11:37   Plugin Change
Reply With Quote #1

I have this plugin
PHP Code:
#include <amxmodx>
#include <engine>
#include <hamsandwich>
#include <nvault>
#include <sqlx>
#include <geoip>

#pragma semicolon 1

// Here you can configure main settings

// #define COLORCHAT

new const g_szPrefix[] = "DeathRun";

const 
MAX_PLAYERS 32;

#define ADMIN_ACCESS ADMIN_CVAR

// Here you stop

#if defined COLORCHAT
    #include <colorchat>
#endif

/* Macro */

#define set_bit(%1,%2)    (%1 |= (1<<%2))
#define get_bit(%1,%2)    (%1 & (1<<%2))
#define clr_bit(%1,%2)    (%1 &= ~(1<<%2))

/* Macro */

new const g_szVersion[] = "0.1";

new const 
g_szTableName[] = "DEATHRUN_STATS";

new 
g_pWebLink;

new 
Handle:g_hSqlTuple;

new 
bool:g_bSqlite;

new 
g_szMapName[64];

new 
Trie:g_tStartsTrie:g_tStops;

new 
bool:g_bTimerFound;

enum _:eTimer
{
    
START,
    
STOP
};

new 
g_szTimerModels[eTimer][] =
{
    
"models/deathrun/timer/timer_start.mdl",
    
"models/deathrun/timer/timer_stop.mdl"
};
new 
g_szTimerName[eTimer][] =
{
    
"Start",
    
"Stop"
};

new 
g_iTimer[eTimer];
new 
Float:g_vTimerOrigin[eTimer][3];

new 
g_iTimerAngles[eTimer];
new 
Float:g_flTimerAngles[4] =
{
    
0.0,
    
90.0,
    
180.0,
    
270.0
};

new 
g_iPlayerTimer[MAX_PLAYERS 1];

new 
g_bConnectedg_bAliveg_bStarted;

new 
Float:g_flStartTime[MAX_PLAYERS 1], Float:g_flFinishTime[MAX_PLAYERS 1];

new 
g_iVault;

new 
g_iMsgRoundTime;

new 
g_iHudSyncObj;

public 
plugin_precache()
{
    for (new 
0eTimeri++)
        
precache_model(g_szTimerModels[i]);
}
public 
plugin_init()
{
    
register_plugin("DeathRun Timer"g_szVersion"deniS");
    
    
g_pWebLink register_cvar("dr_timer_web_link""http://link");// link to web files
    
    
register_cvar("dr_timer_sql_host""host");
    
register_cvar("dr_timer_sql_user""login");
    
register_cvar("dr_timer_sql_pass""password");
    
register_cvar("dr_timer_sql_db""deathrun_timer.db"); /* If you don't have web server, you can use local stats, just add .db like deathrun_stats.db and enable sqlite module! */
    
    
get_mapname(g_szMapNamecharsmax(g_szMapName));
    
    
g_tStarts    TrieCreate();
    
g_tStops    TrieCreate();
    
    new 
iiSize;
    
    new const 
szStarts[][] =
    {
        
"counter_start""clockstartbutton""firsttimerelay""but_start""counter_start_button",
        
"multi_start""timer_startbutton""start_timer_emi""gogogo"
    
};
    
iSize sizeof(szStarts);
    
    for (
0iSizei++)
        
TrieSetCell(g_tStartsszStarts[i], 1);
    
    new const 
szStops[][] =
    {
        
"counter_off""clockstopbutton""clockstop""but_stop""counter_stop_button",
        
"multi_stop""stop_counter""m_counter_end_emi"
    
};
    
iSize sizeof(szStops);
    
    for (
0iSizei++)
        
TrieSetCell(g_tStopsszStops[i], 1);
    
    new 
iEntity = -1;
    
    while ((
iEntity find_ent_by_class(iEntity"func_button")) != 0)
    {
        new 
szTargetName[64];
        
entity_get_string(iEntityEV_SZ_targetnameszTargetNamecharsmax(szTargetName));
        
        if (
TrieKeyExists(g_tStartsszTargetName) || TrieKeyExists(g_tStopsszTargetName))
        {
            if (!
g_bTimerFound)
                
g_bTimerFound true;
            
            break;
        }
    }
    
    if (!
g_bTimerFound)
    {
        
TrieDestroy(g_tStarts);
        
TrieDestroy(g_tStops);
        
        new 
szFile[96];
        
formatex(szFilecharsmax(szFile), "deathrun/timer/%s"g_szMapName);
        
        
g_iVault nvault_open(szFile);
        
        
LoadTimers();
    }
    
    
iEntity create_entity("info_target");
    
    if (
iEntity)
    {
        
entity_set_float(iEntityEV_FL_nextthinkget_gametime() + 0.5);
        
entity_set_string(iEntityEV_SZ_classname"_TimerThink");
        
register_think("_TimerThink""TimerThink");
    }
    
    
g_iMsgRoundTime get_user_msgid("RoundTime");
    
    
RegisterHam(Ham_Spawn"player""HamSpawnPlayer_Post"true);
    
RegisterHam(Ham_Killed"player""HamKilledPlayer_Post"true);
    
RegisterHam(Ham_Use"func_button""HamUseFuncButton_Pre"false);
    
    
register_clcmd("say /timer""ClCmdTimer");
    
register_clcmd("say_team /timer""ClCmdTimer");
    
    
register_clcmd("say /best""ClCmdBest");
    
register_clcmd("say_team /best""ClCmdBest");
    
    
g_iHudSyncObj CreateHudSyncObj();
}
public 
plugin_cfg()
{
    
set_task(0.5"DB_Init");
}
public 
DB_Init()
{
    
state mysql;
    
    new 
szDB[64];
    
get_cvar_string("dr_timer_sql_db"szDBcharsmax(szDB));
    
    if (
contain(szDB".") > 0)
    {
        
state sqlite;
        
        
g_bSqlite true;
    }
    
    
SQL_Init();
}
SQL_Init()<mysql>
{
    new 
szHost[64], szUser[64], szPass[64], szDB[64];
    
get_cvar_string("dr_timer_sql_host"szHostcharsmax(szHost));
    
get_cvar_string("dr_timer_sql_user"szUsercharsmax(szUser));
    
get_cvar_string("dr_timer_sql_pass"szPasscharsmax(szPass));
    
get_cvar_string("dr_timer_sql_db"szDBcharsmax(szDB));
    
    
g_hSqlTuple SQL_MakeDbTuple(szHostszUserszPassszDB);
    
    new 
szQuery[512];
    
    
formatex
    
(
        
szQuerycharsmax(szQuery),
        
"CREATE TABLE IF NOT EXISTS `%s` \
        ( \
            `ID`                INT                NOT NULL    AUTO_INCREMENT, \
             \
            `MAPNAME`            VARCHAR(64)        NOT NULL, \
            `AUTHID`            VARCHAR(32)        NOT NULL, \
            `NICKNAME`            VARCHAR(64)        NOT NULL, \
            `IP`                VARCHAR(45)        NOT NULL, \
            `COUNTRY_FULL`        VARCHAR(45)        NOT NULL, \
            `COUNTRY_SHORT`        VARCHAR(3)        NOT NULL, \
            `TIME`                DOUBLE            NOT NULL, \
            `DATE`                DATETIME        NOT NULL, \
             \
            PRIMARY KEY(`ID`) \
        )"
,
        
g_szTableName
    
);
    
    
SQL_ThreadQuery(g_hSqlTuple"Sql_IgnoredQuery_Handler"szQuery);
}
SQL_Init()<sqlite>
{
    
SQL_SetAffinity("sqlite");
    
    new 
szDataDir[128];
    
get_localinfo("amxx_datadir"szDataDircharsmax(szDataDir));
    
    new 
szDB[64];
    
get_cvar_string("dr_timer_sql_db"szDBcharsmax(szDB));
    
    new 
szFile[196];
    
formatex(szFilecharsmax(szFile), "%s/%s"szDataDirszDB);
    
    if (!
file_exists(szFile))
    {
        new 
fp fopen(szFile"w");
        
        if (!
fp)
        {
            
log_amx("[%s] SQL_Init()<sqlite>: File ^"%s^" not found and can't be created!"g_szPrefixszFile);
            return;
        }
        else
            
fclose(fp);
    }
    
    
g_hSqlTuple SQL_MakeDbTuple(""""""szFile0);
    
    new 
szQuery[512];
    
    
formatex
    
(
        
szQuerycharsmax(szQuery),
        
"CREATE TABLE IF NOT EXISTS `%s` \
        ( \
            `MAPNAME`                TEXT            NOT NULL, \
            `AUTHID`                TEXT            NOT NULL, \
            `NICKNAME`                TEXT            NOT NULL, \
            `IP`                    TEXT            NOT NULL, \
            `COUNTRY_FULL`            TEXT            NOT NULL, \
            `COUNTRY_SHORT`            TEXT            NOT NULL, \
            `TIME`                    REAL            NOT NULL, \
            `DATE`                    DATETIME        NOT NULL \
        )"
,
        
g_szTableName
    
);
    
    
SQL_ThreadQuery(g_hSqlTuple"Sql_IgnoredQuery_Handler"szQuery);
}
public 
client_putinserver(id)
{
    
set_bit(g_bConnectedid);
}
public 
client_disconnect(id)
{
    
clr_bit(g_bConnectedid);
    
    if (
get_bit(g_bAliveid))
        
clr_bit(g_bAliveid);
    
    if (
get_bit(g_bStartedid))
        
clr_bit(g_bStartedid);
    
    if (
g_flStartTime[id] != 0.0)
        
g_flStartTime[id] = 0.0;
    
    if (
g_flFinishTime[id] != 0.0)
        
g_flFinishTime[id] = 0.0;
}
public 
TimerThink(iEntity)
{
    if (
iEntity)
        
entity_set_float(iEntityEV_FL_nextthinkget_gametime() + 0.5);
    
    for (new 
iAlivePlayer 0iAlivePlayer MAX_PLAYERSiAlivePlayer++)
    {
        if (
get_bit(g_bConnectediAlivePlayer) && get_bit(g_bAliveiAlivePlayer) && get_bit(g_bStartediAlivePlayer))
        {
            new 
Float:flGameTime get_gametime();
            
            
message_begin(MSG_ONE_UNRELIABLEg_iMsgRoundTime_iAlivePlayer);
            
write_short(floatround(flGameTime g_flStartTime[iAlivePlayer], floatround_floor) + 1);
            
message_end();
            
            for (new 
iDeadPlayer 0iDeadPlayer MAX_PLAYERSiDeadPlayer++)
            {
                if (
get_bit(g_bConnectediDeadPlayer) && !get_bit(g_bAliveiDeadPlayer) && entity_get_int(iDeadPlayerEV_INT_iuser2) == iAlivePlayer && entity_get_int(iDeadPlayerEV_INT_iuser1) == 4)
                {
                    new 
iMinutes floatround(g_flStartTime[iAlivePlayer] / 60.0floatround_floor);
                    new 
iSeconds floatround(g_flStartTime[iAlivePlayer] - iMinutes 60floatround_floor);
                    
                    
set_hudmessage(02550, -1.00.250_0.5__1);
                    
ShowSyncHudMsg(iDeadPlayerg_iHudSyncObj"%02d:%02d"iMinutesiSeconds);
                }
            }
        }
    }
}
public 
HamSpawnPlayer_Post(id)
{
    
set_bit(g_bAliveid);
    
    if (
get_bit(g_bStartedid))
    {
        
clr_bit(g_bStartedid);
        
        
g_flStartTime[id] = 0.0;
    }
}
public 
HamKilledPlayer_Post(id)
{
    
clr_bit(g_bAliveid);
    
    if (
get_bit(g_bStartedid))
    {
        
clr_bit(g_bStartedid);
        
        
g_flStartTime[id] = 0.0;
    }
}
public 
HamUseFuncButton_Pre(iEntityid)
{
    if (!
get_bit(g_bAliveid))
        return(
HAM_IGNORED);
    
    if (
g_bTimerFound)
    {
        new 
szTarget[32];
        
entity_get_string(iEntityEV_SZ_targetszTargetcharsmax(szTarget));
        
        if (
TrieKeyExists(g_tStartsszTarget))
            
Timer_Start(id);
        else if (
TrieKeyExists(g_tStopsszTarget))
            
Timer_Stop(id);
    }
    else
    {
        if (
iEntity == g_iTimer[START])
            
Timer_Start(id);
        else if (
iEntity == g_iTimer[STOP])
            
Timer_Stop(id);
    }
    
    return(
HAM_IGNORED);
}
Timer_Start(id)
{
    
set_hudmessage(00255, -1.00.900_3.0__1);
    
    if (!
get_bit(g_bStartedid))
    {
        
set_bit(g_bStartedid);
        
        
ShowSyncHudMsg(idg_iHudSyncObj"Timer started!");
    }
    else
        
ShowSyncHudMsg(idg_iHudSyncObj"Timer re-started!");
    
    
g_flStartTime[id] = get_gametime();
}
Timer_Stop(id)
{
    if (!
get_bit(g_bStartedid))
        return;
    
    
clr_bit(g_bStartedid);
    
    
g_flFinishTime[id] = get_gametime() - g_flStartTime[id];
    
    
g_flStartTime[id] = 0.0;
    
    
message_begin(MSG_ONE_UNRELIABLEg_iMsgRoundTime_id);
    
write_short(1);
    
message_end();
    
    new 
szTime[17];
    
ClimbtimeToString(g_flFinishTime[id], szTimecharsmax(szTime));
    
    
#if defined COLORCHAT
        
ColorChat(idRED"^4[%s]^1 You finished map in^3 %s^1!"g_szPrefixszTime);
    
#else
        
client_print(idprint_chat"[%s] You finished map in %s!"g_szPrefixszTime);
    
#endif
    
    
new iPlayers[MAX_PLAYERS], iNum;
    
get_players(iPlayersiNum"ch");
    
    if (
iNum)
    {
        new 
szName[32];
        
get_user_name(idszNamecharsmax(szName));
        
        new 
iPlayer;
        
        for (new 
0iNumi++)
        {
            
iPlayer iPlayers[i];
            
            if (
iPlayer == id)
                continue;
            
            
#if defined COLORCHAT
                
ColorChat(iPlayerRED"^4[%s]^3 %s^1 finished map in^3 %s^1!"g_szPrefixszNameszTime);
            
#else
                
client_print(iPlayerprint_chat"[%s] %s finished map in %s!"g_szPrefixszNameszTime);
            
#endif
        
}
    }
    
    new 
szAuthID[32];
    
get_user_authid(idszAuthIDcharsmax(szAuthID));
    
    new 
szQuery[512], cData[1]; cData[0] = id;
    
    
formatex
    
(
        
szQuerycharsmax(szQuery),
        
"SELECT \
            `TIME` \
        FROM \
            `%s` \
        WHERE \
            `MAPNAME` = '%s' \
        AND \
            `AUTHID` = '%s'"
,
        
g_szTableName,
        
g_szMapName,
        
szAuthID
    
);
    
    
SQL_ThreadQuery(g_hSqlTuple"Sql_QueryTop_Handler"szQuerycDatasizeof(cData));
}
public 
Sql_QueryTop_Handler(iFailStateHandle:hQueryszError[], iErrorcData[], iSize)
{
    if (
iFailState != TQUERY_SUCCESS)
    {
        
log_amx("[%s] Sql_IgnoredQuery_Handler(): SQL_Error #%d - %s"g_szPrefixiErrorszError);
        return;
    }
    
    new 
id cData[0];
    
    if (!
get_bit(g_bConnectedid))
        return;
    
    new 
szAuthID[32], szName[64], szIP[32], szCountryFull[45], szCountryShort[3], szDate[32];
    
get_user_authid(idszAuthIDcharsmax(szAuthID));
    
get_user_name(idszNamecharsmax(szName));
    
get_user_ip(idszIPcharsmax(szIP), 1);
    
geoip_country(szIPszCountryFullcharsmax(szCountryFull));
    
geoip_code2(szIPszCountryShort);
    
get_time("%Y%m%d%H%M%S"szDatecharsmax(szDate));
    
    
SQL_PrepareString(szNameszNamecharsmax(szName));
    
    new 
szQuery[512];
    
    if (
SQL_NumResults(hQuery))
    {
        new 
Float:flOldTimeFloat:flResultszTime[17];
        
        
SQL_ReadResult(hQuery0flOldTime);
        
        if (
g_flFinishTime[id] < flOldTime)
        {
            
flResult flOldTime g_flFinishTime[id];
            
            
ClimbtimeToString(flResultszTimecharsmax(szTime));
            
            
#if defined COLORCHAT
                
ColorChat(idRED"^4[%s]^1 You improved your time for^3 %s^1 msec!"g_szPrefixszTime);
            
#else
                
client_print(idprint_chat"[%s] You improved your time for %s msec!"g_szPrefixszTime);
            
#endif
            
            
formatex
            
(
                
szQuerycharsmax(szQuery),
                
"UPDATE `%s` \
                SET \
                    `NICKNAME`            = '%s', \
                    `IP`                = '%s', \
                    `COUNTRY_FULL`        = '%s', \
                    `COUNTRY_SHORT`        = '%s', \
                    `TIME`                = '%f', \
                    `DATE`                = '%s' \
                WHERE \
                    `MAPNAME`            = '%s' \
                AND \
                    `AUTHID`            = '%s'"
,
                
g_szTableName,
                
szName,
                
szIP,
                
szCountryFull,
                
szCountryShort,
                
g_flFinishTime[id],
                
szDate,
                
g_szMapName,
                
szAuthID
            
);
            
            
SQL_ThreadQuery(g_hSqlTuple"Sql_IgnoredQuery_Handler"szQuery);
            
            
formatex
            
(
                
szQuerycharsmax(szQuery),
                
"SELECT \
                    `AUTHID` \
                FROM \
                    `%s` \
                WHERE \
                    MAPNAME='%s' \
                ORDER BY \
                    `TIME` \
                LIMIT 15"
,
                
g_szTableName,
                
g_szMapName
            
);
            
            
SQL_ThreadQuery(g_hSqlTuple"Sql_GetPlaceQuery_Handler"szQuerycDatasizeof(cData[]));
        }
        else
        {
            
flResult g_flFinishTime[id] - flOldTime;
            
            
ClimbtimeToString(flResultszTimecharsmax(szTime));
            
            
#if defined COLORCHAT
                
ColorChat(idRED"^4[%s]^1 You failed your time for^3 %s^1 msec!"g_szPrefixszTime);
            
#else
                
client_print(idprint_chat"[%s] You failed your time for %s msec!"g_szPrefixszTime);
            
#endif
        
}
    }
    else
    {
        
formatex
        
(
            
szQuerycharsmax(szQuery),
            
"INSERT INTO `%s` \
            ( \
                `MAPNAME`, \
                `AUTHID`, \
                `NICKNAME`, \
                `IP`, \
                `COUNTRY_FULL`, \
                `COUNTRY_SHORT`, \
                `TIME`, \
                `DATE` \
            ) \
             \
            VALUES \
            ( \
                '%s', \
                '%s', \
                '%s', \
                '%s', \
                '%s', \
                '%s', \
                '%f', \
                '%s' \
            )"
,
            
g_szTableName,
            
g_szMapName,
            
szAuthID,
            
szName,
            
szIP,
            
szCountryFull,
            
szCountryShort,
            
g_flFinishTime[id],
            
szDate
        
);
        
        
SQL_ThreadQuery(g_hSqlTuple"Sql_IgnoredQuery_Handler"szQuery);
        
        
formatex
        
(
            
szQuerycharsmax(szQuery),
            
"SELECT \
                `AUTHID` \
            FROM \
                `%s` \
            WHERE \
                MAPNAME='%s' \
            ORDER BY \
                `TIME` \
            LIMIT 15"
,
            
g_szTableName,
            
g_szMapName
        
);
        
        
SQL_ThreadQuery(g_hSqlTuple"Sql_GetPlaceQuery_Handler"szQuerycDatasizeof(cData[]));
    }
    
    
g_flFinishTime[id] = 0.0;
}
public 
Sql_GetPlaceQuery_Handler(iFailStateHandle:hQueryszErroriErrorcData[], iSize)
{
    if (
iFailState != TQUERY_SUCCESS)
    {
        
log_amx("[%s] Sql_GetPlaceQuery_Handler(): SQL_Error #%d - %s"g_szPrefixiErrorszError);
        return;
    }
    
    new 
id cData[0];
    
    if (!
get_bit(g_bConnectedid))
        return;
    
    new 
szAuthID[32];
    
get_user_authid(idszAuthIDcharsmax(szAuthID));
    
    new 
iszAuthID_SQL[32];
    
    while(
SQL_MoreResults(hQuery))
    {
        
i++;
        
        
SQL_ReadResult(hQuery0szAuthID_SQLcharsmax(szAuthID_SQL));
        
        if (
equal(szAuthIDszAuthID_SQL))
        {
            
#if defined COLORCHAT
                
ColorChat(idRED"^4[%s]^1 You are now on^3 %d^1 place in map top!"g_szPrefixi);
            
#else
                
client_print(idprint_chat"[%s] You are now on %d place in map top!"g_szPrefixi);
            
#endif
            
            
new iPlayers[MAX_PLAYERS], iNum;
            
get_players(iPlayersiNum"ch");
            
            if (
iNum)
            {
                new 
szName[32];
                
get_user_name(idszNamecharsmax(szName));
                
                new 
iPlayer;
                
                for (new 
0iNumi++)
                {
                    
iPlayer iPlayers[i];
                    
                    if (
iPlayer == id)
                        continue;
                    
                    
#if defined COLORCHAT
                        
ColorChat(iPlayerRED"^4[%s]^3 %s^1 is now on^3 %d^1 place in map top!"g_szPrefixszNamei);
                    
#else
                        
client_print(iPlayerprint_chat"[%s] %s is now on %d place in map top!"g_szPrefixszNamei);
                    
#endif
                
}
            }
            break;
        }
        
SQL_NextRow(hQuery);
    }
}
public 
Sql_IgnoredQuery_Handler(iFailStateHandle:hQueryszError[], iErrorcData[], iSize)
{
    if (
iFailState != TQUERY_SUCCESS)
    {
        
log_amx("[%s] Sql_IgnoredQuery_Handler(): SQL_Error #%d - %s"g_szPrefixiErrorszError);
        return;
    }
}
public 
ClCmdBest(id)
{
    if (!
g_bSqlite)
    {
        new 
szWebLink[128];
        
get_pcvar_string(g_pWebLinkszWebLinkcharsmax(szWebLink));
        
        new 
szMotd[256];
        
formatex(szMotdcharsmax(szMotd), "<META HTTP-EQUIV=^"REFRESH^" CONTENT=^"0;URL=%s/maptop.php?mapname=%s^">"szWebLinkg_szMapName);
        
        
show_motd(idszMotd"DR - Map Top");
    }
    else
    {
        new 
szQuery[512], cData[1]; cData[0] = id;
        
        
formatex
        
(
            
szQuerycharsmax(szQuery),
            
"SELECT \
                `NICKNAME`, \
                `TIME` \
            FROM \
                `%s` \
            WHERE \
                `MAPNAME` = '%s' \
            ORDER BY \
                `TIME` \
            LIMIT 15"
,
            
g_szTableName,
            
g_szMapName
        
);
        
        
SQL_ThreadQuery(g_hSqlTuple"Sql_LoadTopQuery_Handler"szQuerycDatasizeof(cData));
    }
}
public 
Sql_LoadTopQuery_Handler(iFailStateHandle:hQueryszErroriErrorcData[], iSize)
{
    if (
iFailState != TQUERY_SUCCESS)
    {
        
log_amx("[%s] Sql_GetPlaceQuery_Handler(): SQL_Error #%d - %s"g_szPrefixiErrorszError);
        return;
    }
    
    new 
id cData[0];
    
    if (!
get_bit(g_bConnectedid))
        return;
    
    new 
szMotd[1536], iSize charsmax(szMotd);
    
    new 
iLen formatex
    
(
        
szMotdiSize,
        
"<!DOCTYPE HTML> \
        <html> \
        <head> \
            <style type=^"
text/css^"> \
                body \
                { \
                    background: #000000; \
                    margin: 8px; \
                    color: #FF3300; \
                    font: normal 16px/20px Verdana, Tahoma, sans-serif; \
                    text-align: center; \
                } \
                th:nth-child(2){ text-align: left; } \
                td:nth-child(2){ text-align: left; } \
            </style> \
        </head> \
        <body>"
    
);
    
    
iLen += formatex
    
(
        
szMotd[iLen], iSize iLen,
        
"<table align=^"center^" width=^"90%%^"> \
            <tr> \
                <th width=^"
5%%^">#</th>\
                <th width=^"
40%%^">Jucator</th>\
                <th width=^"
20%%^">Timp</th>\
            </tr> \
        "
    
);
    
    new 
1;
    new 
Float:flTimeszName[32], szTime[32];
    
    while (
SQL_MoreResults(hQuery))
    {
        
SQL_ReadResult(hQuery0szName31);
        
SQL_ReadResult(hQuery1flTime);
        
        
ClimbtimeToString(flTimeszTime16);
        
        
iLen += formatex
        
(
            
szMotd[iLen], iSize iLen,
            
"<tr> \
                <td>%d</td> \
                <td>%s</td> \
                <td>%s</td> \
            </tr>"
,
            
i,
            
szName,
            
szTime
        
);
        
        
i++;
        
SQL_NextRow(hQuery);
    }
    
    
formatex
    
(
        
szMotd[iLen], iSize iLen,
        
"</table> \
        </body> \
        </html>"
    
);
    
    
show_motd(idszMotd"DR - Top15");
}
stock SQL_PrepareString(const szQuery[], szOutPut[], iSize)
{
    
copy(szOutPutiSizeszQuery);
    
replace_all(szOutPutiSize"'""\'");
    
replace_all(szOutPutiSize"`""\`");
    
replace_all(szOutPutiSize"\\""\\\\");
}
ClimbtimeToString(Float:flClimbTimeszOutPut[], iLen)
{
    new 
iMinutes floatround(flClimbTime 60.0floatround_floor);
    new 
iSeconds floatround(flClimbTime iMinutes 60floatround_floor);
    new 
iMiliSeconds floatround((flClimbTime - (iMinutes 60 iSeconds)) * 100floatround_floor);
    
    
formatex(szOutPutiLen"%02i:%02i.%02i"iMinutesiSecondsiMiliSeconds);
}
public 
ClCmdTimer(id)
{
    if (~
get_user_flags(id) & ADMIN_ACCESS)
    {
        
#if defined COLORCHAT
            
ColorChat(idNORMAL"^4[%s]^1 You don't have enought access!"g_szPrefix);
        
#else
            
client_print(idprint_chat"[%s] You don't have enought access!"g_szPrefix);
        
#endif
        
        
return(PLUGIN_HANDLED);
    }
    if (
g_bTimerFound)
    {
        
#if defined COLORCHAT
            
ColorChat(idNORMAL"^4[%s]^1 This map already have timers!"g_szPrefix);
        
#else
            
client_print(idprint_chat"[%s] This map already have timers!"g_szPrefix);
        
#endif
        
return(PLUGIN_HANDLED);
    }
    if (!
get_bit(g_bAliveid))
    {
        
#if defined COLORCHAT
            
ColorChat(idNORMAL"^4[%s]^1 You should be alive!"g_szPrefix);
        
#else
            
client_print(idprint_chat"[%s] You should be alive!"g_szPrefix);
        
#endif
        
return(PLUGIN_HANDLED);
    }
    
    
TimerMenu(id);
    
    return(
PLUGIN_HANDLED);
}
public 
TimerMenu(id)
{
    new 
iMenu menu_create("\r[DeathRun]\y Timer Menu""TimerMenu_Handler");
    
    
menu_additem(iMenu"Create");
    
menu_additem(iMenu"Rotate^n");
    
    
menu_additem(iMenu"Save^n");
    
    new 
szMenuItem[64];
    
formatex(szMenuItemcharsmax(szMenuItem), "Timer - (\y%s\w)"g_szTimerName[g_iPlayerTimer[id]]);
    
menu_additem(iMenuszMenuItem);
    
    
menu_display(idiMenu);
}
public 
TimerMenu_Handler(idiMenuiItem)
{
    if (
iItem == MENU_EXIT)
    {
        
menu_destroy(iMenu);
        return(
PLUGIN_HANDLED);
    }
    
    switch (
iItem)
    {
        case 
0create_timer(idg_iPlayerTimer[id]);
        case 
1:
        {
            if (
is_valid_ent(g_iTimer[g_iPlayerTimer[id]]))
            {
                switch (
g_iTimerAngles[g_iPlayerTimer[id]])
                {
                    case 
3g_iTimerAngles[g_iPlayerTimer[id]] = 0;
                    case 
012g_iTimerAngles[g_iPlayerTimer[id]]++;
                }
                
                new 
Float:vAngles[3];
                
vAngles[1] = g_flTimerAngles[g_iTimerAngles[g_iPlayerTimer[id]]];
                
                
entity_set_vector(g_iTimer[g_iPlayerTimer[id]], EV_VEC_anglesvAngles);
            }
        }
        case 
2:
        {
            if (
is_valid_ent(g_iTimer[g_iPlayerTimer[id]]))
            {
                if (
g_iVault == INVALID_HANDLE)
                    return(
PLUGIN_HANDLED);
                
                new 
szData[128], iTimestamp;
                
                if (
nvault_lookup(g_iVaultg_szTimerName[g_iPlayerTimer[id]], szDatacharsmax(szData), iTimestamp))
                    
nvault_remove(g_iVaultg_szTimerName[g_iPlayerTimer[id]]);
                
                
formatex(szDatacharsmax(szData), "^"%.1f^" ^"%.1f^" ^"%.1f^" ^"%d^""g_vTimerOrigin[g_iPlayerTimer[id]][0], g_vTimerOrigin[g_iPlayerTimer[id]][1], g_vTimerOrigin[g_iPlayerTimer[id]][2], g_iTimerAngles[g_iPlayerTimer[id]]);
                
                
nvault_set(g_iVaultg_szTimerName[g_iPlayerTimer[id]], szData);
                
                
#if defined COLORCHAT
                    
ColorChat(idRED"^4[%s]^1 Timer (^3%s^1) saved!"g_szPrefixg_szTimerName[g_iPlayerTimer[id]]);
                
#else
                    
client_print(idprint_chat"[%s] Timer (%s) saved!"g_szPrefixg_szTimerName[g_iPlayerTimer[id]]);
                
#endif
            
}
        }
        case 
3:
        {
            switch (
g_iPlayerTimer[id])
            {
                case 
STARTg_iPlayerTimer[id] = STOP;
                case 
STOPg_iPlayerTimer[id] = START;
            }
        }
    }
    
    
ClCmdTimer(id);
    return(
PLUGIN_HANDLED);
}
LoadTimers()
{
    if (
g_iVault == INVALID_HANDLE)
        return;
    
    for (new 
02i++)
    {
        new 
szData[128], iTimestamp;
        if (
nvault_lookup(g_iVaultg_szTimerName[i], szDatacharsmax(szData), iTimestamp))
        {
            new 
szOrigin[3][17], szAngles[2];
            
parse(szDataszOrigin[0], charsmax(szOrigin[]), szOrigin[1], charsmax(szOrigin[]), szOrigin[2], charsmax(szOrigin[]), szAnglescharsmax(szAngles));
            
            for (new 
03x++)
                
g_vTimerOrigin[i][x] = str_to_float(szOrigin[x]);
            
            
g_iTimerAngles[i] = str_to_num(szAngles);
            
            
create_timer(0ig_vTimerOrigin[i]);
        }
        else
            continue;
    }
}
stock create_timer(idiTypeFloat:vOrigin[3] = {0.00.00.0})
{
    if (!
g_iTimer[iType])
    {
        new 
iEntity create_entity("func_button");
        
        if (!
is_valid_ent(iEntity))
            return;
        
        new 
szClassName[32];
        
formatex(szClassNamecharsmax(szClassName), "Timer_%s"g_szTimerName[iType]);
        
        
entity_set_string(iEntityEV_SZ_classnameszClassName);
        
entity_set_int(iEntityEV_INT_solidSOLID_BBOX);
        
entity_set_int(iEntityEV_INT_movetypeMOVETYPE_NONE);
        
entity_set_model(iEntityg_szTimerModels[iType]);
        
entity_set_size(iEntityFloat:{-16.0, -16.00.0}, Float:{16.016.060.0});
        
        
g_iTimer[iType] = iEntity;
    }
    if (
id)
    {
        new 
vOriginI[3];
        
get_user_origin(idvOriginI3);
        
        new 
Float:vOriginF[3];
        
IVecFVec(vOriginIvOriginF);
        
        
entity_set_origin(g_iTimer[iType], vOriginF);
        
        for (new 
03i++)
            
g_vTimerOrigin[iType][i] = vOriginF[i];
    }
    else
        
entity_set_origin(g_iTimer[iType], vOrigin);
    
    new 
Float:vAngles[3];
    
vAngles[1] = g_flTimerAngles[g_iTimerAngles[iType]];
    
    
entity_set_vector(g_iTimer[iType], EV_VEC_anglesvAngles);
    
    
drop_to_floor(g_iTimer[iType]);
}
public 
plugin_end()
{
    if (
g_bTimerFound)
    {
        
TrieDestroy(g_tStarts);
        
TrieDestroy(g_tStops);
    }
    else
    {
        if (
g_iVault != INVALID_HANDLE)
            
nvault_close(g_iVault);
    }
    
    
SQL_FreeHandle(g_hSqlTuple);

I want the button to not be solid and I want it to activate when I go through it, not to press it same as the finish button
jgtyui 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 02:15.


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