• Welcome to Vice City Multiplayer.
 

Can someone help?

Started by Jancis_LV, January 30, 2010, 06:01:23 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Jancis_LV

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
Latvian Vice City server
78.84.47.75:5192

Boss

#1

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.

Jancis_LV

Thanks for that, but i wanted something like this, but is that possible?

if(GetFileText("test.txt") == "11")){ SendClientMessage(playerid, COLOR_ORANGE, "text");
Latvian Vice City server
78.84.47.75:5192

Boss

Quote from: Jancis_LV on January 31, 2010, 09: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");

Jancis_LV

How to make pickup, what respawns in 0 seconds?
Latvian Vice City server
78.84.47.75:5192