Playd Time

Unpaid Requests, Public Plugins
User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 209
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

Playd Time

#1

Post by sPe3doN » 1 Month Ago

can we add new things on this plugin ?
Change time count to hours and minutes exp (Played Time for: 10h:26m)
and who reach 50 hours get vip for 15 days

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    ze_colored_print(id, "!tYour played time!y: !g%i !tMinutes!y!", g_iPlayedTime[id]/60)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#2

Post by Muhammet20 » 4 Weeks Ago

sPe3doN wrote:
1 Month Ago
can we add new things on this plugin ?
Change time count to hours and minutes exp (Played Time for: 10h:26m)
and who reach 50 hours get vip for 15 days

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    ze_colored_print(id, "!tYour played time!y: !g%i !tMinutes!y!", g_iPlayedTime[id]/60)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}
for the hours and minutes count, i have made 2 codes
but haven't tested it,
and for 15 day vip i don't know how to, you can ask @Raheem
you can try and choose the working one:

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    if(g_iPlayedTime[id] => 3600)
    {
    	ze_colored_print(id, "!tYour played time!y: !g%i !tHours!y!", g_iPlayedTime[id]/3600)
    }
    else
    {
	ze_colored_print(id, "!tYour played time!y: !g%i !tMinutes!y!", g_iPlayedTime[id]/60)
    }
}
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}

the other one:

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    ze_colored_print(id, "!tYour played time!y: !g%i !tHours!y!", g_iPlayedTime[id]/3600)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}

for my choose if the 2 codes are working, i prefer the second one
but it's for your opinion
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 209
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#3

Post by sPe3doN » 4 Weeks Ago

Muhammet20 wrote:
4 Weeks Ago
sPe3doN wrote:
1 Month Ago
can we add new things on this plugin ?
Change time count to hours and minutes exp (Played Time for: 10h:26m)
and who reach 50 hours get vip for 15 days

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    ze_colored_print(id, "!tYour played time!y: !g%i !tMinutes!y!", g_iPlayedTime[id]/60)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}
for the hours and minutes count, i have made 2 codes
but haven't tested it,
and for 15 day vip i don't know how to, you can ask @Raheem
you can try and choose the working one:

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    if(g_iPlayedTime[id] => 3600)
    {
    	ze_colored_print(id, "!tYour played time!y: !g%i !tHours!y!", g_iPlayedTime[id]/3600)
    }
    else
    {
	ze_colored_print(id, "!tYour played time!y: !g%i !tMinutes!y!", g_iPlayedTime[id]/60)
    }
}
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}

the other one:

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    ze_colored_print(id, "!tYour played time!y: !g%i !tHours!y!", g_iPlayedTime[id]/3600)
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}

for my choose if the 2 codes are working, i prefer the second one
but it's for your opinion
how i dont think to use 3600 damn it, good idea thanks dude, but we still have a problem if you played 2 hours it will be like this 2hours:120minute

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#4

Post by Muhammet20 » 3 Weeks Ago

which code are you using? the first or second?

[ Post made via Android ]
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 209
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#5

Post by sPe3doN » 3 Weeks Ago

Muhammet20 wrote:
3 Weeks Ago
which code are you using? the first or second?
Seconde code and I add this : , g_iPlayedTime[id]/60)

[ Post made via Android ]

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#6

Post by Muhammet20 » 3 Weeks Ago

sPe3doN wrote:
3 Weeks Ago
Muhammet20 wrote:
3 Weeks Ago
which code are you using? the first or second?
Seconde code and I add this : , g_iPlayedTime[id]/60)
try the code without add anything
also try it from another name, i mean try it from a new name to see when your played hours is under the one hours how it will seen and if not work i will fix it when turn my pc on

[ Post made via Android ]
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 209
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#7

Post by sPe3doN » 3 Weeks Ago

Muhammet20 wrote:
3 Weeks Ago
sPe3doN wrote:
3 Weeks Ago
Muhammet20 wrote:
3 Weeks Ago
which code are you using? the first or second?
Seconde code and I add this : , g_iPlayedTime[id]/60)
try the code without add anything
also try it from another name, i mean try it from a new name to see when your played hours is under the one hours how it will seen and if not work i will fix it when turn my pc on
nah there is no problem on code we just need to add somthing that reset minutes to 0 when minutes be 59

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#8

Post by Muhammet20 » 3 Weeks Ago

