Raised This Month: $ Target: $400
 0% 

[AMXX 1.8.2] CSSTATS (native request)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
schmurgel1983
Veteran Member
Join Date: Aug 2006
Location: Germany
Old 10-11-2010 , 19:46   [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #1

request for amxx 1.8.2 csstats module,

native set_user_stats(index,stats[8],bodyhits[8])

for changing hits shots kills deaths...
that would be really nice.
__________________

Working on:
nothing
schmurgel1983 is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 10-11-2010 , 20:05   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #2

That actually would be pretty cool
__________________
Quote:
Originally Posted by DarkGod View Post
nikhilgupta generates his plugins using sheer awesome.
If you like my work, please
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-12-2010 , 00:29   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #3

Requests go in Bugzilla. Good luck!
__________________
fysiks is offline
schmurgel1983
Veteran Member
Join Date: Aug 2006
Location: Germany
Old 10-13-2010 , 06:04   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #4

good idea, but how...
find only bug report
__________________

Working on:
nothing
schmurgel1983 is offline
blanko
Senior Member
Join Date: Aug 2008
Old 10-13-2010 , 06:10   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #5

Quote:
Originally Posted by schmurgel1983 View Post
good idea, but how...
find only bug report
https://bugs.alliedmods.net/request.cgi
blanko is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-13-2010 , 17:56   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #6

I'm not entirely sure how it works but there is a few requests in there already. Find those and see if they just look like normal bug reports.

But remember, that this will probably never happen unless you do it.
__________________
fysiks is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-13-2010 , 19:44   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #7

I'll (try to) make it. It will not be as efficient as if it were coded in into the dll but it will do the trick.
__________________

Last edited by Bugsy; 10-13-2010 at 19:54.
Bugsy is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-14-2010 , 21:49   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #8

Well I coded reading and writing to csstats.dat successfully in Pawn but all changes made by my code are lost at map-change\restart since the csstats.dat file is open and being manipulated by csx module while the server is running. Someone will need to code this into the dll.

Here it is if anyone needs it for anything.
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <csx>

/*  -- csstats.dat file structure --
    * int16 - RANK_VERSION
    * uint16 - Bytes in first string (if 0, no entries)
          o sz - Name (read N bytes, where N is previous uint16)
          o uint16 - Bytes of next string
          o sz - Steam ID (read N bytes, where N is previous uint16)
          o uint32 - Team kills
          o uint32 - Damage
          o uint32 - Deaths
          o int32 - Kills
          o uint32 - Shots
          o uint32 - Hits
          o uint32 - Headshots
          o uint32 - Defusions
          o uint32 - Defusal Attempts
          o uint32 - Plants
          o uint32 - Explosions
          o uint32[9] - Body Hits (array of ints, one for each body hit area)
          o uint16 - If zero, end of file. Otherwise, loop back up and read the next name for this many bytes. 
*/

const RANK_VERSION 11;

//Array sizes for storing data in csstats.dat
const STATS_SIZE 11;
const 
BODYHITS_SIZE 9;

//Array sizes CSX functions use for reading data with natives
const CSX_STATS_SIZE 8;
const 
CSX_BODYHITS_SIZE 8;

enum _:Stats
{
    
TeamKills,  //3
    
Damage,     //6
    
Deaths,     //1
    
Kills,      //0
    
Shots,      //4
    
Hits,       //5
    
Headshots//2
    
Defusions//7
    
DefusalAttempts,
    
Plants,
    
Explosions
}

enum _:BodyHits
{
    
Generic,
    
Head,
    
Chest,
    
Stomach,
    
LeftArm,
    
RightArm,
    
LeftLeg,
    
RightLeg,
    Empty
}

new 
StatsTable[] = 
{
    
Kills,
    
Deaths,
    
Headshots,
    
TeamKills,
    
Shots,
    
Hits,
    
Damage,
    
Defusions
};

public 
plugin_init() 
{
    
register_clcmd"say hi" "Test" );
}

