[Crossfire-wiki] [Crossfire DokuWiki] page added: user:gxc:scripts:food_watch

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Thu Mar 20 02:41:02 CDT 2008


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2008/03/20 02:41
User        : gxc
Edit Summary: created

====== Introduction ======
This client-side [[wp>C++]] script monitors your food level and feeds your character when it falls below 250.

====== Requirements ======
  * C++

====== Code ======
<code c++>
//gxc's Food Monitor Ver 1.0
#include <cstdio>
#include <cstdlib>
#include <cstring>

int main (){
	//variable declaration
	char buf[200], checkFood[]="food";
	int foodLVL;
	
	//tell client to watch all stats
	printf ("watch stats\n");
	
	//flush stdout, necessary after all output
	fflush (stdout);
	
	//begin an infinite loop
	while(true){
	
		//loops until buf = "food", which means
		//the next string is the amount food left
		while(strcmp(buf,checkFood)!=0){
			scanf("%s",buf);
		}
		
		//get the amount of food
		scanf("%s",buf);
		
		//convert to an integer
		foodLVL = atoi(buf);
		
		//if it's less than the danger amount,
		//apply food of your choice
		if(foodLVL<250){
			//Change "food" in this line to the
			//food of your choice
			printf("issue 1 1 apply food\n");
			fflush (stdout); //flush as always
		}
	}
	return 0;
}
</code>

====== Notes & Comments ======
Ver 1.0\\
Basic food watching script, nothing too cool. I've run it extensively with no problems.

Coming:\\
-Database of food, maybe, that consumes food in some order

====== References =======
  * [[:Client Side Scripting]]


IP-Address  : 76.210.35.252
Old Revision: none
New Revision: http://wiki.metalforge.net/doku.php/user:gxc:scripts:food_watch

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list