AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved There is only positive vibes ;3 (https://forums.alliedmods.net/showthread.php?t=327492)

Magicher0ex 09-22-2020 09:15

There is only positive vibes ;3
 
Player's personal time by Supremache

fysiks 09-22-2020 22:27

Re: Players played time in the server
 
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.

Supremache 09-26-2020 14:10

Re: Players played time in the server
 
I did player time list, i think it better than typing player name:
https://i.ibb.co/dKGHfPm/reset-bank.png

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)     } }

Magicher0ex 09-26-2020 14:29

Re: Players played time in the server
 
Quote:

Originally Posted by Supremache (Post 2719092)
I did player time list, i think it better than typing player name:
https://i.ibb.co/dKGHfPm/reset-bank.png

Genius, think right about it, but also think it's more harder for anyone to do it. Thank you very much!

Magicher0ex 09-26-2020 14:51

Re: Players played time in the server
 
Quote:

Originally Posted by Supremache (Post 2719092)
I did player time list, i think it better than typing player name:
https://i.ibb.co/dKGHfPm/reset-bank.png

Mhm you have a problem. The all players in the server see their own time
https://i.ibb.co/HKDBQsQ/10-screensh...26214513-1.jpg


Supremache 09-26-2020 15:07

Re: Players played time in the server
 
Oops, Fixed, Check first post


All times are GMT -4. The time now is 13:56.

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