User Tools

Site Tools


user:gxc:scripts:food_watch

Introduction

This client-side C++ script monitors your food level and feeds your character when it falls below 250.

Requirements

  • C++

Code

//gxc's Food Monitor Ver 1.0
 
//How to use:
//1. Save and compile
//2. Enter "scripts <path to save>" in Crossfire
 
#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;
}

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

user/gxc/scripts/food_watch.txt · Last modified: 2008/03/20 02:48 (external edit)