Problem with string sizes
#1

Hello.
I'm trying to fix the string size, that the message that exteeds a certain limit, gets put into the next line, if that makes sense.

But it doesn't work.
This is my code:
PHP код:
* ============================================================================ */
COMMAND:s(playerid,params[])
{
    if(!
Player[playerid][Authed]) return SendClientError(playerid"You are not authed!");
    if(!
Player[playerid][Admin] && !Player[playerid][Helper]) return SendClientError(playerid,"You are not authorized to use this command!");
    new 
message[164],string[200],string2[100];
    if(
sscanf(params"s"message)) return SendClientUsage(playerid"/s [message]");
    
IRC_GroupSay(Group"#staff"sprintf("(Staff Chat) %s %s: %s "getAdminName(playerid),RPName(playerid),message));
    for(new 
0GetPlayerPoolSize(); <= ji++)
       {
           if(
Player[i][Admin])
           {
           
format(string,sizeof(string),"{FF0000}(Staff Chat) {D4D4D4}%s %s: {FFFFFF}%s",getAdminName(playerid),RPName(playerid),message);
        
SendClientMessage(i,-1,sprintf("%i",strlen(string)));
        if(
strlen(string) >= 97
        {
            
strmid(string2string96256);
            
strdel(string96256);
            
SendClientMessage(i, -1string);
            
SendClientMessage(i, -1string2);
        }     
        else 
SendClientMessage(i, -1string);
        }    
            else if(
Player[i][Helper])
            {
            
SendMessageToPlayer(i,-1,sprintf("{FF0000}(Staff Chat) {D4D4D4}%s %s: {FFFFFF}%s",getAdminName(playerid),RPName(playerid),message),110);
            }
       }
    return 
1;
}
/* ============================================================================= */ 
(what i'm talking about is after the if(playerid[playerid][Admin]).
This is what currently happends:

Reply
#2

Код:
strmid(string2, string, 0, 96); // string2 contains everything from 0 to 96 character
SendClientMessage(i, -1, string2);
strmid(string2, string, 96, 256); // string2 now contains everything from 96 to 256.
SendClientMessage(i, -1, string2);
Reply
#3

Quote:
Originally Posted by TORKQ
Посмотреть сообщение
Код:
strmid(string2, string, 0, 96); // string2 contains everything from 0 to 96 character
SendClientMessage(i, -1, string2);
strmid(string2, string, 96, 256); // string2 now contains everything from 96 to 256.
SendClientMessage(i, -1, string2);
yes

so, my code should be correct, right?
Reply
#4

bump
Reply
#5

This should help you out and relive the headache.

Код:
forward SendClientMessageA(playerid,color,text[]);
public SendClientMessageA(playerid,color,text[])
{
    new safetxt[400];
    format(safetxt,sizeof(safetxt),"%s",text);
    if(strlen(safetxt) <= 99) { SendClientMessage(playerid,color,text); }
    else {

        new texts[128];
        strmid(texts,safetxt,99,256);
        strins(safetxt, " ..", 99, 1);
        strdel(safetxt, 100, strlen(safetxt));
        SendClientMessage(playerid,color,safetxt);
        SendClientMessage(playerid,color,texts);

    }
}
Reply
#6

Quote:
Originally Posted by zT KiNgKoNg
Посмотреть сообщение
This should help you out and relive the headache.

Код:
forward SendClientMessageA(playerid,color,text[]);
public SendClientMessageA(playerid,color,text[])
{
    new safetxt[400];
    format(safetxt,sizeof(safetxt),"%s",text);
    if(strlen(safetxt) <= 99) { SendClientMessage(playerid,color,text); }
    else {

        new texts[128];
        strmid(texts,safetxt,99,256);
        strins(safetxt, " ..", 99, 1);
        strdel(safetxt, 100, strlen(safetxt));
        SendClientMessage(playerid,color,safetxt);
        SendClientMessage(playerid,color,texts);

    }
}


didnt work ;/
Reply
#7

The reason for that is because the whole "(Staff Chat) 1337 Administrator Test Eend: " is taking up 43 spaces in your limit of 128 characters in the messages, because the greatest length that any message can be in SA-MP Global Chat is 128 characters (I think). To view in the chat. So in order to fix your problem. I suggest re naming your Chat. So
(1337 Staff Chat): That will allow you to type more before it gets cut off.

That's also why when creating a message to display on global chat you always allow no more than 128 characters; new string[128]; or string[50]; not string[503]; < 503 is completely unnecessary as you won't be able to use 503 characters in one line in SA-MP Global Chat.
Reply
#8

Quote:
Originally Posted by Tass007
Посмотреть сообщение
The reason for that is because the whole "(Staff Chat) 1337 Administrator Test Eend: " is taking up 43 spaces in your limit of 128 characters in the messages, because the greatest length that any message can be in SA-MP Global Chat is 128 characters (I think). To view in the chat. So in order to fix your problem. I suggest re naming your Chat. So
(1337 Staff Chat): That will allow you to type more before it gets cut off.

That's also why when creating a message to display on global chat you always allow no more than 128 characters; new string[128]; or string[50]; not string[503]; < 503 is completely unnecessary as you won't be able to use 503 characters in one line in SA-MP Global Chat.
input = 128
output = 144

Quote:
Originally Posted by justjamie
Посмотреть сообщение
...




https://github.com/Kevin-Reinke/Mess...-Multiple-Rows
Reply
#9

Quote:
Originally Posted by SickAttack
Посмотреть сообщение
What do you mean with input & output?
Reply
#10

Quote:
Originally Posted by justjamie
Посмотреть сообщение
What do you mean with input & output?
https://sampwiki.blast.hk/wiki/Limits

The text input limit on chat / commands is limited to 128 cells and the out limit is limited to 144 cells.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)