AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   top 25 time.. (https://forums.alliedmods.net/showthread.php?t=231636)

kumail149 12-17-2013 13:21

top 25 time..
 
Hello Guys ,

Can someone plz try making me this plugin
top25_time , like the top25 peoples played time..

-Must Be Sql..
-Commands Must Be /my_time & /time
-/time instead of /top25_time

Thank You In Advance :D

Regards ,

Kumail

joshknifer 12-17-2013 13:36

Re: top 25 time..
 
Something like this?

http://forums.alliedmods.net/showthread.php?p=457071

kumail149 12-17-2013 14:30

Re: top 25 time..
 
Nope , Its Not Sql..

Kia 12-18-2013 05:58

Re: top 25 time..
 
Why it must run on SQL?

PoLiCe 12-18-2013 07:52

Re: top 25 time..
 
Here, It uses SQL & commands are /my_time - /time
PHP Code:

#include <amxmodx>  
#include <amxmisc>  
#include <sqlx>  
#define PLUGIN "Played Time"  
#define VERSION "0.1"  
#define AUTHOR "UnKnown Author."  
#define host "127.0.0.1"  
#define user "root"  
#define pass ""  
#define db "played_time"  
new Handle:sqlg_query[512]  
new 
PlayedTime[33]  
new 
showpt;  
public 
plugin_init()   
{  
    
register_plugin(PLUGINVERSIONAUTHOR );  
      
    
register_clcmd("say""handle_say");  
    
register_concmd("amx_playedtime""admin_showptime"ADMIN_RCON," <#Player Name> - Details about playedtime.");  
      
    
showpt register_cvar("amx_pt_mod","1");  
      
}  
public 
plugin_cfg(){  
    
sql SQL_MakeDbTuple(host,user,pass,db)  
    
formatex(g_query,511,"CREATE TABLE IF NOT EXISTS `played_time` (name VARCHAR(32), playedtime INT, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP)")  
    
SQL_ThreadQuery(sql,"query",g_query)  
}  
public 
handle_say(id)   
{  
    static 
said[12]  
    
read_argv(1said11)  
      
    if(
equali(said"/my_time"))  
    {  
        static 
ctime[64], timep;  
          
        
timep get_user_time(id1) / 60;  
        
get_time("%H:%M:%S"ctime63);  
          
        switch(
get_pcvar_num(showpt))  
        {  
            case 
0: return PLUGIN_HANDLED;  
                  
            case 
:  
            {  
                
client_print(idprint_chat"[Played-Time] You have been playing on the server for: %d minute%s."timeptimep == "" "s");   
                
client_print(idprint_chat"[Played-Time] Your total played time on the server: %d minute%s."timep+PlayedTime[id], timep+PlayedTime[id] == "" "s");  
            }  
            case 
:  
            {  
                
set_hudmessage(25550500.340.5006.04.00.10.2, -1);  
                
show_hudmessage(id"[Played-Time] You have been playing on the server for: %d minute%s.^n[AMXX]Current time: %s"timeptimep == "" "s"ctime);  
            }  
        }  
        return 
PLUGIN_HANDLED;  
    }  
    else if(
equal(said,"/time")){  
        new 
data[1];data[0]=id  
          
        formatex
(g_query,511,"SELECT * FROM played_time ORDER BY playedtime DESC LIMIT 25")  
        
SQL_ThreadQuery(sql,"show_top15",g_query,data,1)  
          
    }  
    return 
PLUGIN_CONTINUE;  
}  
public 
admin_showptime(id,level,cid)   
{  
    if(!
cmd_access(idlevelcid2))  
        return 
PLUGIN_HANDLED;  
      
    static 
arg[32];  
    
read_argv(1arg31);  
      
    new 
player cmd_target(idarg2);  
      
    if(!
player)  
        return 
PLUGIN_HANDLED;  
      
    static 
name[32];  
    
get_user_name(playername31);  
      
    static 
timepctime[64];  
      
    
timep get_user_time(player1) / 60;  
    
get_time("%H:%M:%S"ctime63);  
      
    
console_print(id"-----------------------(#PlayedTime#)-----------------------");  
    
console_print(id"[Played-Time] %s have been playing on the server for %d minute%s.",nametimeptimep == "" "s");  
    
console_print(id"[Played-Time] %s's total played time on the server %d minute%s.",nametimep+PlayedTime[player], timep == "" "s"); // new  
    
console_print(id"-----------------------------------------------------------------");  
      
    return 
PLUGIN_HANDLED;  
}  
public 
client_disconnect(id){  
    new 
name[32]  
      
    
get_user_name(id,name,31)      
    
replace_all(name,32,"'","")  
    
replace_all(name,32,"^"","")

    formatex(g_query,511,"
UPDATE played_time SET playedtime='%d' WHERE name='%s'",PlayedTime[id],name)  
    SQL_ThreadQuery(sql,"
query",g_query)  
      
    PlayedTime[id] = 0  
}  
public client_putinserver(id){  
    PlayedTime[id] = get_playedtime(id)  
    log_amx("
--> Got %d",PlayedTime[id])  
}  
public plugin_end(){  
    SQL_FreeHandle(sql)  
}  

get_playedtime(id){  
    new err,error[128]  
      
    new Handle:connect = SQL_Connect(sql,err,error,127)  
      
    if(err){  
        log_amx("
--> MySQL Connection Failed - [%d][%s]",err,error)  
        set_fail_state("
mysql connection failed")  
    }  
      
    new name[32],Handle:query,pt  
    get_user_name(id,name,31)  
    replace_all(name,32,"'","")  
    replace_all(name,32,"^"","")  
      
    query = SQL_PrepareQuery(connect,"SELECT playedtime FROM played_time WHERE name='
%s'",name)  
    SQL_Execute(query)  
      
    if(!SQL_MoreResults(query)){  
        formatex(g_query,511,"INSERT INTO played_time (name,playedtime) VALUES('
%s','%d')",name,get_user_time(id,1)/60)  
        SQL_ThreadQuery(sql,"query",g_query)  
          
        pt = (get_user_time(id,1)/60)  
    }else{  
        pt = SQL_ReadResult(query,0)+(get_user_time(id,1)/60)  
    }  
      
    log_amx("--> Get %d minutes for %s",pt,name)  
      
    SQL_FreeHandle(connect)  
    SQL_FreeHandle(query)  
      
    return pt  
}  
public show_top15(FailState, Handle:Query, Error[], Errcode,Data[], DataSize){  
    static name[32]  
      
    new id=Data[0]  
    new good,motd[1024],len,place  
      
    if(!SQL_MoreResults(Query)){  
        client_print(id,print_chat,"[PT] No entryes")  
        return PLUGIN_HANDLED  
    }  
      
    len = format(motd, 1023,"<body bgcolor=#000000><font color=#FFB000><pre>")  
    len += format(motd[len], 1023-len,"%s %-22.22s %3s^n", "#", "Name", "Time")  
      
    while(SQL_MoreResults(Query)){  
        place++  
          
        SQL_ReadResult(Query,0,name, 32)  
        good = SQL_ReadResult(Query,1)  
          
        replace_all(name, 32,"<","")  
        replace_all(name, 32,">","")  
          
        len += format(motd[len], 1023-len,"%d %-22.22s %d minute%s^n",place,name,good,good == 1 ? "" : "s")  
          
        SQL_NextRow(Query)  
    }  
      
    len += format(motd[len], 1023-len,"</body></font></pre>")  
    show_motd(id, motd,"Top 15 Players By Time")  
      
    return PLUGIN_CONTINUE  
}  
public query(FailState, Handle:Query, Error[], Errcode){  
}  
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 


kumail149 12-18-2013 11:14

Re: top 25 time..
 
Kia : Cuz Without Sql , The Time Resets X___X
PoLice : Thank-You Bro <3

Kia 12-18-2013 11:29

AW: Re: top 25 time..
 
Quote:

Originally Posted by kumail149 (Post 2073529)
Kia : Cuz Without Sql , The Time Resets X___X
PoLice : Thank-You Bro <3

You can also use Vault for that.

kumail149 12-18-2013 11:32

Re: top 25 time..
 
Ahh , The Problem Is Still There ...
The Actual Problem Is That The /top15time or 25 time updates only when the map Changes X__X
Can Any1 Fix It Please?

kumail149 12-18-2013 11:32

Re: top 25 time..
 
Kia : Ohh Okayy , Thnx for telling :)

PoLiCe 12-18-2013 11:36

Re: top 25 time..
 
@kumail, np. too many peoples asking for this, if you searched alittel, you would find the plugin that you want but your so lazy :3

@Kia, I used Played Time Extended & Played Time by Alka, both uses nVault and it resets players time. but i tried SQL and it works perfectly, i don't know why it resets with nvault :/


All times are GMT -4. The time now is 20:41.

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