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

Solved Thank you supre ;3


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Magicher0ex
Member
Join Date: Dec 2019
Old 09-25-2020 , 20:59   Thank you supre ;3
Reply With Quote #1

Hey guys, can anyone edit this to use SteamID time counting not by name
Code:
#include <amxmodx>
#include <colorchat>
#include <nvault>
#include <time>

#define MAX_PLAYERS 32

new g_iVault

new g_szName[MAX_PLAYERS+1][32]
new g_iLastPlayedTime[MAX_PLAYERS+1]

public plugin_init()
{
	register_plugin("Time", "0.1", "ConnorMcLeod")
	register_dictionary("time.txt")

	g_iVault = nvault_open("played_time")

	register_clcmd("say /time", "ClientCommand_PlayedTime")
}

public plugin_end() nvault_close( g_iVault )
 

public client_authorized( id )
{
	new szTime[32]
	get_user_name(id, g_szName[id], charsmax(g_szName[]))
	nvault_get(g_iVault, g_szName[id], szTime, charsmax(szTime))
	g_iLastPlayedTime[id] = str_to_num(szTime)
}

get_user_total_playtime( id )
{
	return g_iLastPlayedTime[id] + get_user_time(id)
}

public ClientCommand_PlayedTime( id )
{
    new szTime[128]
    new szName[32]
    get_time_length(id, get_user_total_playtime( id ), timeunit_seconds, szTime, charsmax(szTime))
    get_user_name(id, szName, charsmax(szName)) 
    ColorChat( id, GREEN, "^x04%s^x01's Time:^x04 %s", szName, szTime)
} 

public client_disconnect( id )
{
	new szTime[32]
	formatex(szTime, charsmax(szTime), "%d", get_user_total_playtime( id ))
	nvault_set(g_iVault, g_szName[id], szTime)
}

Last edited by Magicher0ex; 09-26-2020 at 10:01.
Magicher0ex is offline
Magicher0ex
Member
Join Date: Dec 2019
Old 09-25-2020 , 21:07   Re: STEAMID played time
Reply With Quote #2

i mean szName stay but the time counting to be on steamid, not the name
Magicher0ex is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-25-2020 , 21:39   Re: STEAMID played time
Reply With Quote #3

Change
new g_szName[MAX_PLAYERS+1][32]
to
new g_szAuthID[MAX_PLAYERS+1][32]

In client_authorized, change
get_user_name(id, g_szName[id], charsmax(g_szName[]))
to
get_user_authid(id, g_szAuthID[id], charsmax(g_szAuthID[]))

In client_disconnect(), change
nvault_set(g_iVault, g_szName[id], szTime)
to
nvault_set(g_iVault, g_szAuthID[id], szTime)
__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-25-2020 , 22:30   Re: STEAMID played time
Reply With Quote #4

Quote:
Originally Posted by Magicher0ex View Post
i mean szName stay but the time counting to be on steamid, not the name
Saving time to NVault = 0
Save time by Name = 2
Save time by steamid = 1
Save time by IP = 0

Code:
#include <amxmodx> #include <colorchat> #include <nvault> #include <time> #define MAX_PLAYERS 32 new g_iVault new g_SaveTime, g_SaveType; new g_szAuth[MAX_PLAYERS+1][32] new g_iLastPlayedTime[MAX_PLAYERS+1] public plugin_init() {     register_plugin("Time", "0.1", "ConnorMcLeod")     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.     g_iVault = nvault_open("played_time")     register_clcmd("say /time", "ClientCommand_PlayedTime") } public plugin_end() nvault_close( g_iVault )   public client_authorized( id ) {     LoadData(id) } get_user_total_playtime( id ) {     return g_iLastPlayedTime[id] + get_user_time(id) } public ClientCommand_PlayedTime( id ) {     new szTime[128]     new szName[32]     get_time_length(id, get_user_total_playtime( id ), timeunit_seconds, szTime, charsmax(szTime))     get_user_name(id, szName, charsmax(szName))     ColorChat( id, GREEN, "^x04%s^x01's Time:^x04 %s", szName, szTime) } public client_disconnect( id ) {     SaveData(id) } SaveData(id) {     new szKey[64];         if (get_pcvar_num(g_SaveTime) == 0)     {         get_user_ip(id, g_szAuth[id] , charsmax(g_szAuth[]), 1)         formatex(szKey , charsmax(szKey) , "%s-IP" , g_szAuth[id])     }     else if (get_pcvar_num(g_SaveTime) == 1)     {         get_user_authid(id , g_szAuth[id] , charsmax(g_szAuth[]))         formatex(szKey , charsmax(szKey) , "%s-ID" , g_szAuth[id])     }     else if (get_pcvar_num(g_SaveTime) == 2)     {         get_user_name(id, g_szAuth[id] , charsmax(g_szAuth[]))         formatex(szKey , charsmax(szKey) , "%s-NAME" , g_szAuth[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)     {         get_user_ip(id, g_szAuth[id] , charsmax(g_szAuth[]), 1)         formatex(szKey , charsmax(szKey) , "%s-IP" , g_szAuth[id])     }     else if (get_pcvar_num(g_SaveTime) == 1)     {         get_user_authid(id , g_szAuth[id] , charsmax(g_szAuth[]))         formatex(szKey , charsmax(szKey) , "%s-ID" , g_szAuth[id])     }     else if (get_pcvar_num(g_SaveTime) == 2)     {         get_user_name(id, g_szAuth[id] , charsmax(g_szAuth[]))         formatex(szKey , charsmax(szKey) , "%s-NAME" , g_szAuth[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-25-2020 at 22:32.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-26-2020 , 00:42   Re: STEAMID played time
Reply With Quote #5

@Supremache:

1. You should set the appropriate value in g_szAuth[id] at client_authorized() instead of doing it twice--once at load and once at save. The goal is to call as few natives as possible in a plugin for efficiency.
2. There is no need to use anything but steam id as a unique identifier for a player.
__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-26-2020 , 01:10   Re: STEAMID played time
Reply With Quote #6

1. I was want to use one value for everything "Name, steamid, ip" but well i did it
Spoiler


2. I want to give him every opptions togther in plugin "'Name, steamid, Ip", I do that because there's other people at sometime searching for this thing and making a new topic but as we saying in egypt i dont know how to say that but it's like, This is the end of the topic
__________________
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 01:13.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-26-2020 , 11:07   Re: Thank you supre ;3
Reply With Quote #7

I don't agree with your argument. There's no reason why anyone should use anything but the steam id to store player-specific data. Only people who do not have steam would want this, which AMX-X does not support.
__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-26-2020 , 12:46   Re: Thank you supre ;3
Reply With Quote #8

I gave him more options and he have the choice

Code:
g_SaveTime = register_cvar("time_save","1") // Save time by : 2 = Name, 1 = SteamID, 0 = IP.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-26-2020 , 13:01   Re: Thank you supre ;3
Reply With Quote #9

I understand that. My point is there is no point in using name or IP... steam ID should be the ONLY unique player identifier that is used.
__________________
Bugsy is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 09-26-2020 , 13:05   Re: Thank you supre ;3
Reply With Quote #10

Quote:
Originally Posted by Bugsy View Post
I understand that. My point is there is no point in using name or IP... steam ID should be the ONLY unique player identifier that is used.
You are right, As i said i was want to give him more options
__________________
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


Thread Tools
Display Modes

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 00:55.


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