12.11.2013, 14:29
Alright i am trying to save some values into a file. It worked nice
untill i tried to save a playername (string) into the file.
This is what i got;
The parts above actually work fine it just that i cant get the string correctly.
Under here is the part that im dealing with, at the comments you can see that i was trying things out.
If i look into the saved file it shows this;
Cash = 5000
Status = 1
Owner =
After trying different things it sometimes showed up like this;
Cash = 5000
Status = 1
Owner = -
I didnt show the actual 'loading' the file part because thats not what i need to know now.
untill i tried to save a playername (string) into the file.
This is what i got;
pawn Код:
enum cInfo
{
Money,
Sold,
Owner[32],
}
new Companies[MAX_COMPANIES][cInfo];
pawn Код:
SaveCompanyInfo(companyid)
{
new bigstring[50];
format(bigstring, sizeof(bigstring),"/Economy/%s.INI",CompanyNames[companyid]);
new INI:File = INI_Open(bigstring);
INI_SetTag(File, "Company accounts");
INI_WriteInt(File,"Cash",Companies[companyid][Money]);
INI_WriteInt(File,"Status",Companies[companyid][Sold]);
INI_WriteString(File,"Owner",Companies[companyid][Owner]);
INI_Close(File);
}
Under here is the part that im dealing with, at the comments you can see that i was trying things out.
pawn Код:
if(!strcmp(cmdtext, "/ownit", true))
{
new name[MAX_PLAYER_NAME+1], string[24+MAX_PLAYER_NAME+1];
GetPlayerName(playerid, name,sizeof(name));
format(string, sizeof(string), "name:%s",name);
// format(string, sizeof(string), "%s", name);
//Companies[0][Owner]= GetPlayerName(playerid, name,sizeof(name));
Companies[0][Owner]= string[32];
SaveCompanyInfo(0);
return 1;
}
Cash = 5000
Status = 1
Owner =
After trying different things it sometimes showed up like this;
Cash = 5000
Status = 1
Owner = -
I didnt show the actual 'loading' the file part because thats not what i need to know now.