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

Solved There is only positive vibes ;3


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Magicher0ex
Member
Join Date: Dec 2019
Old 09-22-2020 , 09:15   There is only positive vibes ;3
Reply With Quote #1

Player's personal time by Supremache

Last edited by Magicher0ex; 10-09-2020 at 13:11.
Magicher0ex is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-22-2020 , 22:27   Re: Players played time in the server
Reply With Quote #2

You can't pass arguments to functions when you register the whole command name in register_clcmd(). You must register for "say" and then in that callback function, you have to read the arg string (read_args()) and then parse it. If it starts with "/time" then grab the second argument and get the "id" for that target using cmd_target() or find_player(). If it's a valid "id" then you can use that to get that player's time.

If that doesn't solve your problem, then you need to give details of your actual problem.
__________________

Last edited by fysiks; 09-22-2020 at 22:28.
fysiks is offline
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
Magicher0ex
Member
Join Date: Dec 2019
Old 09-26-2020 , 14:29   Re: Players played time in the server
Reply With Quote #4

Quote:
Originally Posted by Supremache View Post
I did player time list, i think it better than typing player name:

Genius, think right about it, but also think it's more harder for anyone to do it. Thank you very much!
Magicher0ex is offline
Magicher0ex
Member
Join Date: Dec 2019
Old 09-26-2020 , 14:51   Re: Players played time in the server
Reply With Quote #5

Quote:
Originally Posted by Supremache View Post
I did player time list, i think it better than typing player name:


Mhm you have a problem. The all players in the server see their own time
Magicher0ex is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-26-2020 , 15:07   Re: Players played time in the server
Reply With Quote #6

Oops, Fixed, Check first post
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache 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 13:48.


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