Textdraw Question
#1

Hello, My server has an announce command using a textdraw. So basicaly we do /text [Message] And we can use ~b~ ~n~ etc. I saw some people having an announce command but they couldn't use the ~n~ but needed $cr for example make it red. /text $crHello. In this case, the server is not crashing if ~r~ is misspelled in ~r~~. I'm asking how can I disable the usage of ~~ in my text command and make it using the "$c"?
Reply
#2

This may or may not work so don't blame me if it doesn't.

pawn Код:
stock CheckTD(String[]) {
    for(new StringPos = 0; StringPos < strlen(String); StringPos++) {
        if(String[StringPos] == '~' && String[(StringPos + 2)] == '~') {
            switch(String[(StringPos + 1)]) {
                case 'n', 'r', 'g', 'b': {
                    strdel(String, StringPos, (StringPos + 2));
                    StringPos--;
                }
            }
        }
        else if(String[StringPos] == '$' && String[(StringPos + 1)] == 'c') {
            switch(String[(StringPos + 2)]) {
                case 'r', 'g', 'b': {
                    String[StringPos] = '~';
                    String[(StringPos + 1)] = String[(StringPos + 2)];
                    String[(StringPos + 2)] = '~';
                }
            }
        }
    }
    return String;
}
Possible Example:
Код:
printf("%s", CheckTD("~r~Welcome to~n~ $crmy server! $cg$cnNoob!"));
Possible Output:
Welcome to my server! $cnNoob!
Reply
#3

The code you gave look fine but where should I add the CheckTD in my code?
I tried: But the td is not showing at all
pawn Код:
CMD:text(playerid,params[])
{
    if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);
    new announce[41];
    if(sscanf(params,"s[256]", announce)) return Usage(playerid, "/text [message]");

    if(!InUse)
    {
        TextDrawSetString(AnnText, CheckTD(announce));
        TextDrawShowForAll(AnnText);
        SetTimer("TextTime",4000,false);
        InUse = true;
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "Text already in use!");
    }
    AdminMessage(playerid, "/text");
    return 1;
}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)