String placed two times? -
ConnorHunter - 22.04.2014
Alright so I'm making a description feature for my roleplay server, and when I enter a new description on one feature, it appears on the second one too..
pawn Код:
CMD:describe(playerid, params[])
{
new string[128];
format(string, sizeof(string), "{F9FFB8}Characters Head\n\
{BDBDBD}%s (Click to edit)\n\
{F9FFB8}Characters Arms\n\
{BDBDBD}%s (Click to edit)",
PlayerInfo[playerid][pHeadDesc], PlayerInfo[playerid][pArmDesc]);
ShowPlayerDialog(playerid, DIALOG_DESCRIPTION, DIALOG_STYLE_LIST, "IRG:RP - Character Descriptions", string, "Edit", "Exit");
return 1;
}
Re: String placed two times? -
JhnzRep - 06.05.2014
When you save the heads description, it must be saving both into PlayerInfo[playerid][pHeadDesc] and PlayerInfo[playerid][pArmDesc]. PM if you want me to check your code or something.
Re: String placed two times? -
ConnorHunter - 22.05.2014
Gonna bump this
Re: String placed two times? -
arakuta - 22.05.2014
How are you setting those strings?
Re: String placed two times? -
Rittik - 22.05.2014
You are not clear enough.Give a detail please.
Re: String placed two times? -
ConnorHunter - 22.05.2014
pawn Код:
forward ChangeHeadDesc(playerid, newdesc[]);
public ChangeHeadDesc(playerid, newdesc[])
{
format(PlayerInfo[playerid][pHeadDesc],128,"%s", newdesc);
}
forward ChangeArmDesc(playerid, newdesc[]);
public ChangeArmDesc(playerid, newdesc[])
{
format(PlayerInfo[playerid][pArmDesc],128,"%s", newdesc);
}
Re: String placed two times? -
ConnorHunter - 23.05.2014
Bump
Re: String placed two times? - Patrick - 23.05.2014
Well that's not the best way to copy a string into another string, its also a bad practice to you, I am not really sure what was your problem, explain it more ??
pawn Код:
stock ChangeHeadDesc(playerid, newdesc[])
return strcat(PlayerInfo[playerid][pHeadDesc], newdesc, 128 + 1);
stock ChangeArmDesc(playerid, newdesc[])
return strcat(PlayerInfo[playerid][pArmDesc], newdesc, 128 + 1);
Re: String placed two times? -
ConnorHunter - 23.05.2014
Quote:
Originally Posted by Patrick_
Well that's not the best way to copy a string into another string, its also a bad practice to you, I am not really sure what was your problem, explain it more ??
pawn Код:
stock ChangeHeadDesc(playerid, newdesc[]) return strcat(PlayerInfo[playerid][pHeadDesc], newdesc, 128 + 1);
stock ChangeArmDesc(playerid, newdesc[]) return strcat(PlayerInfo[playerid][pArmDesc], newdesc, 128 + 1);
|
Well that sort of works, except now it's pasting it and not removing the old one.
Re: String placed two times? - Patrick - 23.05.2014
Quote:
Originally Posted by ConnorHunter
Well that sort of works, except now it's pasting it and not removing the old one.
|
Here we use
'\0' or
EOS to clear the first cell in pHeadDesc and pArmDesc and replace it with the old string with the new string you have inserted.
pawn Код:
stock ChangeHeadDesc(playerid, const newdesc[])
return strcat((PlayerInfo[playerid][pHeadDesc][0] = '\0', PlayerInfo[playerid][pHeadDesc]), newdesc, 128 + 1);
stock ChangeArmDesc(playerid, const newdesc[])
return strcat((PlayerInfo[playerid][pArmDesc][0] = '\0', PlayerInfo[playerid][pArmDesc]), newdesc, 128 + 1);