Help with fwrite
#1

I probably sound kinda dumb using fwrite and I'll probably convert to mySQL or some other thing later on. However, how can I add more lines to the file? I've done it before but this time it won't let me.

Here is the code:
Код:
			if (strcmp(ParameterName, "TruckerRank", false) == 0)
				APlayerData[playerid][TruckerRank], 50, strval(ParameterValue);
			if (strcmp(ParameterName, "PoliceRank", false) == 0)
				APlayerData[playerid][PoliceRank], 50, strval(ParameterValue);
Код:
	format(LineForFile, sizeof(LineForFile), "TruckerRank %s\r\n", APlayerData[playerid][TruckerRank]);"
	fwrite(PFile, LineForFile); // And save it to the file
	format(LineForFile, sizeof(LineForFile), "PoliceRank %s\r\n", APlayerData[playerid][PoliceRank]);"
	fwrite(PFile, LineForFile); // And save it to the file
This is what it outputs when compiled:
undefined symbol "TruckerRank"
undefined symbol "PoliceRank"
undefined symbol "TruckerRank"
undefined symbol "PoliceRank"

What have I missed/done wrong? Thanks in advance.
Reply
#2

Show us how you define TruckerRank and PoliceRank
Reply
#3

I just fixed that, thanks. Now I have two more errors but I'm pretty sure I'm just missing something here.

Код:
			if (strcmp(ParameterName, "TruckerRank", false) == 0)
				APlayerData[playerid][TruckerRank], strval(ParameterValue); // line 101
			if (strcmp(ParameterName, "PoliceRank", false) == 0)
				APlayerData[playerid][PoliceRank], strval(ParameterValue); // line 103
compiles as:

warning 215: expression has no effect (line 101)
warning 215: expression has no effect (line 103)
Reply
#4

"

Код:
format(LineForFile, sizeof(LineForFile), "TruckerRank %s\r\n", APlayerData[playerid][TruckerRank]);"
	fwrite(PFile, LineForFile); // And save it to the file
	format(LineForFile, sizeof(LineForFile), "PoliceRank %s\r\n", APlayerData[playerid][PoliceRank]);"
	fwrite(PFile, LineForFile); // And save it to the file
Reply
#5

Quote:
Originally Posted by DarkBr
Посмотреть сообщение
"

Код:
format(LineForFile, sizeof(LineForFile), "TruckerRank %s\r\n", APlayerData[playerid][TruckerRank]);"
	fwrite(PFile, LineForFile); // And save it to the file
	format(LineForFile, sizeof(LineForFile), "PoliceRank %s\r\n", APlayerData[playerid][PoliceRank]);"
	fwrite(PFile, LineForFile); // And save it to the file
Nope, wasn't it. It created a lot of errors and none of my other fwrites have "'s where you put them.
Reply
#6

Код:
APlayerData[playerid][TruckerRank], strval(ParameterValue); // line 101
APlayerData[playerid][PoliceRank], strval(ParameterValue); // line 103
What does this code do? What are you trying to call? You can't just call a variable directly, you have to do something with it.
Reply
#7

Quote:
Originally Posted by ComDuck
Посмотреть сообщение
Код:
APlayerData[playerid][TruckerRank], strval(ParameterValue); // line 101
APlayerData[playerid][PoliceRank], strval(ParameterValue); // line 103
What does this code do? What are you trying to call? You can't just call a variable directly, you have to do something with it.
Checks if it exists and then saves it to APlayerData
Reply
#8

Equal sign is used for variable assignment.
pawn Код:
APlayerData[playerid][TruckerRank] = strval(ParameterValue);
APlayerData[playerid][PoliceRank] = strval(ParameterValue);
Reply
#9

Quote:
Originally Posted by Calisthenics
Посмотреть сообщение
Equal sign is used for variable assignment.
pawn Код:
APlayerData[playerid][TruckerRank] = strval(ParameterValue);
APlayerData[playerid][PoliceRank] = strval(ParameterValue);
Thanks! +repped both of you for your contributions and Calis, for your final answer.
Edit: Can't rep again, will do when I can
Reply
#10

Another thing:

TruckerRank
PoliceRank

are both empty in the player's .txt file.

Код:
new Rank[24];

Rank = "Newbie";
APlayerData[playerid][TruckerRank] = Rank;
That is the only piece of code I added ^^ (added it to the part where the player joins the class and gets a rank based on the amount of trucking missions he has done, etc)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)