Jump to content

Looking for advice on a stats module


BobbyRC

Recommended Posts

I'm trying to code a module for a pre-existing bot that runs on deviantart.com's chat network. I'm getting errors, and I don't really know if I'm going about this the right way, so I figured I'd post the code and see if anyone is willing to lend some advice.

The code uses a text file I'm trying to store stats in for each user of the room.

 

function c_editstat($ns, $from, $message, $target) {

$fname = "userstats.txt";
$user = args($message, 1);
$newstat = args($message, 2);

$fhandle = fopen($fname,"r");
$content = fread($fhandle,filesize($fname));

$oldstat = strstr($content, $user."=")
$newstat = $user."=".$newstat
$content = str_replace($user.$oldstat, $newstat, $content);

$fhandle = fopen($fname,"w");
fwrite($fhandle,$content);
fclose($fhandle);
}

 

The contents of the file will simply be:

 

example=1

 

I'm getting parsing errors at the moment, and tried to sort it out through type casting, but to no avail.. -_-

Link to comment
https://forums.phpfreaks.com/topic/148187-looking-for-advice-on-a-stats-module/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.