public 
Testid )
{
    new 
iStats] , iBHits];
    
    
//Get position in stats and stats data from csstats.dat
    
new iRankPos get_user_statsid iStats iBHits );
    
    
server_print"STATS BEFORE WRITE" );
    
    
//Read existing stats
    
ReadStats();
    
    
//Modify values to check if they change
    
iStats] = 1101;
    
iStats] = 1102;
    
iStats] = 1103;
    
iStats] = 1104;
    
iStats] = 1105;
    
iStats] = 1106;
    
iStats] = 1107;
    
iStats] = 1108;
    
    
//Write new values
    
WriteStatsiRankPos iStats iBHits );
    
    
server_print"STATS AFTER WRITE" );
    
    
//Read to see if changed after writing
    
ReadStats();
}
    
public 
ReadStats()
{
    new 
szFile64 ] , iFile;
    new 
iData10 ];
    new 
szString35 ] , iStringLen;
    new 
iStatsStats ] , iBHitsBodyHits ];
    
    
//Format the file name
    
copyszFileget_datadirszFile charsmaxszFile ) ) ] , charsmaxszFile ) , "/csstats.dat" );
    
    
//Open file for binary read
    
iFile fopenszFile "rb" );

    
//Read rank version
    
fread_rawiFile iData BLOCK_SHORT );
    
    if ( 
iData] != RANK_VERSION )
        
set_fail_state"Rank version does not match" );
    
    
//Read first name len (if 0, there are no player in stats file)
    
fread_rawiFile iData BLOCK_SHORT );
    
iStringLen iData] & 0xFFFF;

    while ( 
iStringLen )
    {        
        
//Read name
        
fread_rawiFile iData iStringLen BLOCK_CHAR );
        
ReadStringszString iStringLen charsmaxszString ) , iData );
        
server_print"Name: %s" szString );
        
        
//Read steamid len
        
fread_rawiFile iData BLOCK_SHORT );
        
iStringLen iData] & 0xFFFF;
        
        
//Read steamid
        
fread_rawiFile iData iStringLen BLOCK_CHAR );
        
ReadStringszString iStringLen charsmaxszString ) , iData );
        
server_print"SteamID: %s" szString );
        
        
//Read stats data
        
fread_rawiFile iStats STATS_SIZE BLOCK_INT );
        
server_print"%d %d %d %d %d %d %d %d %d %d %d" iStatsDamage ] ,
                                
iStatsKills ] ,
                                
iStatsDeaths ] ,
                                
iStatsTeamKills ] ,
                                
iStatsShots ] ,
                                
iStatsHits ] ,
                                
iStatsHeadshots ] ,
                                
iStatsPlants ] ,
                                
iStatsExplosions ] ,
                                
iStatsDefusions ] ,
                                
iStatsDefusalAttempts ] );
        
        
//Read body-hit data
        
fread_rawiFile iBHits BODYHITS_SIZE BLOCK_INT );
        
server_print"%d %d %d %d %d %d %d %d %d" iBHitsGeneric ] ,
                                
iBHitsHead ] ,
                                
iBHitsChest ] ,
                                
iBHitsStomach ] ,
                                
iBHitsLeftArm ] ,
                                
iBHitsRightArm ] ,
                                
iBHitsLeftLeg ] ,
                                
iBHitsRightLeg ] ,
                                
iBHits] );
        
        
//Read next players name len (if 0, end of stats)
        
fread_rawiFile iData BLOCK_SHORT );
        
iStringLen iData] & 0xFFFF;
    }
    
    
fcloseiFile );    
}

public 
WriteStatsiEntry iStatsCSX_STATS_SIZE ] , iBHitsCSX_BODYHITS_SIZE ] )
{
    new 
szFile64 ] , iFile;
    new 
iData10 ];
    new 
iStringLen;
    new 
iCurrentEntry;
    
    
copyszFileget_datadirszFile charsmaxszFile ) ) ] , charsmaxszFile ) , "/csstats.dat" );
    
    if ( !( 
iFile fopenszFile "rb+" ) ) )
        
