Raised This Month: $32 Target: $400
 8% 

is it correct? (players stats)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mrmiki
Junior Member
Join Date: Mar 2021
Old 06-25-2021 , 14:17   is it correct? (players stats)
Reply With Quote #1

hi
i want to write player stats on map end
is it correct?
how can i improve it?







HTML Code:
#pragma semicolon 1
#include <cstrike>
#include <clientprefs>




new String:szFile[256];



public OnPluginStart()
{
	//RegAdminCmd("sm_addadmin", Command_AddAdmin, ADMFLAG_ROOT, "Adds an admin to admins_simple.ini");
	HookEvent("round_end", round_end);
	HookEvent("cs_win_panel_match", round_end);
	
}


public OnMapStart()
{
    BuildPath(Path_SM, szFile, sizeof(szFile), "configs/ranks.txt");
    new Handle:h0File = OpenFile(szFile, "w");
    WriteFileLine(h0File, "//ranks");
    CloseHandle(h0File);
}






public round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
    decl client;
    client = GetClientOfUserId(GetEventInt(event, "userid"));
    if(StrContains(name, "cs_win_panel_match", false) != -1) // Map end
    {
    char AuthId[64];
    char Name[64];
    char IPAddress[32];
    new frags = GetScore(client);
    new deaths = GetDeaths(client);
    new assists = GetAssists(client);
    new realscore = GetRealScore(client);
    new mvp = GetMvp(client);
    new totalcashspent = GetTotalCashSpent(client);
    
    
    
    GetClientName(client, Name, sizeof(Name));
    GetClientAuthId(client, AuthId_Steam2, AuthId, sizeof(AuthId));
    GetClientIP(client, IPAddress, sizeof(IPAddress), true);
    
    
    if (client && IsClientInGame(client))
    {
        new Handle:hFile = OpenFile(szFile, "w");
        WriteFileLine(hFile, "\"%N\" \"%s\" \"%s\" \"%i\" \"%i\" \"%i\" \"%i\" \"%i\"", Name, AuthId, IPAddress, frags, deaths, assists, realscore, mvp, totalcashspent);
        
        CloseHandle(hFile);
    }
    }
}



public GetTotalCashSpent(client)
{
    return GetEntProp(client, Prop_Data, "m_iTotalCashSpent");
}
public GetDeaths(client)
{
    return GetEntProp(client, Prop_Data, "m_iDeaths");
}
public GetMvp(client)
{
    return GetEntProp(client, Prop_Data, "m_iMVPs");
}
public GetScore(client)
{
     return GetClientFrags(client);
}
public GetAssists(client)
{
    return CS_GetClientAssists(client);
}
public GetRealScore(client)
{
    return CS_GetClientContributionScore(client);
}
mrmiki is offline
mrmiki
Junior Member
Join Date: Mar 2021
Old 06-26-2021 , 07:11   Re: is it correct? (players stats)
Reply With Quote #2

Quote:
Originally Posted by mrmiki View Post
hi
i want to write player stats on map end
is it correct?
how can i improve it?
i just want to log these data to a txt file






HTML Code:
#pragma semicolon 1
#include <cstrike>
#include <clientprefs>




new String:szFile[256];



public OnPluginStart()
{
	//RegAdminCmd("sm_addadmin", Command_AddAdmin, ADMFLAG_ROOT, "Adds an admin to admins_simple.ini");
	HookEvent("round_end", round_end);
	HookEvent("cs_win_panel_match", round_end);
	
}


public OnMapStart()
{
    BuildPath(Path_SM, szFile, sizeof(szFile), "configs/ranks.txt");
    new Handle:h0File = OpenFile(szFile, "w");
    WriteFileLine(h0File, "//ranks");
    CloseHandle(h0File);
}






