Raised This Month: $ Target: $400
 0% 

Solved There is only positive vibes ;3


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-26-2020 , 14:10   Re: Players played time in the server
Reply With Quote #3

I did player time list, i think it better than typing player name:


Code:
#include <amxmodx> #include <amxmisc> #include <colorchat> #include <nvault> #include <time> #define MAX_PLAYERS 32 new g_iVault new g_SaveTime, g_SaveType; new g_szAuth[MAX_PLAYERS+1][33] new g_szName[MAX_PLAYERS+1][33] new g_szUserIP[MAX_PLAYERS+1][33] new szUserTime[128] new g_iLastPlayedTime[MAX_PLAYERS+1] public plugin_init() {     register_plugin("Time", "0.2", "ConnorMcLeod/Updated by Supremache")     register_dictionary("time.txt")         g_SaveType = register_cvar("time_savetype","0") // Save time to : 0 = NVault.     g_SaveTime = register_cvar("time_save","1") // Save time by : 2 = Name, 1 = SteamID, 0 = IP.         register_clcmd( "say /timelist", "cmdTimeList", ADMIN_ADMIN );      g_iVault = nvault_open("played_time")     register_clcmd("say /time", "ClientCommand_PlayedTime") } public plugin_end() nvault_close( g_iVault )   public client_authorized( id ) {     get_user_ip(id, g_szUserIP[id], charsmax(g_szUserIP[]), 1)     get_user_authid(id , g_szAuth[id], charsmax(g_szAuth[]))     get_user_name(id, g_szName[id], charsmax(g_szName[]))     LoadData(id) } get_user_total_playtime( id ) {     return g_iLastPlayedTime[id] + get_user_time(id) } public ClientCommand_PlayedTime( id ) {     get_time_length(id, get_user_total_playtime( id ), timeunit_seconds, szUserTime, charsmax(szUserTime))     ColorChat( id, GREEN, "^x04%s^x01's Time:^x04 %s", g_szName[id], szUserTime) } public client_disconnect( id ) {     SaveData(id) } public cmdTimeList(id, iLevel, iCid) {     if(!cmd_access(id, iLevel, iCid, 1))     {         return PLUGIN_HANDLED     }         new szTitle[128]     formatex(szTitle, charsmax(szTitle), "\yPlayer Activity: \rTime List")     new iPlayers[MAX_PLAYERS], iPnum, iMenu = menu_create(szTitle, "TimeList_Handler")     get_players(iPlayers, iPnum, "ch");     SortCustom1D(iPlayers, iPnum, "SortPlayersTime")     for(new szItem[1024], iPlayer, i; i < iPnum; i++) {         iPlayer = iPlayers[i];         get_time_length(iPlayer, get_user_total_playtime(iPlayer), timeunit_seconds, szUserTime, charsmax(szUserTime))         formatex(szItem, charsmax(szItem), "\w%s \r[\yTime: %s\r]", g_szName[iPlayer], szUserTime);         menu_additem(iMenu, szItem);     }     menu_display(id, iMenu)     return PLUGIN_HANDLED } public TimeList_Handler(id, iMenu, iItem) {     menu_destroy(iMenu)     return PLUGIN_HANDLED } public SortPlayersTime(id, index) {     return g_iLastPlayedTime[index] - g_iLastPlayedTime[id] } SaveData(id) {     new szKey[64];         if (get_pcvar_num(g_SaveTime) == 0)     {         formatex(szKey , charsmax(szKey), "%s-IP" , g_szUserIP[id])     }     else if (get_pcvar_num(g_SaveTime) == 1)     {         formatex(szKey , charsmax(szKey), "%s-ID" , g_szAuth[id])     }     else if (get_pcvar_num(g_SaveTime) == 2)     {         formatex(szKey , charsmax(szKey), "%s-NAME" , g_szName[id])     }         if (!get_pcvar_num(g_SaveType))     {         new szData[256]                 formatex(szData , charsmax(szData) , "%i#" , get_user_total_playtime( id ))                 nvault_pset(g_iVault , szKey , szData)     } } LoadData(id) {     new szKey[64];         if (get_pcvar_num(g_SaveTime) == 0)     {         formatex(szKey , charsmax(szKey), "%s-IP" , g_szUserIP[id])     }     else if (get_pcvar_num(g_SaveTime) == 1)     {         formatex(szKey , charsmax(szKey), "%s-ID" , g_szAuth[id])     }     else if (get_pcvar_num(g_SaveTime) == 2)     {         formatex(szKey , charsmax(szKey), "%s-NAME" , g_szName[id])     }         if (!get_pcvar_num(g_SaveType))     {         new szData[256], szTime[32];                 formatex(szData , charsmax(szData), "%i#", g_iLastPlayedTime[id])         nvault_get(g_iVault, szKey, szData, charsmax(szData))         replace_all(szData , charsmax(szData), "#", " ")         parse(szData, szTime, charsmax(szTime))         g_iLastPlayedTime[id] = str_to_num(szTime)     } }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 09-26-2020 at 15:07.
Supremache is offline
 



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 13:56.


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