String placed two times?
#1

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;
}


Reply
#2

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.
Reply
#3

Gonna bump this
Reply
#4

How are you setting those strings?
Reply
#5

You are not clear enough.Give a detail please.
Reply
#6

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);
}
Reply
#7

Bump
Reply
#8

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);
Reply
#9

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.
Reply
#10

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);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)