

Get player rank from userstats.dat by



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






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















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)





















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
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; } ?>







































edited 10×, last 21.06.15 11:04:20 pm
Approved by Starkkz
Download
2 kb, 729 Downloads