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

Count disconnected player's data


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tepegoz
Senior Member
Join Date: Apr 2019
Old 05-08-2020 , 09:53   Count disconnected player's data
Reply With Quote #1

I have a plugin that is counting player's stopwatch time. Player's stopwatch time showing a motd list. I want to count disconnected player's stopwatch time.
So player1 first starts stopwatchs and time is started and player1 disconnected. In this sequence I want to count with this public to disconnected players time. How to do it? I try remove is_user_connected(z) but I don't know much.

HTML Code:
public pAddName(){
	new z
	for(z=1; z<=33; z++) {	
		
		if(!is_user_bot(z) &&  !is_user_hltv(z) && is_user_connected(z) && model_is_alan[z]){
			new aname[6]
			get_user_name(z,aname,5)
			new team = get_user_team(z)
			
			
			
			new lFirstSaid[64];
			format(lFirstSaid, 63, "%s - %d: %d: %d - %s -",aname, gPlayerStopwatch[z][TIME_SAAT], gPlayerStopwatch[z][TIME_MINUTES], gPlayerStopwatch[z][TIME_SECONDS],team)
			ArrayPushString(gNames,lFirstSaid);
			ArrayPushString(gDates,gDateNow);
		}
	}
	return PLUGIN_CONTINUE;
}
tepegoz is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-08-2020 , 15:47   Re: Count disconnected player's data
Reply With Quote #2

You would need to store player data in a database of some sort, or vault, and then read all records to display the disconnected player data. Your current code handles only those that are actively connected.

There are some things in your code that are wrong as well.
__________________

Last edited by Bugsy; 05-08-2020 at 15:49.
Bugsy is offline
tepegoz
Senior Member
Join Date: Apr 2019
Old 05-10-2020 , 10:08   Re: Count disconnected player's data
Reply With Quote #3

This is my plugin. It count players model time and shows its on a list. Can you convert these codes to make saving also disconnected players stats? I want to change this part :
format(lFirstSaid, 63, "%s - %d: %d: %d - %s -",aname, gPlayerStopwatch[z][TIME_SAAT], gPlayerStopwatch[z][TIME_MINUTES], gPlayerStopwatch[z][TIME_SECONDS],team)
to
Not only connected players, it count all of players who take model.



PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <cstrike>
#include <engine>
#include <fakemeta>
#include <fun>
#include <amxmisc>
#include <nvault>


#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"







enum Time
{
TIME_MSECONDS 0,
TIME_SECONDS,
TIME_MINUTES,
TIME_SAAT
};





