Author Topic: [beta] InGame ZitroStats  (Read 10923 times)

0 Members and 1 Guest are viewing this topic.

Offline Maff^

  • Major(1)
  • Posts: 20
    • Personal page
[beta] InGame ZitroStats
« on: December 05, 2006, 12:59:41 am »
Script Name:  ZitroStats-InGame
Script Description:  This script displays you ZitroStats Rank (and some more stats) in game.
Original Author(s): Maff^
Core Version: v2.5.2
Code:
Code: [Select]
const
PLAYER_STATS_ON=1;
PlAYER_STATS_URL='http://bl-tyrone.student.utwente.nl/zitrostats/PlayerStats.php';

var
Response: String;
ResponseLines: TStringArray;
i: integer;

procedure OnPlayerSpeak(Name, Text: string);
begin
if((Text='!stats')and(PLAYER_STATS_ON=1)) then begin
Response:= GetURL(PLAYER_STATS_URL+'?name='+Name);
ResponseLines:= split(Response,chr(13));
for i:=0 to ArrayHigh(ResponseLines) do SayToPlayer(NametoID(Name),ResponseLines[i]);
end;
end;

this is how it looks like:

Please don't look at my stupid sucking Rank/Stats

The script is not super usefull at the moment, but more of a tech demo.

This script is very simple, after the given command !stats the server requests a simple php file that is placed in your ZitroStats directory. The scripts returns you current rank and some kill/death info.

notes:
- Don't forget to save this file as PlayerStats.php in your ZitroStats root dir.
- Make sure you change the PlAYER_STATS_URL const, and point it to the url of you own ZitroStats dir!
- The rank/stats you get are not live, because all stats get only updated once in a while (on my server thats every 2 hours)
- script doesn't work on linux servers cause of bug in split() function, it will be fixed in next dedicated version
- Should write my own HTTPEncode function to make sure it does work with all the playernames. (Until 2.6 is released)
- Could do the same for the split function... :/
- Thx to cooz for the nice (example) scripts!

I've not tested this script on linux, or on many windows servers, so i'm not sure if there are bugs. Please report them here if you find one.
Live server info for Zitro-Stats: topic | brokenliquid.net/zitrostats/
Brokenliquid.net DM Serv (soldat://130.89.164.52:23073/) (1.4.2)
now playing: Jungle (2/32) next: Krab

sig updated on 06-10-2008 23:28:45 (GMT+1)

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: [beta] InGame ZitroStats
« Reply #1 on: December 05, 2006, 02:13:10 am »
Very nice script, however there's a bug. Doesn't work if there is a space between names. For example, "Player One" won't give any results. Must be "Player_One" or "Player.One". This makes the script useless as the majority of players have names that are more than 2 words ;)

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: [beta] InGame ZitroStats
« Reply #2 on: December 05, 2006, 02:13:41 am »
Excellent, this is exactly what Leo was asking for awhile back.

You should also mention you need script safe mode to be turned off.

EDIT: Bah damn you Leo, posted before me. Yeah you need to replace spaces with %20 and so forth for the other HTML characters.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: [beta] InGame ZitroStats
« Reply #3 on: December 05, 2006, 02:21:52 am »
Yeah, if you could make this work at Linux servers would be great :)

Offline cooz

  • Soldier
  • **
  • Posts: 187
  • BANNED
Re: [beta] InGame ZitroStats
« Reply #4 on: December 05, 2006, 04:18:23 am »
nice script, i'm glad more people starts to write them ;)

Leo, as Maff^ said, you have to wait till soldat v1.3.2 / dedi server v2.6 and this script will work on linux servers
Dead man! Dead man walking! We got a dead man walking here! Banned man crawling more like

Offline Titus

  • Major(1)
  • Posts: 3
