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

[req] donate time edit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bombi786
Member
Join Date: Mar 2013
Old 08-14-2013 , 03:05   [req] donate time edit
Reply With Quote #1

HEY GUYS.. I NEED A LITTLE HELP... CURRENT I M USING THIS PLUGINES FOR PLAYED TIME

PHP Code:
#include <amxmodx> 
#include <amxmisc> 
#include <sqlx> 

#define PLUGIN "Played Time" 
#define VERSION "0.1" 
#define AUTHOR "authour-unknown" 

#define host "127.0.0.1" 
#define user "DB USER" 
#define pass "DB PASS" 
#define db "time //DB NAME" 

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"/mytime")) 
    { 
        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"[Elite-Gaming] 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,"/top15_time")){ 
        new 
data[1];data[0]=id 
         
        formatex
(g_query,511,"SELECT * FROM played_time ORDER BY playedtime DESC LIMIT 15"
        
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,"^"","") 
     
    PlayedTime[id] = get_playedtime(id) 
     
    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){ 


AND I NEED TO ADD DONATE TIME IN THT PLUGIN... I FOUND THIS BUT I DONT HAVE TO ADD THIS.. CAN SOME1 HELP ME WITH IT...

PHP Code:
new gTime33 ]; // Variable that holds total time of player
new g_tempid// Played Id of target

public plugin_init()
{
    
register_clcmd"say /donate""CmdDonate" ); //Opens the menu
    
register_clcmd"pt_donate""CmdDonateTime" );
}

public 
CmdDonateTimeidlevelcid 

    new 
amount21 ]; 
    
    
read_argv1amountcharsmaxamount )  ); 

    new 
szSenderName32 ], szReceiverName32 ];
    
get_user_nameidszSenderNamecharsmaxszSenderName ) ); 
    
get_user_nameg_tempidszReceiverNamecharsmaxszReceiverName ) );
    
    new 
timenum str_to_numamount ); 
    
    if( 
timenum > ( gTimeid ] / 60 ) )
    {
        
client_printidprint_chat"* You don't have enough time to give." );
        return 
PLUGIN_HANDLED;
    }
    
    
gTimeg_tempid ] += timenum 60;
    
gTimeid ] -= timenum 60;
    
    
client_printg_tempidprint_chat"* You received %i minutes from %s"timenumszSenderName ); 
    
client_printidprint_chat"* You gave %i minutes to %s leaving you %i minutes"timenumszReceiverName, ( gTimeid ] / 60 ) );
    
    
Saveid )
    
Saveg_tempid )
    
    return 
PLUGIN_CONTINUE
}

public 
CmdDonateid )
{
    new 
frm125 ];
    
formatfrmcharsmaxfrm ), "\yDonate time to player ( Your time in minutes: \w%i )", ( gTimeid ] / 60 ) );
    
    new 
menu menu_createfrm"menu_handler" );
    
    new 
players32 ], pnumtempid;
    
    new 
szName32 ], szTempid10 ];
    
    
get_playersplayerspnum );
    
    for( new 
ipnumi++ )
    {
        
tempid players];
        
        
get_user_nametempidszNamecharsmaxszName ) );
        
num_to_strtempidszTempidcharsmaxszTempid ) );
        
        
menu_additemmenuszNameszTempid);
        
    }
    
menu_displayidmenu);
}

public 
menu_handleridmenuitem )
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroymenu );
        return 
PLUGIN_HANDLED;
    }
    
    new 
data], szName64 ];
    new 
accesscallback;
    
menu_item_getinfomenuitemaccessdatacharsmaxdata ), szNamecharsmaxszName ), callback );
    
    
g_tempid str_to_numdata );
    
    new 
szTargetName32 ];
    
get_user_nameg_tempidszTargetNamecharsmaxszTargetName ) );
    
    
client_printidprint_chat"* Write amount you want to donate to %s"szTargetName );
    
    
client_cmdid"messagemode pt_donate" );
    
    
menu_destroymenu );
    return 
PLUGIN_HANDLED;

bombi786 is offline
quark
Veteran Member
Join Date: Oct 2011
Location: Your mind.
Old 08-14-2013 , 03:19   Re: [req] donate time edit
Reply With Quote #2

Quote:
I FOUND THIS BUT I DONT
HAVE TO ADD THIS..
What do you mean? You dont know how to add it?
__________________

Check out My Plugins:
qServerInfo ; ASKTAG
quark is offline
bombi786
Member
Join Date: Mar 2013
Old 08-14-2013 , 03:26   Re: [req] donate time edit
Reply With Quote #3

yess.. the post i found donate plugin.. he said its a addon to ur played time.. but i dont knw.. how to add it
bombi786 is offline
sami_spt
Veteran Member
Join Date: Sep 2012
Location: I<3 pussy cats
Old 08-14-2013 , 04:20   Re: [req] donate time edit
Reply With Quote #4

add the code to the original playedtime plugin.
sami_spt is offline
bombi786
Member
Join Date: Mar 2013
Old 08-14-2013 , 04:58   Re: [req] donate time edit
Reply With Quote #5

after the orginal plugin ends??
bombi786 is offline
quark
Veteran Member
Join Date: Oct 2011
Location: Your mind.
Old 08-14-2013 , 05:03   Re: [req] donate time edit
Reply With Quote #6

Post the full codes please.
__________________

Check out My Plugins:
qServerInfo ; ASKTAG

Last edited by quark; 08-14-2013 at 05:04.
quark is offline
bombi786
Member
Join Date: Mar 2013
Old 08-14-2013 , 05:23   Re: [req] donate time edit
Reply With Quote #7

i already have... the 1st is my played time plugin.. n then code is the donate add on..i found
bombi786 is offline
quark
Veteran Member
Join Date: Oct 2011
Location: Your mind.
Old 08-14-2013 , 05:25   Re: [req] donate time edit
Reply With Quote #8

If you post the full codes maybe i can help you.
__________________

Check out My Plugins:
qServerInfo ; ASKTAG
quark is offline
bombi786
Member
Join Date: Mar 2013
Old 08-14-2013 , 05:27   Re: [req] donate time edit
Reply With Quote #9

full for played time??? or donate?
bombi786 is offline
quark
Veteran Member
Join Date: Oct 2011
Location: Your mind.
Old 08-14-2013 , 05:51   Re: [req] donate time edit
Reply With Quote #10

why not both ?
__________________

Check out My Plugins:
qServerInfo ; ASKTAG
quark 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 14:07.


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