strmid don't work
#1

pawn Код:
// enum pInfo
pWarnName1[24],
pWarnReason1[64],

// OnPlayerConnect
strmid(PlayerInfo[playerid][pWarnName1], "Nobody", 0, strlen("Nobody"), 255);
strmid(PlayerInfo[playerid][pWarnReason1], "Empty", 0, strlen("Empty"), 255);

// OnPlayerRegister & OnPlayerDataSave
format(var, 64, "WarnName1=%s\n",PlayerInfo[playerid][pWarnName1]);fwrite(hFile, var);
format(var, 64, "WarnReason1=%s\n",PlayerInfo[playerid][pWarnReason1]);fwrite(hFile, var);

// OnPlayerLogin
if(strcmp(key , "WarnName1" , true) == 0) { val = ini_GetValue(Data); strmid(PlayerInfo[playerid][pWarnName1], val, 0, strlen(val)-1, 255); }
if(strcmp(key , "WarnReason1" , true) == 0) { val = ini_GetValue(Data); strmid(PlayerInfo[playerid][pWarnReason1], val, 0, strlen(val)-1, 255); }
Here is the command: http://pastie.org/748515

Here is the bugged part from command:

pawn Код:
SendFormattedMessage(playerid,COLOR_LIGHTGREEN,"[DEBUG]: Sendername: %s | Reason: %s",sendername,result);
strmid(PlayerInfo[giveplayerid][pWarnName1],sendername,0,strlen(sendername));
strmid(PlayerInfo[giveplayerid][pWarnReason1],result,0,strlen(result));
SendFormattedMessage(playerid,COLOR_LIGHTGREEN,"[DEBUG]: WarnName1: %s | WarnReason1: %s",PlayerInfo[giveplayerid][pWarnName1],PlayerInfo[giveplayerid][pWarnReason1]);
And here is the bug: http://files.uploadffs.com/a/b/c1e8bfe0/untitled.PNG
Reply
#2

So ? You have this problem too ? Or nobody know the answer ?
Reply
#3

You forgot the NULL char

pawn Код:
strmid(PlayerInfo[giveplayerid][pWarnName1],sendername,0,strlen(sendername)+1);
              strmid(PlayerInfo[giveplayerid][pWarnReason1],result,0,strlen(result)+1);
Reply
#4

Oh no ... same problem ..
Reply
#5

isn't it "strlen(sendername)-1" ?
Reply
#6

Nop , tested and same thing
Reply
#7

Just use format xD
Код:
format(PlayerInfo[giveplayerid][pWarnName1],24,"%s",sendername);
format(PlayerInfo[giveplayerid][pWarnReason1],64,"%s",result);
Reply
#8

edited
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)