TP

Modificari necesare ale pluginurilor

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Post Reply
User avatar
spedon
Membru, skill 0
Membru, skill 0
Posts: 31
Joined: 25 Nov 2016, 04:41
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 8 times
Contact:

14 Jul 2021, 01:23

can someone fix this, evrey time i disconnect from server time played restart to 0

Code: Select all

#include <amxmodx>
#include <nvault>
#include <zb_stocks>
 
#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 /online", "ShowPlayedTime")
    register_clcmd("say_team /online", "ShowPlayedTime")
}
 
public ShowPlayedTime(id) 
{
    new mins = g_iPlayedTime[id]/60

    ColorChat(id, "!yyour Total played time is:  !g%d !yminutes", mins)
}


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)
}
 
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)
    {
        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
spedon
Membru, skill 0
Membru, skill 0
Posts: 31
Joined: 25 Nov 2016, 04:41
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 8 times
Contact:

17 Jul 2021, 23:18

???
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3287
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Discord: Levin#0061
Has thanked: 39 times
Been thanked: 500 times
Contact:

20 Jul 2021, 17:23

Code: Select all

#include <amxmodx>
#include <nvault>
#include <zb_stocks>
 
#define PLAYED_TIME_TASK 9100
 
new const g_szVault_Name[] = "Played_Time"
 
new g_iPlayedTime[33], g_iVaultHandler

public plugin_end(){
    // Close Vault
    if(g_iVaultHandler!=-1) nvault_close(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")

    // Open the Vault
    g_iVaultHandler=nvault_open(g_szVault_Name)
    if(g_iVaultHandler==-1) set_fail_state("NVAULT ERROR")
   
    // Commands
    register_clcmd("say /online", "ShowPlayedTime")
    register_clcmd("say_team /online", "ShowPlayedTime")
}
public ShowPlayedTime(id) ColorChat(id, "Your total played time is:!g %d!y minu.", g_iPlayedTime[id])

public client_putinserver(id){
    if(is_user_hltv(id) || is_user_bot(id)) return
    // Just 1 second delay
    set_task(0.5, "DelayLoad", id)
}
public DelayLoad(id){
    // Load his time played
    LoadPlayedTime(id)
}
public LoadPlayedTime(id){
    new szData[30], szAuthID[33]
    get_user_name(id, szAuthID, charsmax(szAuthID))
   
    // Useless Variable
    new iTimestamp, iExists
    iExists = nvault_lookup(g_iVaultHandler, szAuthID, szData, charsmax(szData), iTimestamp)

    g_iPlayedTime[id] = iExists?str_to_num(szData):0

    // Save played minu.
    set_task(60.0, "IncreaseTimePlayed", id+PLAYED_TIME_TASK, .flags= "b")
}
public IncreaseTimePlayed(taskid){
    new id = taskid - PLAYED_TIME_TASK
    g_iPlayedTime[id]++
}

#if AMXX_VERSION_NUM >= 183
public client_disconnected(id)
#else
public client_disconnect(id)
#endif
{
    if(is_user_hltv(id) || is_user_bot(id)) return
   
    // Save played time
    SavePlayedTime(id)
   
    remove_task(id+PLAYED_TIME_TASK)
    remove_task(id)
}
public SavePlayedTime(id){
    new szAuthID[33],szData[30]
    get_user_name(id, szAuthID, charsmax(szAuthID))
    num_to_str(g_iPlayedTime[id], szData, charsmax(szData))
   
    // Saves His Data
    nvault_set(g_iVaultHandler, szAuthID, 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]
}
Faceți cerere bine detaliată aici și respectând modelul dacă vreți ajutor.
Nu-mi mai dați add doar pentru a mă avea în lista de prieteni.
Dacă te ajut, și mă ignori/etc > te adaug la lista de „ignore”.
Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine(STEAM sau PM) dacă aveți o problemă/nelămurire în acest caz! (am cont doar aici!!)
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici, iar dacă sunt ceva probleme sau aveți dvs. probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se va posta la actual, doar dacă se găsește ceva critic/urgent de remediat, fiind coduri vechi, iar unele refăcute recent. NU MAI OFER SUPORT PENTRU ELE!(doar dacă nu e ceva critic/sau plătit)
* Nume pe cs1.6: eVoLuTiOn
* Atelierul meu - anunturi/lev-shop-t370037.html
INACTIV
Post Reply

Return to “Modificari pluginuri”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests