Files

> > CS2D > Lua Scripts > [UNUSED] Get Player Rank v1.4
Files overviewCS2D overviewLua Scripts overview

English [UNUSED] Get Player Rank v1.4 >

18 comments2 kb, 686 Downloads

old [UNUSED] Get Player Rank v1.4

MikuAuahDark
User Off Offline

INFO
Because cs2d lua cmd stats already exists, you no longer need this script. Only download this if you want to know how to extract player rank information from sys/userstats.dat
Get player rank from userstats.dat by user MikuAuahDark

∗ Description ∗
This lua allows you to get player stats from userstats.dat file located at "sys/stats" folder
It include Kills, Frags, Deaths, and Time on Server

∗ Features ∗
• > Get player rank from userstats.dat(it include kills, frags, deaths, and time on server)

∗ How to Install ∗
Put files at desired folder and edit server.lua to execute rank.txt.

∗ Reserved Global Variable
> GetUserStatsRank

∗ Information ∗
> Hooks: 0
> Lines: 35(with description 53 lines)
> Size: 881 Bytes(with description 1539 Bytes)

∗ Functions
> GetUserStatsRank(usgn(number))
• Parameters:
• - usgn, ID of the USGN to see the rank information from userstats.dat
• ∗ Returns: A information from userstats.dat(table)

∗ Table Index ∗
Table returned by GetUserStatsRank function have this index:
isexists - Is the rank exists(boolean)
score - USGN Score(number)
frags - USGN frags(number)
deaths - USGN deaths(number)
time - Time on server(in seconds)(number)

∗ Special Thanks to ∗
• user DC: For the userstats.dat file format(at thread cs2d Server rank issue(score is altered)(Here))

∗ Rules ∗
√ You can use it for your server
√ You can edit it
√ You can upload at another website, say user MikuAuahDark made it
× You can't say this is yours
× You can't upload on another website without put me on credits

∗ Notes ∗
• 1. it doesn't use any library function(for stream files) for lua. it uses default io.open file:read function
• 2. if you want to learn how the code works, take a look at rank_desc.txt
• 3. there's a addional index which retrieves very first used player name on the server. Check rank.txt for more info

∗ PHP Implementation ∗
Here's the PHP implementation of v1.4(tested in PHP 5.5.0)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
function GetUserStatsRank($usgn) {
	$Int=function($f) {
		return ord(fread($f,1))+ord(fread($f,1))*256+ord(fread($f,1))*65536+ord(fread($f,1))*16777216;
	};
	$f=fopen("sys/stats/userstats.dat","rb");
	fseek($f,0,SEEK_END);
	$size=ftell($f);
	fseek($f,17,SEEK_SET);
	$temp=[
		"isexists"=>FALSE,
		"score"=>0,
		"frags"=>0,
		"deaths"=>0,
		"time"=>0,
	];
	while(ftell($f)!=$size) {
		fgets($f);		// skip player name
		$temp_usgn=$Int($f);
		if($usgn==$temp_usgn) {
			$temp["isexists"]=TRUE;
			$temp["score"]=$Int($f);
			$temp["frags"]=$Int($f);
			$temp["deaths"]=$Int($f);
			$temp["time"]=$Int($f);
			break;
		} else fseek($f,16,SEEK_CUR);
	}
	fclose($f);
	return $temp;
}
?>

∗ Version History ∗
> V1.4
• >
CHANGED
Int function isn't global variable anymore
• >
INFO
Rewrite code from stratch. It now ~10x faster than V1.3
> V1.3
• >
FIXED
You can't read the first USGN that enter your server
> V1.2
• >
CHANGED
The file now is opened with binary mode which would solve a error that would not read the file correctly
> V1.1
• >
REMOVED
Player rank on server. I just accidently put "step" variable as rank number
> V1.0
• >
ADDED
Initial Release

∗ Another MikuAuahDark Scripts ∗
> file cs2d Timer Extra function(timerEx) v4.0
> file cs2d Env_Laser v1.0
> file cs2d Weapon Hudtxt v1.0
> file cs2d Improved Badwords v2.0
edited 10×, last 21.06.15 11:04:20 pm
Approved by Starkkz

Download Download

2 kb, 686 Downloads

Comments

18 comments
To the start Previous 1 Next To the start

Log in!

You need to log in to be able to write comments!Log in

old

HoOtix
User Off Offline

Just great.It's so bad..BAD@SS! Epic
I like it!

old

Sapiens
User Off Offline

Good job. New version is more useful. We can take the player's first name in rank
I like it!

old

Ajmin
User Off Offline

Looks good!
Keep going
I like it!

old

Legend7
User Off Offline

nice work
I like it!

old Cries

ExEc ExE
User Off Offline

Your work is so underrated.
Makes me cri everitem *Sad violin*
I like it!

old

Avo
User Off Offline

Just view Miku's files. They're useful, damn useful and nobody likes them.
I like it!

old

Rainoth
Moderator Off Offline

@user Avo: I can fix that.
I like it!

old

TopNotch
User Off Offline

user Avo: Agree.
File: Good work.
I like it!

old

Avo
User Off Offline

I always wonder why so awesome uploads have only about 5-8 likes.
I like it!

old

mr_s
User Off Offline

how to do your time on server like that??

anyways, thank you!
I like it!

old

MikuAuahDark
User Off Offline

Thanks. But i just accidently put "step" variable as Player Rank LOL.

old

BcY
Reviewer Off Offline

looks good.
good job.
I like it!

old

Infinite Rain
Reviewer Off Offline

ooops, forgotten to put a like.
I like it!

old

_Yank
User Off Offline

This type of script would help me too much. I hate when someone asks me to say rank. I need to move my hands start hitting the keys ._.
Then they ask how can they view other infos and i have to teach them how they can activate the fullrankinfo using my fingers again.

And about how to install, you could edit it and write "Put it inside autorun folder". Seems like you want to see comments like i cant install

Good, script, clean and small. Above my lua skills. You could do mathmatics to know the time on server in hours or minutes.
I like it!

old

Infinite Rain
Reviewer Off Offline

xD, I wanted to do this yesterday, you're a friggin ninja.
I like it!

old

MikuAuahDark
User Off Offline

@user D-D3ADxPro: what hudtxt?? it just return table not return any message. The message on screenshot is just cs2d lua cmd msg2

old

D-D3ADxPro
User Off Offline

The only reason why I liked this file was because the description is filled with good information. This script is pretty useful.
I like it!
edited 1×, last 30.07.13 05:13:10 am
To the start Previous 1 Next To the start