SA-MP Forums Archive
String spilting error. - 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: String spilting error. (/showthread.php?tid=394387)



String spilting error. - Benzke - 22.11.2012

Here's the command, Whenever I go IG and try it, it first gives out "(( (ID)MyName: ... ))" and then on the next line "(( (ID)MyName: .... )) )) " Yes, the second time, there are two )).

pawn Код:
CMD:b(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid, COLOR_SYNTAX,"[SYNTAX]: /b [TEXT HERE]");
    new sendername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid,sendername,sizeof(sendername));
    sendername[strfind(sendername,"_")] = ' ';
    if(strlen(params) > 24)
    {
        new part1[24];
        new part2[44];
        strmid(part1,string,0,23,24);
        format(string, sizeof(string), "(( (ID:%d) %s: %s... ))", playerid, GetName(playerid), part1);
        ProxDetector(20.0, playerid, string,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
        strmid(part2,string,24,128,44);
        format(string, sizeof(string), "(( (ID:%d) %s: ...%s ))", playerid, GetName(playerid), part2);
        ProxDetector(20.0, playerid, string,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
    }
    else
    {
        format(string, sizeof(string), "(( (ID:%d) %s: %s ))", playerid, GetName(playerid), params);
        ProxDetector(20.0, playerid, string,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
    }
    return 1;
}



Re: String spilting error. - Benzke - 23.11.2012

Here I'll give an example of what I was trying to do -
P1 - " Hello, So lets test the max string length blablablablablablablablabla[NOW whatever I'll type will split]
P1 - " Blabla string has splitted. "

I hope you get what I mean.


Re: String spilting error. - Benzke - 23.11.2012

Well, I edited it a bit and I'm able to see the text I entered but unfortunately, it is not splitting, any idea why ? The string is not empty now.

pawn Код:
CMD:b(playerid,params[])
{
    if(isnull(params)) return SendClientMessage(playerid, COLOR_SYNTAX,"[SYNTAX]: /b [TEXT HERE]");
    new sendername[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid,sendername,sizeof(sendername));
    sendername[strfind(sendername,"_")] = ' ';
    if(PlayerInfo[playerid][Authenticated] == 1)
    {
   
        format(string, sizeof(string), "(( (ID:%d) %s: %s ))", playerid, GetName(playerid), params);
        ProxDetector(20.0, playerid, string,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
    }
    else if(strlen(params) > 24)
    {
        new part1[24];
        new part2[44];
        strmid(part1,string,0,23,24);
        format(string, sizeof(string), "(( (ID:%d) %s: %s... ))", playerid, GetName(playerid), part1);
        ProxDetector(20.0, playerid, string,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
        strmid(part2,string,24,128,44);
        format(string, sizeof(string), "(( (ID:%d) %s: ...%s ))", playerid, GetName(playerid), part2);
        ProxDetector(20.0, playerid, string,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY,COLOR_GREY);
    }
    return 1;
}