set_fail_state"Error at file open" );
        
    
fread_rawiFile iData BLOCK_SHORT );
    
    if ( 
iData] != RANK_VERSION )
        
set_fail_state"Rank version does not match" );
    
    
fread_rawiFile iData BLOCK_SHORT );
        
    
iStringLen iData] & 0xFFFF;

    while ( 
iStringLen && ( ++iCurrentEntry <= iEntry ) )
    {
        
//Seek past the name data
        
fseekiFile iStringLen SEEK_CUR );
        
        
//Read steam-id len
        
fread_rawiFile iData BLOCK_SHORT );
        
iStringLen iData] & 0xFFFF;

        
//Seek past steam-id data
        
fseekiFile iStringLen SEEK_CUR );
        
        
//If current entry is the one we want to modify
        
if ( iCurrentEntry == iEntry )
        {
            
//The order of stats saved to csstats.dat and the order used
            //by csx are different, this puts them in correct order.
            
FixStatsOrderiStats );

            
//Write stats array
            
fwrite_rawiFile iStats CSX_STATS_SIZE BLOCK_INT )
            
//Only 8 of 11 ints are written so we seek past 3
            
fseekiFile , ( STATS_SIZE CSX_STATS_SIZE ) * BLOCK_INT SEEK_CUR );
            
            
//Write body-hit data
            
fwrite_rawiFile iBHits CSX_BODYHITS_SIZE BLOCK_INT );
            
//Only 8 of 9 ints are written so we seek past 1
            
fseekiFile , ( BODYHITS_SIZE CSX_BODYHITS_SIZE ) * BLOCK_INT SEEK_CUR );
        }
        else
        {
            
//This is not the entry that we want to modify so we skip past
            //the stats and bodyhit data.
            
fseekiFile , ( ( STATS_SIZE BODYHITS_SIZE ) * BLOCK_INT ) , SEEK_CUR );
        }
        
        
fread_rawiFile iData BLOCK_SHORT );    
        
iStringLen iData] & 0xFFFF;
    }
    
    
fcloseiFile );    
}

FixStatsOrderiStats] )
{
    new 
iTmpStats];
    
    
iTmpStats iStats;

    for ( new 
i++ )
        
iStats] = iTmpStatsStatsTable] ]; 
}

ReadStringszDestString[] , iLen iMaxLen SourceData[] )
{
    new 
iStrPos = -1;
    new 
iRawPos 0;
    
    while ( ( ++
iStrPos iLen ) && ( iStrPos iMaxLen ) && ( iRawPos 10 ) )
    {
        
szDestStringiStrPos ] = ( SourceDataiRawPos ] >> ( ( iStrPos ) * ) ) & 0xFF;
    
        if ( 
iStrPos && ( ( iStrPos ) == ) )
            
iRawPos++
    }
    
    
szDestStringiStrPos ] = EOS;

Code:
STATS BEFORE WRITE

Name: bugsy
SteamID: STEAM_0:0:12345
121 2 43 0 8274 2 0 7 7 2 2
0 0 0 2 0 0 0 0 0

STATS AFTER WRITE

Name: bugsy
SteamID: STEAM_0:0:12345
1103 1101 1107 1104 1105 1106 1102 7 7 1108 2
0 0 0 2 0 0 0 0 0
__________________

Last edited by Bugsy; 10-14-2010 at 23:14.
Bugsy is offline
souvikdas95
Senior Member
Join Date: Mar 2012
Old 04-02-2014 , 10:02   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #9

@Bugsy - how do i convert back from short int type to int. you know, just like how you converted from int to short int with '& 0xffff'
souvikdas95 is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 04-02-2014 , 10:08   Re: [AMXX 1.8.2] CSSTATS (native request)
Reply With Quote #10

Do you guys ever look at the date of the thread?
__________________
Kia 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 01:09.


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