Crossfire Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hacking server code. I need help!



Just a simple C file that empty a character.
When a character die just run this program with the filename of the character.

I think it would be very easy to integrate it directly in the game.
you can also add the loss of experience in it.

JC.

#include <stdio.h>
#include <string.h>

char buf[255]="";

char shoottype[]="shoottype";
char fin[]="end\n";
char known_spell[]="known_spell";
char map[]="map";
char coordx[]="x";
char coordy[]="y";
char gen_hp[]="gen_hp";
char gen_sp[]="gen_sp";
char attac[]="attacktype";
char file_temp[]="tmp.fic";

FILE *fichier_pl;
FILE *fichier_temp;


resur(nom_fichier)

char *nom_fichier;
{
	char *retour="";
	
	fichier_pl=fopen(nom_fichier, "rb");
	fichier_temp=fopen(file_temp, "wb");
	fgets(buf, 255, fichier_pl);
	while (strncmp(buf, shoottype, strlen(shoottype)))
	{
		 if (!strncmp(buf, gen_hp, strlen(gen_hp)))
			fprintf(fichier_temp, "gen_hp 0\n");
		else if (!strncmp(buf, gen_sp, strlen(gen_sp)))
			fprintf(fichier_temp, "gen_sp 0\n");
		else {
		fprintf(fichier_temp, "%s", buf);
		}
		fgets(buf, 255, fichier_pl);
	}
	fprintf(fichier_temp, "shoottype 0\n");
	fgets(buf, 255, fichier_pl);
	while (strncmp(buf, fin, strlen(fin)))
	{
		if (strncmp(buf, known_spell, strlen(known_spell)))	
		{
			if (!strncmp(buf, map, strlen(map)))
				fprintf(fichier_temp, "map 4\n");
			else if (!strncmp(buf, coordx, strlen(coordx)))
				fprintf(fichier_temp, "x 20\n");
			else if (!strncmp(buf, coordy, strlen(coordy)))
				fprintf(fichier_temp, "y 20\n");
			else if (!strncmp(buf, attac, strlen(attac)))
				fprintf(fichier_temp, "attacktype 1\n");
			else
				fprintf(fichier_temp, "%s", buf);
		}
		fgets(buf, 255, fichier_pl);
	}
	fprintf(fichier_temp, "%s", buf);
	fclose(fichier_pl);
	fclose(fichier_temp);
	
	fichier_pl=fopen(nom_fichier, "wb");
	fichier_temp=fopen(file_temp, "rb");
	fgets(buf, 255, fichier_temp);
	while (retour!=NULL)
	{
		fprintf(fichier_pl, "%s", buf);
		retour=fgets(buf, 255, fichier_temp);
	}
	fclose(fichier_pl);
	fclose(fichier_temp);
}

main(int argc, char *argv[])
{
	resur(argv[1]);
}