Ini not returning string -
cuzido - 24.02.2016
Hi. I'm working on my faction system and when you create a faction, you're supposed to get a message with the information you entered.
Код:
CMD:createfaction(playerid,params[]){
if(PlayerInfo[playerid][pAdmin] >= 4){
new fid, name[128];
new string[512];
if(sscanf(params, "ds[128]", fid, name)) return SendClientMessage(playerid, -1, "USAGE: /createfaction [Faction-Slot] [Faction-Name]");
if(fid <= 0 || fid >= 16) return SendClientMessage(playerid, -1, "Invalid Faction ID. ( 1-15 )");
if(FactionInfo[fid][fMembers] >= 1) return SendClientMessage(playerid, -1, "Faction slot occupied.");
new Factionfile[32];
format(Factionfile, sizeof(Factionfile), "factions/%d.ini", fid);
new INI:File = INI_Open(Factionfile);
INI_SetTag(File,"data");
INI_WriteString(File,"Faction Name",name);
INI_WriteInt(File,"Faction Type",0);
INI_WriteInt(File,"Total Members",0);
INI_Close(File);
format(string, sizeof(string), "You created %s faction at slot %d.", FactionInfo[fid][fName], fid);
printf("%s has created faction %s at slot %d.", GetName(playerid), FactionInfo[fid][fName], fid);//ChatLog
return SendClientMessage(playerid, 0xffffffff, string);
}
return 1;
}
Everything is writing just fine on the ini file. If I try to create a faction on a faction slot wih atleast 1 member, it says it's already occupied, and the faction name also shows up on the ini file just like it's supposed to.
However, when you use the command, it says: "You created (*should be fNamehere*) faction at slot (slot)." < The faction name doesn't seem to load.
When I use other commands that should return the fName string, it also doesn't show up. Even though the writing works fine and the integers seem to load fine aswell.
Thanks for any help provided.
Re: Ini not returning string -
cuzido - 25.02.2016
Bump! Someone help, please?
Re: Ini not returning string -
-CaRRoT - 25.02.2016
You probably already defined the variable as a string in your enum as it loads up just fine on your ini so its quite weird. Try replacing FactionInfo[fid][fName] with "name" while formatting and see if that works, as that's where you define the faction name anyway.
EDIT: You never set the the variable "name" equal to "FName" in the enum, so you'll have to add
Код:
FactionInfo[fid][fName] = name;
before formatting the message.
Re: Ini not returning string -
cuzido - 25.02.2016
I have to stop coding before going to bed because of this kind of stuff I miss haha.
Thanks for the attention and pointing it out
Re: Ini not returning string -
Jefff - 25.02.2016
FactionInfo[fid][fName] is always empty you need add 'name' into FactionInfo[fid][fName]
pawn Код:
FactionInfo[fid][fName][0] = EOS; // cleaning array
strcat(FactionInfo[fid][fName], name, size_of_fName_here);