i have a new idea for this but am sorry you must wait cuz i can't turn the pc in anytime, just somedays and i will give you the fix

[ Post made via Android ]
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
Muhammet20
Veteran Member
Veteran Member
Syria
Posts: 399
Joined: 1 Year Ago
Location: Turkey
Has thanked: 36 times
Been thanked: 5 times
Age: 13
Contact:

#9

Post by Muhammet20 » 3 Weeks Ago

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    if(g_iPlayedTime[id] => 3600)
    {
        ze_colored_print(id, "!tYour played time!y: !g%i !tHours!y!", g_iPlayedTime[id]/60)
    }
    else
    {
        ze_colored_print(id, "!tYour played time!y: !g%i !tHours!y and !g%i !tMinutes!y!",g_iPlayedTime[id]/3600 ,g_iPlayedTime[id]/60-60)
    }
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}
i'm sure this will work with you, but if not work wait me a few days while founding a fix
let me know if work or not

[ Post made via Android ]
.::Kaya Gaming || Never Give Up || Zombie Escape::. [Server is Under The Work]
https://kaya-gaming.ga/

I just believe in two things, First thing is who i see in the mirror, second thing is who i don't see in the sky.

User avatar
sPe3doN
Senior Member
Senior Member
Algeria
Posts: 209
Joined: 2 Years Ago
Has thanked: 14 times
Been thanked: 7 times
Age: 20
Contact:

#10

Post by sPe3doN » 3 Weeks Ago

Muhammet20 wrote:
3 Weeks Ago

Code: Select all

#include <zombie_escape>
#include <nvault>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler
 
public plugin_natives()
{
    // Native to return played time in seconds, plugin will save using nVault
    register_native("ze_get_played_time", "native_ze_get_played_time", 1)
}
 
public plugin_init()
{
    register_plugin("Played Time", "1.0", "Raheem")
   
    // Commands
    register_clcmd("say /played", "ShowPlayedTime")
    register_clcmd("say_team /played", "ShowPlayedTime")
}
 
public ShowPlayedTime(id)
{
    if(g_iPlayedTime[id] => 3600)
    {
        ze_colored_print(id, "!tYour played time!y: !g%i !tHours!y!", g_iPlayedTime[id]/60)
    }
    else
    {
        ze_colored_print(id, "!tYour played time!y: !g%i !tHours!y and !g%i !tMinutes!y!",g_iPlayedTime[id]/3600 ,g_iPlayedTime[id]/60-60)
    }
}
 
public client_putinserver(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
   
    // Save played seconds
    set_task(1.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, _, _, "b")
}
 
public DelayLoad(id)
{
    // Load his time played
    LoadPlayedTime(id)
}
 
public IncreaseTimePlayed(taskid)
{
    new id = taskid - PLAYED_TIME_TASK
   
    g_iPlayedTime[id]++
}
 
public client_disconnected(id)
{
    if(is_user_hltv(id) || is_user_bot(id))
        return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
    g_iPlayedTime[id] = 0
}
 
public SavePlayedTime(id)
{
    new szAuthID[35]
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    new szData[128]
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Open the Vaults
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, szData)
   
    // Close Vaults
    nvault_close(g_iVaultHandler)
}
 
public LoadPlayedTime(id)
{
    new szData[128], szAuthID[35]
   
    get_user_authid(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
   
    // Open the Vault
    g_iVaultHandler = nvault_open(g_szVault_Name)
   
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)
   
    // Close Vault
    nvault_close(g_iVaultHandler)
   
    if (!iExists)
    {
        g_iPlayedTime[id] = 0
        SavePlayedTime(id)
    }
    else
    {
        g_iPlayedTime[id] = str_to_num(szData)
    }
}
 
public native_ze_get_played_time(id)
{
    if(!is_user_connected(id))
    {
        log_error(AMX_ERR_NATIVE, "[ZE] Invalid Player id (%d)", id)
        return -1;
    }
   
    return g_iPlayedTime[id]
}
i'm sure this will work with you, but if not work wait me a few days while founding a fix
let me know if work or not
it will not work like that, but i already fix it i add seconds too

Code: Select all

ze_colored_print(id, "!yYour Total played time is: !g%i!yH!t:!g%i!yM!t:!g%i!yS", g_iPlayedTime[id]/3600 ,g_iPlayedTime[id]%60 ,g_iPlayedTime[id]%60)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest