Name change wrong (INI 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)
+--- Thread: Name change wrong (INI problem!) (
/showthread.php?tid=379055)
Name change wrong (INI problem!) -
Devix - 20.09.2012
Hey guys!
I want to change a name IG so I created a system where a dialog pops up and you can change a name after you entered the rank number (which is stored in the PVaR). that works but saving and loading the name goes wrong!
Here's the code:
At Dialog:
Код:
new i = PlayerInfo[playerid][pFaction];
if(GetPVarInt(playerid, "FrankEdit") == 1)
{
strcat(FactionInfo[i][fRank1], inputtext);
}
SaveFactions(i);
The savefactions function:
Код:
stock SaveFactions(id)
{
new dFile[128];
format(dFile, sizeof(dFile),"Factions/%i.ini",id);
new
INI:File = INI_Open(dFile);
INI_WriteString(File, "Name", FactionInfo[id][fName]);
INI_WriteString(File, "fRank1", FactionInfo[id][fRank1]);
INI_WriteString(File, "fRank2", FactionInfo[id][fRank2]);
INI_WriteString(File, "fLeader", FactionInfo[id][fLeader]);
INI_Close(File);
return 1;
}
And last but not least the loading function:
Код:
forward LoadFactions(id, name[], value[]);
public LoadFactions(id, name[], value[])
{
INI_String("Name",FactionInfo[id][fName],529);
INI_String("fLeader",FactionInfo[id][fLeader],256);
INI_String("fRank1",FactionInfo[id][fRank1],256);
INI_String("fRank2",FactionInfo[id][fRank2],256);
return 1;
}
Another weird thing. When SaveFactions is called, the fleader goes to default instead of saving the name of the player..
Anyone who can help me? This is a big problem :P.
Re: Name change wrong (INI problem!) -
newbienoob - 20.09.2012
Try this
pawn Код:
//Change this
INI_WriteString(File, "Name", FactionInfo[id][fName]);
//to this
new name[24];
GetPlayerName(id,name,24);
INI_WriteString(File, "Name", name);
Re: Name change wrong (INI problem!) -
Devix - 20.09.2012
fname = just the faction name, not the leader :P
fleader = the leader name which gets erased.
Re: Name change wrong (INI problem!) -
Devix - 21.09.2012
Anyone?