SA-MP Forums Archive
Dini read file problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dini read file problem (/showthread.php?tid=193793)



Dini read file problem - Biesmen - 27.11.2010

Well, since I'm working on a system, I want the system to read the ID of the file.
The file has a number.txt. Inside the txt there's an ID. Exactly the same as the .txt file.

So, I made this command to check what ID you're at:

pawn Код:
if(strcmp(cmd, "/checkbiz", true) == 0)
    {
    new file[31];
    if(PlayerInfo[playerid][pAdmin] >= 99997) {
    for(new i; i < sizeof(BusinessData); i++)
    {
   if(IsPlayerInRangeOfPoint(playerid, 2, x,y,z))
    {
    format(file, sizeof(file), "BusinessData/%i.txt", BusinessData[i][BusinessID]);
    format(string, sizeof(string), "You are at business ID: %i", dini_Int(file, "ID"));
    SendClientMessage(playerid, NEWBIE_COLOR, string);
    return 1;
    } else {
    SendClientMessage(playerid, COLOR_GRAD1, " You are not at a business.");
    return 1;
                }
            }
        }
    }
(IsPlayerInRangeOfPoint has been made shorter, so it'll be easier to read).
Nothing's wrong with this command.
It works fine if the file is called 1.txt or the ID is 1..

This is the stock to load the content:
I just added the necessary part:
pawn Код:
BusinessData[j][BusinessID] = dini_Int(bfile, "ID");
No errors.
This is a business system as you may have noticed.

I made it spawn an icon.
The icon is called
BusinessData[i][BusinessID] = CreatePickup(blabla);

So, it works; /enter, /exit, it reads everything the file has (entry fee, stock, everything I want it to read) except the ID.

If you stand on the icon, it will give information who the owner is, entry fee, stock, how much the business cost.
It loads that information, except the ID.

I don't really get it and it's hard to explain.

I hope you can help me with the information I gave you.
I do not wish to post the entire code to prevent copy&paste from people.

Thank you.


Re: Dini read file problem - Biesmen - 27.11.2010

I tried adding a new one.
pawn Код:
BusinessData[busj][BusInfo] = dini_Int(bfile, "BusInfo");
But that also doesn't load the ID.

I also tried to add strval where it recieves the business ID:
pawn Код:
strval(BusinessData[i][BusinessID]);
That also failed.

I'm seriously out of ideas. This is really weird.

It loads everything it has to load; The interior ID, the coordinates, the name, the owner, everything except BusinessID.

I think it has to do with, the BusinessID is the same number as the file. But I had to do this so you can modify the file by standing on it, without entering the file number.


Re: Dini read file problem - ••• ĤБĶБM ••• - 27.11.2010

I'm having the same problem, can someone help me?


Re: Dini read file problem - Biesmen - 27.11.2010

Seems like no one knows the problem.
I'm still looking for help by the way.


Re: Dini read file problem - XoSarahMoX - 27.11.2010

Maybe make it get the actual file name? Not the ID inside that file? Like say the file name is:
Ammunation and inside it says ID: Ammunation just get the file name. But I am not sure how to script that hopefully you know what I mean and goodluck!


Re: Dini read file problem - Biesmen - 27.11.2010

No, I don't get waht you mean, but thanks.

When you stand on the checkpoint(a pickup), it will check which file it is by using a loop. The file name is the same as the business ID. So I could modify the file.
pawn Код:
format(file, sizeof(file), "BusinessData/%i.txt", BusinessData[i][BusinessID]);



Re: Dini read file problem - Biesmen - 28.11.2010

I edited the /checkbiz command into this:
Код:
	if(strcmp(cmd, "/checkbiz", true) == 0)
	{
	new file[31];
	if(PlayerInfo[playerid][pAdmin] >= 99997) {
	for(new busi; busi < sizeof(BusinessData); busi++)
	{
   	if(IsPlayerInRangeOfPoint(playerid, 2, x,y,z))
	{
	format(file, sizeof(file), "BusinessData/%i.txt", BusinessData[busi][BusID]);
	format(string, sizeof(string), "You are at business ID: %i", file;
	SendClientMessage(playerid, NEWBIE_COLOR, string);
	return 1;
	} else {
	SendClientMessage(playerid, COLOR_GRAD1, " You are not at a business.");
	return 1;
				}
			}
		}
	}
I checked if it worked now for 2.txt, but no. It still said "You are not at a business".
But for 1.txt, it didn't tell me the file name.
It should give me this message: "You are at business ID: BUsinessData/1t.txt".
But it gave me this message: "You are at business ID: 66".
I do not understand why he says "66". There's nothing that should name it 66. I'm quite clueless, but I think this is the problem. It doesn't read the files properly.

I hope you could help me now.


Re: Dini read file problem - ••• ĤБĶБM ••• - 28.11.2010

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
I edited the /checkbiz command into this:
Код:
	if(strcmp(cmd, "/checkbiz", true) == 0)
	{
	new file[31];
	if(PlayerInfo[playerid][pAdmin] >= 99997) {
	for(new busi; busi < sizeof(BusinessData); busi++)
	{
   	if(IsPlayerInRangeOfPoint(playerid, 2, x,y,z))
	{
	format(file, sizeof(file), "BusinessData/%i.txt", BusinessData[busi][BusID]);
	format(string, sizeof(string), "You are at business ID: %i", file;
	SendClientMessage(playerid, NEWBIE_COLOR, string);
	return 1;
	} else {
	SendClientMessage(playerid, COLOR_GRAD1, " You are not at a business.");
	return 1;
				}
			}
		}
	}
I checked if it worked now for 2.txt, but no. It still said "You are not at a business".
But for 1.txt, it didn't tell me the file name.
It should give me this message: "You are at business ID: BUsinessData/1t.txt".
But it gave me this message: "You are at business ID: 66".
I do not understand why he says "66". There's nothing that should name it 66. I'm quite clueless, but I think this is the problem. It doesn't read the files properly.

I hope you could help me now.
Strange - I have the same problem and I solved it. Not sure how, but somehow, I managed to fix it.


Re: Dini read file problem - Biesmen - 28.11.2010

Well, I hope anyone could help me to solve this. I still have this bug, there's no reason to stop reading that line in the txt files.