Author Topic: Can someone help?  (Read 2919 times)

0 Members and 1 Guest are viewing this topic.

Offline Jancis_LV

  • Street Thug
  • *
  • Posts: 37
    • View Profile
    • Latvian Vice City
Can someone help?
« on: January 30, 2010, 09: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
« Last Edit: January 30, 2010, 09:06:39 pm by Jancis_LV »
Latvian Vice City server
78.84.47.75:5192

Offline Boss

  • VC:MP Beta Tester (inactive)
  • Made Man
  • *
  • Posts: 229
  • Boss
    • View Profile
    • TDH Clan Site
Re: Reading from file
« Reply #1 on: January 30, 2010, 09:28:55 pm »
Code: [Select]
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.
« Last Edit: January 30, 2010, 09:41:21 pm by Boss »

Offline Jancis_LV

  • Street Thug
  • *
  • Posts: 37
    • View Profile
    • Latvian Vice City
Re: Can someone help?
« Reply #2 on: January 31, 2010, 12:56:29 pm »
Thanks for that, but i wanted something like this, but is that possible?

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

Offline Boss

  • VC:MP Beta Tester (inactive)
  • Made Man
  • *
  • Posts: 229
  • Boss
    • View Profile
    • TDH Clan Site
Re: Can someone help?
« Reply #3 on: January 31, 2010, 01:15:14 pm »
Thanks for that, but i wanted something like this, but is that possible?

Code: [Select]
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");

Offline Jancis_LV

  • Street Thug
  • *
  • Posts: 37
    • View Profile
    • Latvian Vice City
Re: Can someone help?
« Reply #4 on: January 31, 2010, 04:17:19 pm »
How to make pickup, what respawns in 0 seconds?
Latvian Vice City server
78.84.47.75:5192