AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check the player's played time (https://forums.alliedmods.net/showthread.php?t=326876)

Magicher0ex 08-21-2020 08:18

Check the player's played time
 
3 Attachment(s)
Hey guys, i need help. Can anyone remake this plugin to be with public player's time info...
example: /time "player name" - "player's played time is "total played time" "
And if the system didn't found the player to print the message: client_print_color(id, id, "%s There is no OR multiple players with that name ->^x03 %s", szTarget);

Code preview:
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)
}


Natsheh 08-21-2020 09:22

Re: Check the player's played time
 
PHP Code:

public ClientCommand_PlayedTimeid )
{
    new 
szPlayer[32], temp;
    
read_argv(2szPlayer31);
        
    if((
temp=cmd_target(idszPlayer)) > 0)
        {
        
id temp;
    }

    new 
szTime[128]
    new 
szName[32]
    
get_time_length(idget_user_total_playtimeid ), timeunit_secondsszTimecharsmax(szTime))
    
get_user_name(idszNamecharsmax(szName)) 
    
ColorChatidGREEN"^x04%s^x01's Time:^x04 %s"szNameszTime)


Replace and give it a try.

PS : this section is for the people that are interested in coding. And want to learn.

Magicher0ex 08-21-2020 15:48

Re: Check the player's played time
 
Quote:

Originally Posted by Natsheh (Post 2715015)
PHP Code:

public ClientCommand_PlayedTimeid )
{
    new 
szPlayer[32], temp;
    
read_argv(2szPlayer31);
        
    if((
temp=cmd_target(idszPlayer)) > 0)
        {
        
id temp;
    }

    new 
szTime[128]
    new 
szName[32]
    
get_time_length(idget_user_total_playtimeid ), timeunit_secondsszTimecharsmax(szTime))
    
get_user_name(idszNamecharsmax(szName)) 
    
ColorChatidGREEN"^x04%s^x01's Time:^x04 %s"szNameszTime)


Replace and give it a try.

PS : this section is for the people that are interested in coding. And want to learn.

error 017: undefined symbol "cmd_target"

Shadows Adi 08-21-2020 18:26

Re: Check the player's played time
 
Quote:

Originally Posted by Magicher0ex (Post 2715043)
error 017: undefined symbol "cmd_target"

Code:
#include < amxmisc >

Magicher0ex 08-22-2020 00:48

Re: Check the player's played time
 
Quote:

Originally Posted by Shadows Adi (Post 2715060)
Code:
#include < amxmisc >

Yeah the file compilated but it doesn't work correctly.
The command /time "player name" doesn't working
1. I need to type this command in the chat, not console.
2. If doesn't found the name in the chat, it must add 1 more message: "There is NOT OR multiple with that name --> %s"

I saw it's a console command but i don't need it, also if i can't found the client he prints my name in the chat.


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

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