Vice City Multiplayer

VC:MP => mIRC/pawn Scripting => Topic started by: Jancis_LV on January 30, 2010, 07:01:23 PM

Title: Can someone help?
Post by: Jancis_LV on January 30, 2010, 07:01:23 PM
Is there any script (pawn) that checks info of file, for example if that and that is written in file then that and that happens
Sorry for my bad english.

Easier way if you cant understand this: i need a code that checks text in file
Title: Re: Reading from file
Post by: Boss on January 30, 2010, 07:28:55 PM

GetFileText(path[]){
   new File:file, text[256]; // Increase if file is big.
   file = fopen(path);
   fread(file,text,sizeof(text));
   fclose(file);
   return text;
}

Path is a path to the file you're reading, which must be placed in "scriptfiles" folder of your server dir or one of its subfolders.

GetFileText("test.txt") will return contents of "SERVER_DIR/scriptfiles/test.txt".
GetFileText("players/noob.inf") will return contents of "SERVER_DIR/scriptfiles/players/noob.inf".
etc

P.S. Don't name threads like "help me" or "why did I fail". Mentioning your problem in thread's name helps other people to find solution if they have the same problem instead of making then create duplicate threads.
Title: Re: Can someone help?
Post by: Jancis_LV on January 31, 2010, 10:56:29 AM
Thanks for that, but i wanted something like this, but is that possible?

if(GetFileText("test.txt") == "11")){ SendClientMessage(playerid, COLOR_ORANGE, "text");
Title: Re: Can someone help?
Post by: Boss on January 31, 2010, 11:15:14 AM
Quote from: Jancis_LV on January 31, 2010, 10:56:29 AM
Thanks for that, but i wanted something like this, but is that possible?

if(GetFileText("test.txt") == "11")){ SendClientMessage(playerid, COLOR_ORANGE, "text");

String comparison in pawn is done like the following:

if (strcmp(GetFileText("test.txt"), "11", true) == 0) SendClientMessage(playerid, COLOR_ORANGE, "text");
Title: Re: Can someone help?
Post by: Jancis_LV on January 31, 2010, 02:17:19 PM
How to make pickup, what respawns in 0 seconds?