Re: [beta] InGame ZitroStats
« Reply #5 on: January 16, 2007, 07:36:44 am »
yes, realy nice script. but i think a lot of more people would use it, if you could create a longer readme. because i dont know how to setup a apache/php/mysql server :(
i have 2 home soldat servers (VDSL, 5mbit). and it would be nice, if i could run  zitrostats on them.

Thank you very much.

Regards Titus

Offline FliesLikeABrick

  • Administrator
  • Flamebow Warrior
  • *****
  • Posts: 6144
    • Ultimate 13 Soldat
Re: [beta] InGame ZitroStats
« Reply #6 on: January 16, 2007, 11:08:59 am »
Very nice.  I was working with FoZ a long time ago to create a version of this to work with U13SSS, but that was before the server had scripting abilities... so it worked by having an external program connect to the admin connection of a server.

Nice Job

Offline Therier

  • Soldier
  • **
  • Posts: 102
Re: [beta] InGame ZitroStats
« Reply #7 on: March 06, 2007, 04:39:44 am »
very pity that this doesnt work on linux servers coz i have only linux servers :(

Offline KeYDoN

  • Major
  • *
  • Posts: 60
Re: [beta] InGame ZitroStats
« Reply #8 on: April 07, 2007, 08:48:50 am »
dont give up hope Therier, ask teh KeY! ;p

I got it work with my selfmade functions :)
HTTPEncode
xsplit

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: [beta] InGame ZitroStats
« Reply #9 on: April 11, 2007, 07:20:40 pm »
hi very nice stuff man! but i got one problem with zitrostats ingame when i finally
thought it would work...It gives back no result. it says server message:
and nothing more
i raelly dun know where to search anymore
thnx already  !
---
jus saw it gives this error:

getURL: Function Disabled (safemode = on)
« Last Edit: April 11, 2007, 07:30:37 pm by spkka »

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: [beta] InGame ZitroStats
« Reply #10 on: April 12, 2007, 12:49:25 am »
hi very nice stuff man! but i got one problem with zitrostats ingame when i finally
thought it would work...It gives back no result. it says server message:
and nothing more
i raelly dun know where to search anymore
thnx already  !
---
jus saw it gives this error:

getURL: Function Disabled (safemode = on)


You'll have to disable safemode, I believe there is a configuration option for such in server.ini.

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: [beta] InGame ZitroStats
« Reply #11 on: April 12, 2007, 12:59:04 am »
you can only disable safe mode by starting the server with -safe 0

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: [beta] InGame ZitroStats
« Reply #12 on: April 12, 2007, 07:31:31 am »
well i did... now it does noothing at all anymore...
jus says !stats  and thats all not``server message:`
anymore :/
Arsse doens't  give any error...
Plz help



this is the network.pas maybe i did something wrong in here :P

function OnRequestGame(IP: string;State: integer):integer;
begin
Result := State;
end;

procedure OnJoinGame(IP, Nickname: string;Team: byte);
begin
end;

procedure OnJoinTeam(IP, Nickname: string;Team: byte);
begin
end;

procedure OnLeaveGame(IP, Nickname: string;Team: byte);
begin;
end;

procedure OnFlagGrab(ID: integer;TeamFlag: byte;GrabbedInBase: boolean);
begin
end;

procedure OnFlagReturn(ID: integer;TeamFlag: byte);
begin
end;

procedure OnFlagScore(ID: integer;TeamFlag: byte);
begin
end;

procedure OnPlayerKill(Killer,Victim,Weapon: string);
begin
end;

procedure OnPlayerRespawn(ID: integer);
begin
end;


const
PLAYER_STATS_ON=1;
PlAYER_STATS_URL='C:Program FilesEasyPHP1-8wwwitrostatsPlayerStats.php';

var
Response: String;
ResponseLines: TStringArray;
i: integer;

procedure OnPlayerSpeak(Name, Text: string);
begin
if((Text='!stats')and(PLAYER_STATS_ON=1)) then begin
Response:= GetURL(PLAYER_STATS_URL+'?name='+Name);
ResponseLines:= split(Response,chr(13));
for i:=0 to ArrayHigh(ResponseLines) do SayToPlayer(NametoID(Name),ResponseLines);
end;
end;


procedure OnMapChange(NewMap: String);
begin
end;


Date Posted: April 12, 2007, 07:55:01 AM

alright! got it to work ...
C:/program..... needed to be http://localhost/zitrostats/playerstats.php
DUH!
;)

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: [beta] InGame ZitroStats
« Reply #13 on: May 03, 2007, 10:52:10 pm »
the whole zitrostats don´t work with 1.4 right?

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: [beta] InGame ZitroStats
« Reply #14 on: May 03, 2007, 11:43:52 pm »
This code should work:

Code: [Select]
const
PLAYER_STATS_ON=1;
PlAYER_STATS_URL='http://bl-tyrone.student.utwente.nl/zitrostats/PlayerStats.php';

var
Response: String;
ResponseLines: TStringArray;
i: integer;

function xsplit(const source: string; const delimiter: string):TStringArray;
var
i,x,d:integer;
s:string;
begin
d:=length(delimiter);
x:=0;
i:=1;
SetArrayLength(Result,1);
while(i<=length(source)) do begin
s:=Copy(source,i,d);   
    if(s=delimiter) then begin
    inc(i,d);
    inc(x,1);
    SetArrayLength(result,x+1);
    end else begin       
    result[x]:= result[x]+Copy(s,1,1);
    inc(i,1);
  end;
end;
end;

procedure OnPlayerSpeak(Name, Text: string);
begin
if((Text='!stats')and(PLAYER_STATS_ON=1)) then begin
Response:= GetURL(PLAYER_STATS_URL+'?name='+HTTPEncode(Name));
ResponseLines:= xsplit(Response,chr(13));
for i:=0 to ArrayHigh(ResponseLines) do SayToPlayer(NametoID(Name),ResponseLines[i]);
end;
end;
« Last Edit: May 04, 2007, 12:41:31 am by mikembm »

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: [beta] InGame ZitroStats
« Reply #15 on: May 04, 2007, 12:32:01 am »
Error:
Code: [Select]
(08:21:37)  [*] [Hint] (65:1): Variable 'S' never used
(08:21:37)  [*] [Error] (147:56): Unknown identifier 'Name'

Offline EnEsCe

  • Retired Soldat Developer
  • Flamebow Warrior
  • ******
  • Posts: 3101
  • http://enesce.com/
    • [eC] Official Website
Re: [beta] InGame ZitroStats
« Reply #16 on: May 04, 2007, 12:37:54 am »
Agh for the millionth time, 1.3.1 scripts do not work with 1.4.1

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: [beta] InGame ZitroStats
« Reply #17 on: May 04, 2007, 12:39:29 am »
Oh yeah. When I tried this code before I had the same error.
His new version of xsplit fixed it.

I modified my above post also.
« Last Edit: May 04, 2007, 12:42:26 am by mikembm »

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: [beta] InGame ZitroStats
« Reply #18 on: May 04, 2007, 12:47:01 am »
Hmm.. error again:
Code: [Select]
07-05-04 07:39:40  [*] [Error] (94:56): Unknown identifier 'Name'
p.s Nvm, my mistake. No errors but no status either  :( Doesn't work.
« Last Edit: May 04, 2007, 01:29:17 am by Leo »

Offline mikembm

  • Soldier
  • **
  • Posts: 210
Re: [beta] InGame ZitroStats
« Reply #19 on: May 04, 2007, 02:20:01 am »
I have seen this work... Make sure safe mode is off on your server (it's on by default)
Also make sure you have uploaded that PHP file and set the correct link to it in the script.

Offline Leo

  • Soldat Beta Team
  • Veteran
  • ******
  • Posts: 1011
Re: [beta] InGame ZitroStats
« Reply #20 on: May 04, 2007, 02:22:04 am »
Safe mod is off and the file is there. When I do !stats, nothing happens. It was working fine with 1.3.1

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: [beta] InGame ZitroStats
« Reply #21 on: May 04, 2007, 07:31:52 am »
yeah  kinda suckage, its only becus of the log named diff then before...
Looking into it now.. I will send it to you when it works  leo!

Offline ManSoft|Warlord

  • Major
  • *
  • Posts: 70
  • Soldat.IDE Creator
Re: [beta] InGame ZitroStats
« Reply #22 on: June 05, 2007, 07:16:50 am »
I believe this will work...:

Code: [Select]
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if((Text='!stats')and(PLAYER_STATS_ON=1)) then begin
Response:= GetURL(PLAYER_STATS_URL+'?name='+IDToName(ID));
ResponseLines:= xsplit(Response,chr(13));
for i:=0 to ArrayHigh(ResponseLines) do SayToPlayer(ID,ResponseLines[i]);
end;


Date Posted: June 05, 2007, 08:11:56 AM
Don't forget to include KeYDoN's xsplit-function :P

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: [beta] InGame ZitroStats
« Reply #23 on: June 05, 2007, 12:55:03 pm »
You should use HTTPEncode like this

Code: [Select]
procedure OnPlayerSpeak(ID: byte; Text: string);
begin
if((Text='!stats')and(PLAYER_STATS_ON=1)) then begin
Response:= GetURL(PLAYER_STATS_URL+'?name='+HTTPEncode(IDToName(ID)));
ResponseLines:= xsplit(Response,chr(13));
for i:=0 to ArrayHigh(ResponseLines) do SayToPlayer(ID,ResponseLines[i]);
end;
urraka

Offline spkka

  • Camper
  • ***
  • Posts: 469
Re: [beta] InGame ZitroStats
« Reply #24 on: June 05, 2007, 01:31:50 pm »
i know it works for a month now,  thnx to make things clear for other people tho ;)

Offline miketh2005

  • Soldat Beta Team
  • Flagrunner
  • ******
  • Posts: 668
  • What's the URL for www.microsoft.com?
Re: [beta] InGame ZitroStats
« Reply #25 on: September 05, 2007, 08:51:30 am »
can someone zip this pls thanx
Quote from: 'Ando.' pid='12999178' dateline='1309046898'
My new password is secure as shit :)
Mate, I am not sure Shit is even secured nowadays.

Offline Corsair

  • Major(1)
  • Posts: 12
Re: [beta] InGame ZitroStats
« Reply #26 on: October 12, 2007, 03:46:26 am »
copied PerroAZUL's script, started the server - got an error...
Anyways, and 'end' is missing. Should me like this:

Code: [Select]
procedure OnPlayerSpeak(ID: integer; Text: string);
begin
if((Text='!stats')and(PLAYER_STATS_ON=1)) then begin
Response:= GetURL(PLAYER_STATS_URL+'?name='+HTTPEncode(IDToName(ID)));
ResponseLines:= xsplit(Response,chr(13));
for i:=0 to ArrayHigh(ResponseLines) do SayToPlayer(ID,ResponseLines[i]);
end;
end;
« Last Edit: October 12, 2007, 09:49:35 am by Corsair »

Offline addict

  • Major(1)
  • Posts: 19
Re: [beta] InGame ZitroStats
« Reply #27 on: October 14, 2007, 04:00:47 am »
is it fully working on linux?

Offline Norbo

  • Camper
  • ***
  • Posts: 338
Re: [beta] InGame ZitroStats
« Reply #28 on: October 30, 2007, 12:36:13 pm »
Quote
Make sure you change the PlAYER_STATS_URL const, and point it to the url of you own ZitroStats dir!

I don't get it...  ??? :-\ :-[