[GSP] Showing a GSP Usercount in and out of Game

smoochy boys on tour

Azura

Mir3 Coder & Adviser
Legendary
Mar 12, 2005
3,249
111
300
This will make it so you can have a usercount for your server and I have adjusted the script to also show ingame every 10 minutes

You will need a webserver and a php document

This is the code I have within my sig
PHP:
$fp = fsockopen("127.0.0.1", 3000, $errno, $errstr);
if (!$fp) {   echo "ERROR: $errno - $errstr<br />\n";} else {   fwrite($fp, "\n");   
$srvStr = fread($fp, 50);  
 $srvStr = explode("/", $srvStr);   
$srvStr = $srvStr[5];   
fclose($fp);   
if ($srvStr === false) {    $users = "No Users Online";  } else {    $srvStr3 = $srvStr . " Players Online";    
$srvStr2 = "[Count]\r\nUsersOnline=" . $srvStr;  
@file_put_contents('C:\Mud3\Envir\Event\UserCountNumber.txt', $srvStr2); // store the new hit count  }

$srvStr = $srvStr[5]; - This can sometimes be different for you.
Change 5 from 1-5 until you get the count

This saves the number on each refresh to the location at the bottom


Inside 00Default add this...

[@main]
#ACT
goto @UserCountEvent

[@UserCountEvent]
#CALL [..\Event\UserCount.txt] @UserCountStart

Create ..\Event\UserCount.txt and add this inside...

[@UserCountStart]
{
#ACT
DELAYGOTO [LOCAL] 300 @UserCountStart1
break


[@UserCountStart1]
#ACT
Loadvalue A1 "Event\UserCountNumber.txt" [Count] [UsersOnline]
lineMsg "Grobal" "Players Currently Online: <$OUTPUT(A1)>"
DELAYGOTO [LOCAL] 300 @UserCountStart ;10 Minute Timer
break


}

Hope this helps, remember the count will only update on refresh's so its not 100% realtime.
 

ventus

LOMCN Veteran
Veteran
Oct 17, 2013
925
132
105
Nice tutorial. Nice to know little more about how these files work.
 

Karl

LOMCN VIP
VIP
Mar 8, 2004
897
33
275
Gloucester
Started to play around with this, but getting continually spammed, however im not sure where the QuestDiary has come from. Where exactly are we to place these files? I'm assuming it's Envir\Event (The same as the other event files called from 00default) I know it's reading the usercount.txt file because if i move it/remove it I just get spammed with Script error, load fail: rather than the loadtext procedure call.

2016-07-26 01:13:05 - Script error, load fail: ..\Event\UserCount.txt - @UserCountStart
2016-07-26 01:13:05 - unterminated #call(#loadtext) procedure in .\Envir\QuestDiary\..\Event\UserCount.txt
2016-07-26 01:13:05 - Script error, load fail: ..\Event\UserCount.txt - @UserCountStart
2016-07-26 01:13:05 - unterminated #call(#loadtext) procedure in .\Envir\QuestDiary\..\Event\UserCount.txt
2016-07-26 01:13:05 - Script error, load fail: ..\Event\UserCount.txt - @UserCountStart
2016-07-26 01:13:05 - unterminated #call(#loadtext) procedure in .\Envir\QuestDiary\..\Event\UserCount.txt
2016-07-26 01:13:05 - Script error, load fail: ..\Event\UserCount.txt - @UserCountStart
2016-07-26 01:13:05 - Script error at #ACT: "b" line:888 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:1254 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2008 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2018 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2028 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2038 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2048 : .\Envir\Market_Def\00Default
 

Josiko

LOMCN Veteran
Veteran
Loyal Member
Apr 4, 2010
428
8
44
Spain
It's work in 3.55 azura? , And you can say in the post if its need an open port

127.0.0.1", 3000,

or the local ip + 3000 its fix for all ?
thanks you for help the comunity !! +rep




@Karl

[@main]
#ACT
goto @UserCountEvent

[@UserCountEvent]
#CALL [QuestDiary\Event\UserCount.txt] @UserCountStartv


You need put ur folder adress, questdiary\ or Questdiary\System... you can choose the direcc
 

Azura

Mir3 Coder & Adviser
Legendary
Mar 12, 2005
3,249
111
300
It's work in 3.55 azura? , And you can say in the post if its need an open port



or the local ip + 3000 its fix for all ?
thanks you for help the comunity !! +rep




@Karl

[@main]
#ACT
goto @UserCountEvent

[@UserCountEvent]
#CALL [QuestDiary\Event\UserCount.txt] @UserCountStartv


You need put ur folder adress, questdiary\ or Questdiary\System... you can choose the direcc

Its reading the port locally so it should read the port, you can block external connections.

Started to play around with this, but getting continually spammed, however im not sure where the QuestDiary has come from. Where exactly are we to place these files? I'm assuming it's Envir\Event (The same as the other event files called from 00default) I know it's reading the usercount.txt file because if i move it/remove it I just get spammed with Script error, load fail: rather than the loadtext procedure call.
2016-07-26 01:13:05 - Script error, load fail: ..\Event\UserCount.txt - @UserCountStart
2016-07-26 01:13:05 - unterminated #call(#loadtext) procedure in .\Envir\QuestDiary\..\Event\UserCount.txt
2016-07-26 01:13:05 - Script error, load fail: ..\Event\UserCount.txt - @UserCountStart
2016-07-26 01:13:05 - unterminated #call(#loadtext) procedure in .\Envir\QuestDiary\..\Event\UserCount.txt
2016-07-26 01:13:05 - Script error, load fail: ..\Event\UserCount.txt - @UserCountStart
2016-07-26 01:13:05 - unterminated #call(#loadtext) procedure in .\Envir\QuestDiary\..\Event\UserCount.txt
2016-07-26 01:13:05 - Script error, load fail: ..\Event\UserCount.txt - @UserCountStart
2016-07-26 01:13:05 - Script error at #ACT: "b" line:888 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:1254 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2008 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2018 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2028 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2038 : .\Envir\Market_Def\00Default
2016-07-26 01:13:05 - Script error at #ACT: "b" line:2048 : .\Envir\Market_Def\00Default


The default location is Envir\
QuestDiary\System when using the #CALL function

This is why '..\' is there to tell the system to start the #CALL location from two folders back.

[@UserCountEvent]
#CALL [..\Event\UserCount.txt] @UserCountStart

Should work fine, what are you using to write the .txt, notepad or notepad++

It would seem that its only reading 'b' from your break line.

Are you able to post whats in both documents?

 
Last edited:

Karl

LOMCN VIP
VIP
Mar 8, 2004
897
33
275
Gloucester
In D:\mud3\Envir\Market_Def\00default:

Code:
[@main]
#ACT
goto @UserCountEvent    ;
goto @TimerEvent        ;时间
goto @IceBridgeEvent
goto @ItemEvent            ;物品事件(物品点击)
goto @BossEvent            ;Boss地图打点
goto @WeatherEvent        ;天气控制
goto @CastleDefaultSetting    ;沙巴克和沙漠土城 默认设置


;////////////////////////////////////////////////////////////////////////系统未知函数


;这个也有可能是个文件什么的,和00Default一样
[@__System_]
#ACT
Break


;服务器启动事件????
[@_startup]
#ACT
Break






;////////////////////////////////////////////////////////////////////////自定义事件
[@TimerEvent]
#CALL [..\Event\TimerUpdate.txt] @StartTimer


[@ItemEvent]
#CALL [..\Event\ItemClick.txt] @ItemList


[@BossEvent]
#CALL [..\Event\BossPoint.txt] @PointList


[@WeatherEvent]
#CALL [..\Event\Weather.txt] @WeatherList


[@IceBridgeEvent]
#CALL [..\Event\IceBridge.txt] @IceBridgeStart


[@UserCountEvent]
#CALL [..\Event\UserCount.txt] @UserCountStart

In D:\mud3\Envir\Event\UserCount.txt :

Code:
[@UserCountStart]
{
#ACT
DELAYGOTO [LOCAL] 300 @UserCountStart1
break




[@UserCountStart1]
#ACT
Loadvalue A1 "Event\UserCountNumber.txt" [Count] [UsersOnline]
lineMsg "Grobal" "Players Currently Online: <$OUTPUT(A1)>"
DELAYGOTO [LOCAL] 300 @UserCountStart
break




}

Created/Edited with notepad ++ (Although I also attempted to re-save with standard notepad, same error) i'm probably looking straight at the error but can't see it!