public round_end(Handle:event, const String:name[], bool:dontBroadcast)
{
    decl client;
    client = GetClientOfUserId(GetEventInt(event, "userid"));
    if(StrContains(name, "cs_win_panel_match", false) != -1) // Map end
    {
    char AuthId[64];
    char Name[64];
    char IPAddress[32];
    new frags = GetScore(client);
    new deaths = GetDeaths(client);
    new assists = GetAssists(client);
    new realscore = GetRealScore(client);
    new mvp = GetMvp(client);
    new totalcashspent = GetTotalCashSpent(client);
    
    
    
    GetClientName(client, Name, sizeof(Name));
    GetClientAuthId(client, AuthId_Steam2, AuthId, sizeof(AuthId));
    GetClientIP(client, IPAddress, sizeof(IPAddress), true);
    
    
    if (client && IsClientInGame(client))
    {
        new Handle:hFile = OpenFile(szFile, "w");
        WriteFileLine(hFile, "\"%N\" \"%s\" \"%s\" \"%i\" \"%i\" \"%i\" \"%i\" \"%i\"", Name, AuthId, IPAddress, frags, deaths, assists, realscore, mvp, totalcashspent);
        
        CloseHandle(hFile);
    }
    }
}



public GetTotalCashSpent(client)
{
    return GetEntProp(client, Prop_Data, "m_iTotalCashSpent");
}
public GetDeaths(client)
{
    return GetEntProp(client, Prop_Data, "m_iDeaths");
}
public GetMvp(client)
{
    return GetEntProp(client, Prop_Data, "m_iMVPs");
}
public GetScore(client)
{
     return GetClientFrags(client);
}
public GetAssists(client)
{
    return CS_GetClientAssists(client);
}
public GetRealScore(client)
{
    return CS_GetClientContributionScore(client);
}






i have change the plugin to this but still not working
what is wrong?


HTML Code:
#pragma semicolon 1
#include <cstrike>
#include <clientprefs>
#define WHITELIST_MAX 255




new String:whitelist[WHITELIST_MAX][512];
new String:path[PLATFORM_MAX_PATH];
new listlen;

public OnPluginStart()
{
	
	HookEvent("round_end", round_end);
	
}









public Action round_end(Event event, const char[] name, bool dontBroadcast) 
{
    //decl client;
    //client = GetClientOfUserId(GetEventInt(event, "userid"));
    //if(StrContains(name, "cs_win_panel_match", false) != -1) // Map end
    //{
    char AuthId[64];
    char Name[64];
    char IPAddress[32];
    char sFormat[512];
    int allround = CS_GetTeamScore(CS_TEAM_T) + CS_GetTeamScore(CS_TEAM_CT);
    for (new i = 1; i <= MaxClients; i++)
    {
    if(IsClientInGame(i) && !IsFakeClient(i))
    {
    new frags = GetScore(i);
    new deaths = GetDeaths(i);
    new assists = GetAssists(i);
    new realscore = GetRealScore(i);
    new mvp = GetMvp(i);
    new totalcashspent = GetTotalCashSpent(i);
    GetClientName(i, Name, sizeof(Name));
    GetClientAuthId(i, AuthId_Steam2, AuthId, sizeof(AuthId));
    GetClientIP(i, IPAddress, sizeof(IPAddress), true);
    
    BuildPath(PathType:Path_SM, path, sizeof(path), "configs/ranks.txt");
    new Handle:file = OpenFile(path, "a");
    Format(sFormat, sizeof(sFormat), "round \"%d\" : \"%N\" \"%s\" \"%s\" \"%d\" \"%d\" \"%d\" \"%d\" \"%d\"",allround, Name, AuthId, IPAddress, frags, deaths, assists, realscore, mvp, totalcashspent);
    TrimString(sFormat);
    WriteFileLine(file, "%21-s", sFormat);
    whitelist[listlen] = sFormat;
    listlen++;
    CloseHandle(file);
    }
    }
    return Plugin_Handled;
}

public GetTotalCashSpent(i)
{
    return GetEntProp(i, Prop_Data, "m_iTotalCashSpent");
}
public GetDeaths(i)
{
    return GetEntProp(i, Prop_Data, "m_iDeaths");
}
public GetMvp(i)
{
    return GetEntProp(i, Prop_Data, "m_iMVPs");
}
public GetScore(i)
{
     return GetClientFrags(i);
}
public GetAssists(i)
{
    return CS_GetClientAssists(i);
}
public GetRealScore(i)
{
    return CS_GetClientContributionScore(i);
}

Last edited by mrmiki; 06-26-2021 at 07:12. Reason: fix
mrmiki 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 14:31.


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