Retrieving saved text from an array?
#1

Hey guys, I'm having trouble getting text from data I saved to a file using y_ini. What I did was getting a car's name and then saving it to a file, now I need to use that car's name in a format but everything I try fails. The car's name changes regularly so I need to format it to use It in a list dialog.

Код:
LSDealerInfo[playerid][TempCarID] = TempCarID;
LSDealerInfo[playerid][LSDCarName] = GetVehicleNameByModelId(TempCarID);
Save_LSDInfo(playerid);
Please note saving and loading the data is not the problem, I don't know how to format the array to return the car's name like this...
Код:
format(LSDCarsInfo, sizeof(LSDCarsInfo),"%s\n%s\n%s", LSDealerInfo[playerid][LSDCarName1], LSDealerInfo[playerid][LSDCarName2], LSDealerInfo[playerid][LSDCarName3]);
Can anyone help me on thisone please?
Reply
#2

LSDCarName(1/2/3) is saved like LSDCarName?

I suggest changing the string assignment
pawn Код:
LSDealerInfo[playerid][LSDCarName] = GetVehicleNameByModelId(TempCarID);
//to
strcat(LSDealerInfo[playerid][LSDCarName], GetVehicleNameByModelId(TempCarID));
Reply
#3

Quote:
Originally Posted by Misiur
Посмотреть сообщение
LSDCarName(1/2/3) is saved like LSDCarName?

I suggest changing the string assignment
pawn Код:
LSDealerInfo[playerid][LSDCarName] = GetVehicleNameByModelId(TempCarID);
//to
strcat(LSDealerInfo[playerid][LSDCarName], GetVehicleNameByModelId(TempCarID));
Sorry was a typho. It is saved LSDCar1Name, LSDCar2Name etc etc

So what else do you need to help me?

I need to format that so I can use it in a list dialog.
Reply
#4

Firstly make sure that all your string variables are storing valid strings. If something is wrong with them - you know where to look for further problems.
Reply
#5

When I open the saved ini file all the correct information is the for instance in the ini file LSDCar1Name = Bravura
Reply
#6

pawn Код:
printf("Debug: s1 %s s2 %s s3 %s", LSDealerInfo[playerid][LSDCarName1], LSDealerInfo[playerid][LSDCarName2], LSDealerInfo[playerid][LSDCarName3]);
format(LSDCarsInfo, sizeof(LSDCarsInfo),"%s\n%s\n%s", LSDealerInfo[playerid][LSDCarName1], LSDealerInfo[playerid][LSDCarName2], LSDealerInfo[playerid][LSDCarName3]);
Run this, and look what you get in the console
Reply
#7

Ok I've put that code under a command exactely as you said(accept I changed it to the correct spelling "LSDCarName1 should be LSDCar1Name") but the console returned nothing. What am I doing wrong then?
It just returns s1 s2 s3
Reply
#8

It means that you have no strings in LSDealerInfo[playerid][LSDCar(1|2|3)Name]. Fix it
Reply
#9

Ok so how do I fix it? When I save the files the car names are saved to the file but does not print to the server window, could it be my enum causing the problem? Oh and that strcat(blah blah) does not even save the name to the file, it leaves it blank.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)