new 
gPlayerStopwatch[33][Time];
new 
Float:gPlayerNextIncrementTime[33];
new 
bool:gPlayerStopwatchActive[33];
new 
bool:gPlayerShowStopwatch[33];
new 
cVault,Array:gNames,Array:gDates,gDateNow[29]
new 
bool:user_is_model[33]
new 
bool:model_is_alan[33] = false 
public plugin_init() {


gNames ArrayCreate(512);
gDates ArrayCreate(512);
cVault nvault_open("names");
get_time("(%d.%m.%Y)",gDateNow,charsmax(gDateNow));
new 
lKey[16],lCountNames;
formatex(lKey,charsmax(lKey),"TotalName");
lCountNames nvault_get(cVault,lKey);

if(
lCountNames){
    new 
lGetName[28],lGetDate[28];
    for(new 
ilCountNamesi++){
        
formatex(lKey,charsmax(lKey),"%i-Name",i);
        
nvault_get(cVault,lKey,lGetName,charsmax(lGetName));
        
ArrayPushString(gNames,lGetName);
        
formatex(lKey,charsmax(lKey),"%i-Time",i);
        
nvault_get(cVault,lKey,lGetDate,charsmax(lGetDate));
        
ArrayPushString(gDates,lGetDate);
    }
}
register_plugin(PLUGINVERSIONAUTHOR)
register_clcmd("say /stoptimes","stoptimes"
register_clcmd("say /model","cmdmodel"
register_clcmd("say_team /model","cmdmodel"
register_clcmd("say /list","pShowNames");
register_clcmd("say /nomodel","cmdnomodel"
register_forward(FM_PlayerPreThink"Forward_PlayerPreThink");
}
public 
plugin_precache()
{
precache_model("models/player/player1/player1.mdl")
precache_model("models/player/player2/player2.mdl")
}


public 
client_connect(id)
{


model_is_alan[id] = false
static i;
for (
03i++)
gPlayerStopwatch[id][Time:i] = 0;
    
gPlayerNextIncrementTime[id]    = 0.0;
gPlayerStopwatchActive[id]     = false;

}
public 
Forward_PlayerPreThink(id)
{    
    
    
    if (
gPlayerStopwatchActive[id])
    {    
        
// Note sure if this is even right (I forget how I even came to this, but it seems to work)...
        
if (gPlayerNextIncrementTime[id] < get_gametime())
        {
            ++
gPlayerStopwatch[id][TIME_MSECONDS];
            
            if (
gPlayerStopwatch[id][TIME_MSECONDS] >= 10)
            {
                
gPlayerStopwatch[id][TIME_MSECONDS] = 0;
                ++
gPlayerStopwatch[id][TIME_SECONDS];
            }
            
            if (
gPlayerStopwatch[id][TIME_SECONDS] >= 60)
            {
                
gPlayerStopwatch[id][TIME_SECONDS] = 0;
                ++
gPlayerStopwatch[id][TIME_MINUTES];
            }
            if (
gPlayerStopwatch[id][TIME_MINUTES] >= 60)
            {
                
gPlayerStopwatch[id][TIME_MINUTES] = 0;
                ++
gPlayerStopwatch[id][TIME_SAAT];
            }
            
            
gPlayerNextIncrementTime[id] = get_gametime() + 0.1;
        }    
    }
    if (
gPlayerShowStopwatch[id])
    {
        
set_hudmessage(025500.00.2500.0010.001);
        
show_hudmessage(id"Stopwatch: %d:%d:%d"gPlayerStopwatch[id][TIME_SAAT], gPlayerStopwatch[id][TIME_MINUTES], gPlayerStopwatch[id][TIME_SECONDS]);
    }
    return 
FMRES_HANDLED;
}
public 
cmdmodel(id

    
    if(
is_user_alive(id))
    {
        
model_is_alan[id] = true 
        gPlayerStopwatchActive
[id] = true;
        
gPlayerShowStopwatch[id]     = true;
    
        
//modelalan[id] = 1
        
new userteam get_user_team(id
        if(!
user_is_model[id]) 
        {
            
            if(
userteam == 2
            { 
                
                
user_is_model[id] = true 
                
                cs_set_user_model
(id"player2")
                
            } 
            else if(
userteam == 1
            { 
                
user_is_model[id] = true 
                cs_set_user_model
(id"player1")        
                
            }    
            
            
        }
    }
    return 
PLUGIN_HANDLED
}

public 
cmdnomodel(id
{     
    
    if(
user_is_model[id]) 
    {
        
gPlayerStopwatchActive[id] = false;
        
        new 
CsTeams:userteam cs_get_user_team(id
        new 
name[33
        
get_user_name(idname,3)
        
        if(
userteam == CS_TEAM_CT
        { 
            
            
user_is_model[id] = false     
            
            
            
            cs_reset_user_model
(id)
            
        } 
        else if(
userteam == CS_TEAM_T
        { 
            
            
user_is_model[id] = false 
            
            
            cs_reset_user_model
(id)
            
        } 
    } 


public 
stoptimes(id){    
    
ArrayClear(gNames);
    
ArrayClear(gDates);
    
set_task(1.0,"pAddName")    
}
public 
pShowNames(uIndex){
    new 
bmMotd[1680],bmAnlat;
    
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<head><style>table,th,td { border: 1px solid green;color:white; } td { width:100% }</style></head>");
    
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<center><ul>");    
    
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<span>Text</span>")
    new 
lTotal ArraySize(gNames),lSearchForName[28],lGetTime[28];
    if(
lTotal){
        for(new 
ilTotali++){
            
ArrayGetString(gNames,i,lSearchForName,charsmax(lSearchForName));
            
ArrayGetString(gDates,i,lGetTime,charsmax(lGetTime));
            
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"<li>%s %s</li>",lSearchForName,lGetTime);
        }    
    }
    
bmAnlat += formatex(bmMotd[bmAnlat],charsmax(bmMotd)-bmAnlat,"</ul><center>");
    
show_motd(uIndex,bmMotd,"Text");
}

public 
pAddName(){
    new 
z
    
for(z=1z<=33z++) {    
        
        if(!
is_user_bot(z) &&  !is_user_hltv(z) && is_user_connected(z) && model_is_alan[z]){
            new 
aname[6]
            
get_user_name(z,aname,5)
            new 
mapname[64]
            
get_mapname(mapname,63)
            new 
team get_user_team(z)
            
            new 
lFirstSaid[64];

            
format(lFirstSaid63"%s - %d: %d: %d - %s -",anamegPlayerStopwatch[z][TIME_SAAT], gPlayerStopwatch[z][TIME_MINUTES], gPlayerStopwatch[z][TIME_SECONDS],team)
            
ArrayPushString(gNames,lFirstSaid);
            
ArrayPushString(gDates,gDateNow);
            
        }
    }
    return 
PLUGIN_CONTINUE;
}

public 
plugin_end(){
    
    
    
    
    new 
lKey[16],lCountNames =  ArraySize(gNames),lNTS[6],lSearchForName[28],lGetTime[28];
    for(new 
ilCountNamesi++){
        
ArrayGetString(gNames,i,lSearchForName,charsmax(lSearchForName));
        
ArrayGetString(gDates,i,lGetTime,charsmax(lGetTime));
        
formatex(lKey,charsmax(lKey),"%i-Name",i);
        
nvault_set(cVault,lKey,lSearchForName);
        
formatex(lKey,charsmax(lKey),"%i-Time",i);
        
nvault_set(cVault,lKey,lGetTime);
    }    
    
num_to_str(lCountNames,lNTS,charsmax(lNTS));
    
formatex(lKey,charsmax(lKey),"TotalName");
    
nvault_set(cVault,lKey,lNTS);
    
nvault_close(cVault);

tepegoz is offline
Reply



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 05:36.


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