textdraw crashing
#1

pawn Код:
CMD:groupinfo(playerid,params[])
{
    new str[1024];
    format(str,sizeof(str),"~y~/Groupcreate (name)~w~ - Create A New Group");
    //strcat(str, "~n~~y~/Groupleave~w~ - Leave Your Group", sizeof(str));
    strcat(str, "~n~~y~/Groupleave~w~ - Leave Your Group", sizeof(str));
    strcat(str, "~n~~y~/Groupinvite~w~ - Invite A Player To Join Your Group", sizeof(str));
    strcat(str, "~n~~y~/Groupkick (id/nick) ~w~ - Kick A Player From Your Group(Rank 5+)", sizeof(str));
    strcat(str, "~n~~y~/Grouplist~w~ - List Group Members", sizeof(str));
    strcat(str, "~n~~y~/Groupcall~w~ - Call Group Members", sizeof(str));
    strcat(str, "~n~~y~/G (Msg)~w~ - Send A Group Message", sizeof(str));
    strcat(str, "~n~~y~/Groupname (Name)~w~ - Change The Name Of Your Group", sizeof(str));
    strcat(str, "~n~~y~/Grouprank (rank=0-6) (Rank Name)~w~ - Change The Name Of A Rank (Leader)", sizeof(str));
    strcat(str, "~n~~y~/Setrank (id/nick) (rank=0-5)~w~ - Set A Player's Rank", sizeof(str));
    strcat(str, "~n~~y~/Getmotd~w~ - Get Your Group MOTD", sizeof(str));
    strcat(str, "~n~~y~/Motd~w~ - Set The MOTD Of Your Group(Rank 5+)", sizeof(str));
    strcat(str, "~n~~y~/Togglegroupchat~w~ - Turn Group Chatting On/Off (Leader)", sizeof(str));
    strcat(str, "~n~~y~/Groups~w~ - List Active Groups", sizeof(str));
    strcat(str, "~n~~y~/Groupleader (id/nick)~w~ - Transfer Ownership", sizeof(str));
    strcat(str, "~n~~n~ ~w~Visit ~b~http://www.Lasventuras.net~w~ For A Complete~n~ List And More Information", sizeof(str));
    strcat(str, "             ~w~Press ~y~LMB~w~ To Close This Box", sizeof(str));

    TextDrawSetString(GroupText,str);
    TextDrawShowForPlayer(playerid,GroupBox);
    TextDrawShowForPlayer(playerid,GroupText);
    TextDrawShowForPlayer(playerid,GroupHeader);
    SetTimerEx("HideDraw", 15000, false, "i", playerid);
    return 1;
}
i used strcat? it shouldn't crash..?
Reply
#2

nothing looks wrong with that, show the other textdraws.
TextDrawShowForPlayer(playerid,GroupBox);
TextDrawShowForPlayer(playerid,GroupText);
TextDrawShowForPlayer(playerid,GroupHeader);
Reply
#3

?

pawn Код:
GroupBox = TextDrawCreate(260.000000, 125.000000, "  ");
    TextDrawBackgroundColor(GroupBox, 255);
    TextDrawFont(GroupBox, 1);
    TextDrawLetterSize(GroupBox, 0.000000, 18.300020);
    TextDrawColor(GroupBox, -1);
    TextDrawSetOutline(GroupBox, 0);
    TextDrawSetProportional(GroupBox, 1);
    TextDrawSetShadow(GroupBox, 1);
    TextDrawUseBox(GroupBox, 1);
    TextDrawBoxColor(GroupBox, 102);
    TextDrawTextSize(GroupBox, 31.000000, 3.000000);

    GroupHeader = TextDrawCreate(68.000000, 131.000000, "~b~Group Information");
    TextDrawBackgroundColor(GroupHeader, 255);
    TextDrawFont(GroupHeader, 3);
    TextDrawLetterSize(GroupHeader, 0.489999, 1.100000);
    TextDrawColor(GroupHeader, 65535);
    TextDrawSetOutline(GroupHeader, 0);
    TextDrawSetProportional(GroupHeader, 1);
    TextDrawSetShadow(GroupHeader, 0);

    GroupText = TextDrawCreate(41.000000, 151.000000, "~y~/Groupcreate~w~ - Create A New Group");
    TextDrawBackgroundColor(GroupText, 255);
    TextDrawFont(GroupText, 1);
    TextDrawLetterSize(GroupText, 0.300000, 1.000000);
    TextDrawColor(GroupText, -1);
    TextDrawSetOutline(GroupText, 0);
    TextDrawSetProportional(GroupText, 1);
    TextDrawSetShadow(GroupText, 1);
Reply
#4

I'm not sure but try debugging it to see where it crashes at like
pawn Код:
CMD:groupinfo(playerid,params[])
{
    new str[1024];
    format(str,sizeof(str),"~y~/Groupcreate (name)~w~ - Create A New Group");
    TextDrawSetString(GroupText,str);
    TextDrawShowForPlayer(playerid,GroupText);
    print("line1 complete");
    strcat(str, "~n~~y~/Groupleave~w~ - Leave Your Group", sizeof(str));
    TextDrawSetString(GroupText,str);
    TextDrawShowForPlayer(playerid,GroupText);
    print("line2 complete");
ect. ect.
Reply
#5

nothing happened
pawn Код:
[17:03:53] Command Executed
[17:03:53] Variable Created
[17:03:53] String Formatted
[17:03:53] Strcat1
[17:03:53] Strcat2
[17:03:53] Strcat3
[17:03:53] Strcat4
[17:03:53] Strcat5
[17:03:53] Strcat6
[17:03:53] Strcat7
[17:03:53] Strcat8
[17:03:53] Strcat9
[17:03:53] Strcat10
[17:03:53] Strcat11
[17:03:53] Strcat12
[17:03:53] Strcat13
[17:03:53] Strcat14
[17:03:53] Strcat15
[17:03:53] Strcat16
[17:03:53] GroupText String Setted
[17:03:53] Group Box Showed
[17:03:53] Group Text Showed
[17:03:53] Group Header Showed
[17:03:53] Command Succesfully Executed.
pawn Код:
print("Command Executed");
    new str[1024];
    print("Variable Created");
    format(str,sizeof(str),"~y~/Groupcreate (name)~w~ - Create A New Group");
    print("String Formatted");
    strcat(str, "~n~~y~/Groupleave~w~ - Leave Your Group", sizeof(str));
    print("Strcat1");
    strcat(str, "~n~~y~/Groupinvite~w~ - Invite A Player To Join Your Group", sizeof(str));
    print("Strcat2");
    strcat(str, "~n~~y~/Groupkick (id/nick) ~w~ - Kick A Player From Your Group(Rank 5+)", sizeof(str));
    print("Strcat3");
    strcat(str, "~n~~y~/Grouplist~w~ - List Group Members", sizeof(str));
    print("Strcat4");
    strcat(str, "~n~~y~/Groupcall~w~ - Call Group Members", sizeof(str));
    print("Strcat5");
    strcat(str, "~n~~y~/G (Msg)~w~ - Send A Group Message", sizeof(str));
    print("Strcat6");
    strcat(str, "~n~~y~/Groupname (Name)~w~ - Change The Name Of Your Group", sizeof(str));
    print("Strcat7");
    strcat(str, "~n~~y~/Grouprank (rank=0-6) (Rank Name)~w~ - Change The Name Of A Rank (Leader)", sizeof(str));
    print("Strcat8");
    strcat(str, "~n~~y~/Setrank (id/nick) (rank=0-5)~w~ - Set A Player's Rank", sizeof(str));
    print("Strcat9");
    strcat(str, "~n~~y~/Getmotd~w~ - Get Your Group MOTD", sizeof(str));
    print("Strcat10");
    strcat(str, "~n~~y~/Motd~w~ - Set The MOTD Of Your Group(Rank 5+)", sizeof(str));
    print("Strcat11");
    strcat(str, "~n~~y~/Togglegroupchat~w~ - Turn Group Chatting On/Off (Leader)", sizeof(str));
    print("Strcat12");
    strcat(str, "~n~~y~/Groups~w~ - List Active Groups", sizeof(str));
    print("Strcat13");
    strcat(str, "~n~~y~/Groupleader (id/nick)~w~ - Transfer Ownership", sizeof(str));
    print("Strcat14");
    strcat(str, "~n~~n~ ~w~Visit ~b~http://www.Lasventuras.net~w~ For A Complete~n~ List And More Information", sizeof(str));
    print("Strcat15");
    strcat(str, "             ~w~Press ~y~LMB~w~ To Close This Box", sizeof(str));
    print("Strcat16");

    TextDrawSetString(GroupText,str);
    print("GroupText String Setted");
    TextDrawShowForPlayer(playerid,GroupBox);
    print("Group Box Showed");
    TextDrawShowForPlayer(playerid,GroupText);
    print("Group Text Showed");
    TextDrawShowForPlayer(playerid,GroupHeader);
    print("Group Header Showed");
    SetTimerEx("HideDraw", 15000, false, "i", playerid);
    print("Command Succesfully Executed.");
o btw i meant the player crashes
Reply
#6

You have TextDrawCreate anywhere?

EDIT: Didnt read 3rd post sorry.
Reply
#7

maybe there are to many ~'s? i splitted it into 2 formats and it still crashed though..
Reply
#8

pawn Код:
TextDrawCreate(260.000000, 125.000000, "  ");
Crashes on empty strings. Put a '.' or something.
Reply
#9

pawn Код:
CarBombBox[playerid] = TextDrawCreate(290.000000, 133.000000, "  ");
    TextDrawBackgroundColor(CarBombBox[playerid], 255);
    TextDrawFont(CarBombBox[playerid], 1);
    TextDrawLetterSize(CarBombBox[playerid], 0.439999, 8.199997);
    TextDrawColor(CarBombBox[playerid], -1);
    TextDrawSetOutline(CarBombBox[playerid], 0);
    TextDrawSetProportional(CarBombBox[playerid], 1);
    TextDrawSetShadow(CarBombBox[playerid], 1);
    TextDrawUseBox(CarBombBox[playerid], 1);
    TextDrawBoxColor(CarBombBox[playerid], 102);
    TextDrawTextSize(CarBombBox[playerid], 32.000000, 0.000000);

    MissionBox = TextDrawCreate(290.000000, 133.000000, "  ");
    TextDrawBackgroundColor(MissionBox, 255);
    TextDrawFont(MissionBox, 1);
    TextDrawLetterSize(MissionBox, 0.439999, 8.199997);
    TextDrawColor(MissionBox, -1);
    TextDrawSetOutline(MissionBox, 0);
    TextDrawSetProportional(MissionBox, 1);
    TextDrawSetShadow(MissionBox, 1);
    TextDrawUseBox(MissionBox, 1);
    TextDrawBoxColor(MissionBox, 0x00000066);
    TextDrawTextSize(MissionBox, 32.000000, 0.000000);
    DriverBox[i] = TextDrawCreate(537.000000, 363.000000, "  ");
        TextDrawBackgroundColor(DriverBox[i], 255);
        TextDrawFont(DriverBox[i], 1);
        TextDrawLetterSize(DriverBox[i], 0.400000, 3.300008);
        TextDrawColor(DriverBox[i], -1);
        TextDrawSetOutline(DriverBox[i], 0);
        TextDrawSetProportional(DriverBox[i], 1);
        TextDrawSetShadow(DriverBox[i], 1);
        TextDrawUseBox(DriverBox[i], 1);
        TextDrawBoxColor(DriverBox[i], 0x00000066);
        TextDrawTextSize(DriverBox[i], 467.000000, 20.000000);
those dont crash.. anyways i'll do it..

also still crash .. im gonna debug to see if its strcat or w/e
Reply
#10

sorry but this is the crashing line..

pawn Код:
strcat(str, "~n~~y~/G (Msg)~w~ - Send A Group Message", sizeof(str));
pawn Код:
CMD:groupinfo(playerid,params[])
{
    new str[1024];
    format(str,sizeof(str),"~y~/Groupcreate (name)~w~ - Create A New Group");
    strcat(str, "~n~~y~/Groupleave~w~ - Leave Your Group", sizeof(str));
    strcat(str, "~n~~y~/Groupinvite~w~ - Invite A Player To Join", sizeof(str));
    strcat(str, "~n~~y~/Groupkick (id/nick)~w~ - Kick A Player (Leader)", sizeof(str));
    strcat(str, "~n~~y~/Grouplist~w~ - List Group Members", sizeof(str));
    strcat(str, "~n~~y~/Groupcall~w~ - Call Group Members", sizeof(str));
    strcat(str, "~n~~y~/G (Msg)~w~ - Send A Group Message", sizeof(str));
    /*strcat(str, "~n~~y~/Groupname (Name)~w~ - Change The Name Of Your Group", sizeof(str));

    strcat(str, "~n~~y~/Grouprank (rank=0-6) (Rank Name)~w~ - Change The Name Of A Rank (Leader)", sizeof(str));
    print("Strcat8");
    strcat(str, "~n~~y~/Setrank (id/nick) (rank=0-5)~w~ - Set A Player's Rank", sizeof(str));
    print("Strcat9");
    strcat(str, "~n~~y~/Getmotd~w~ - Get Your Group MOTD", sizeof(str));
    print("Strcat10");
    strcat(str, "~n~~y~/Motd~w~ - Set The MOTD Of Your Group(Rank 5+)", sizeof(str));
    print("Strcat11");
    strcat(str, "~n~~y~/Togglegroupchat~w~ - Turn Group Chatting On/Off (Leader)", sizeof(str));
    print("Strcat12");
    strcat(str, "~n~~y~/Groups~w~ - List Active Groups", sizeof(str));
    print("Strcat13");
    strcat(str, "~n~~y~/Groupleader (id/nick)~w~ - Transfer Ownership", sizeof(str));
    print("Strcat14");
    strcat(str, "~n~~n~ ~w~Visit ~b~http://www.Lasventuras.net~w~ For A Complete~n~ List And More Information", sizeof(str));
    print("Strcat15");
    strcat(str, "             ~w~Press ~y~LMB~w~ To Close This Box", sizeof(str));
    print("Strcat16");
*/

    TextDrawSetString(GroupText,str);
    print("GroupText String Setted");
    TextDrawShowForPlayer(playerid,GroupBox);
    print("Group Box Showed");
    TextDrawShowForPlayer(playerid,GroupText);
    print("Group Text Showed");
    TextDrawShowForPlayer(playerid,GroupHeader);
    print("Group Header Showed");
    SetTimerEx("HideDraw", 20000, false, "i", playerid);
    print("Command Succesfully Executed.");
    return 1;
}
i left out al the strcats but this and when i put it in it crashed.
Reply
#11

only thing I see is it going over 256 characters, but that shouldn't crash it since it's limited to 1024
Reply
#12

it looks like any strcat after
pawn Код:
strcat(str, "~n~~y~/Groupcall~w~ - Call Group Members", sizeof(str));
is crashing. i'll increase it to 2k i guess to test

still crash.. i'll make 2 strings

yet it became worst.
Reply
#13

Even though textdraws have a huge string limit, using symbols like ~w~ ~n~ ~y~ has a limit. Don't use too many (You have used too many).
Why do you keep repeating the ~y~? It's already yellow. Just use ~y~ at the start of the format.
Reply
#14

1 new line 1 yellow then white
pawn Код:
strcat(str, "~n~~y~/G (Msg)~w~ - Send A Group Message", sizeof(str));
urgh is there any other way
Reply
#15

pawn Код:
new str[1024];
    format(str,sizeof(str),"~y~/Groupcreate (name)~w~ - Create A New Group");
    format(str,sizeof(str),"%s~n~~y~/Groupleave~w~ - Leave Your Group", str);
    format(str,sizeof(str),"%s~n~~y~/Groupleave~w~ - Leave Your Group", str);
    format(str,sizeof(str),"%s~n~~y~/Groupinvite~w~ - Invite A Player To Join Your Group", str);
    format(str,sizeof(str),"%s~n~~y~/Groupkick (id/nick) ~w~ - Kick A Player From Your Group(Rank 5+)", str);
    format(str,sizeof(str),"%s~n~~y~/Grouplist~w~ - List Group Members", str);
    format(str,sizeof(str),"%s~n~~y~/Groupcall~w~ - Call Group Members", str);
    format(str,sizeof(str),"%s~n~~y~/G (Msg)~w~ - Send A Group Message", str);
    format(str,sizeof(str),"%s~n~~y~/Groupname (Name)~w~ - Change The Name Of Your Group", str);
    format(str,sizeof(str),"%s~n~~y~/Grouprank (rank=0-6) (Rank Name)~w~ - Change The Name Of A Rank (Leader)", str);
    format(str,sizeof(str),"%s~n~~y~/Setrank (id/nick) (rank=0-5)~w~ - Set A Player's Rank", str);
    format(str,sizeof(str),"%s~n~~y~/Getmotd~w~ - Get Your Group MOTD", str);
    format(str,sizeof(str),"%s~n~~y~/Motd~w~ - Set The MOTD Of Your Group(Rank 5+)", str);
    format(str,sizeof(str),"%s~n~~y~/Togglegroupchat~w~ - Turn Group Chatting On/Off (Leader)", str);
    format(str,sizeof(str),"%s~n~~y~/Groups~w~ - List Active Groups", str);
    format(str,sizeof(str),"%s~n~~y~/Groupleader (id/nick)~w~ - Transfer Ownership", str);
    format(str,sizeof(str),"%s~n~~n~ ~w~Visit ~b~http://www.Lasventuras.net~w~ For A Complete~n~ List And More Information", str);
    format(str,sizeof(str),"%s             ~w~Press ~y~LMB~w~ To Close This Box", str);
Don't know if this will help any, but it doesn't use strcat.

You could use two textdraws otherwise.
Reply
#16

trust me, that wouldn't work, anyways i fixed it can you help here? https://sampforum.blast.hk/showthread.php?tid=193334

pawn Код:
CMD:groupinfo(playerid,params[])
{
    new str[256],str1[256],str2[256],str3[512];
    format(str,sizeof(str),"~y~/Groupcreate (name)~w~ - Create A New Group");
    strcat(str, "~n~~y~/Groupleave~w~ - Leave Your Group", sizeof(str));
    strcat(str, "~n~~y~/Groupinvite~w~ - Invite A Player To Join", sizeof(str));
    strcat(str, "~n~~y~/Groupkick (id/nick)~w~ - Kick A Player (Leader)", sizeof(str));
   
    format(str1,sizeof(str1),"~n~~n~~n~~n~~y~/Grouplist~w~ - List Group Members");
    strcat(str1, "~n~~y~/Groupcall~w~ - Call Group Members", sizeof(str1));
    strcat(str1, "~n~~y~/Gm (Msg)~w~ - Send A Group Message", sizeof(str1));
    strcat(str1, "~n~~y~/Groupname (Name)~w~ - Change The Name Of Your Group", sizeof(str1));

    format(str2,sizeof(str2),"~n~~n~~n~~n~~n~~n~~n~~n~~y~/Grouprank~w~ - Change The Name Of A Rank (Leader)");
    strcat(str2, "~n~~y~/Setrank (id/nick)(rank=0-5)~w~ - Set A Player's Rank", sizeof(str2));
    strcat(str2, "~n~~y~/Getmotd~w~ - Get Your Group MOTD", sizeof(str2));
    strcat(str2, "~n~~y~/Motd~w~ - Set The MOTD Of Your Group(Rank 5+)", sizeof(str2));
   
    format(str3,sizeof(str3),"~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~y~/Togglegroupchat~w~ - Turn Group Chatting On/Off(Leader)");
    strcat(str3, "~n~~y~/Groups~w~ - List Active Groups", sizeof(str3));
    strcat(str3, "~n~~y~/Groupleader (id/nick)~w~ - Transfer Ownership", sizeof(str3));
    strcat(str3, "~n~~n~    ~w~Visit ~b~http://www.Lasventuras.net~w~ For A Complete~n~        List And More Game Information", sizeof(str3));
    strcat(str3, "~n~           ~w~Press ~y~LMB~w~ To Close This Box", sizeof(str3));

    TextDrawSetString(GroupText,str);
    TextDrawSetString(GroupText1,str1);
    TextDrawSetString(GroupText2,str2);
    TextDrawSetString(GroupText3,str3);
    TextDrawShowForPlayer(playerid,GroupBox);
    TextDrawShowForPlayer(playerid,GroupText);
    TextDrawShowForPlayer(playerid,GroupText1);
    TextDrawShowForPlayer(playerid,GroupText2);
    TextDrawShowForPlayer(playerid,GroupText3);
    TextDrawShowForPlayer(playerid,GroupHeader);
    SetTimerEx("HideDraw", 20000, false, "i", playerid);
    return 1;
}
;p
Reply
#17

Why would it not work?
Reply
#18

because when you format the string, it actually formats

so only the last value would work and str would be set to

format(str,sizeof(str),"%s ~w~Press ~y~LMB~w~ To Close This Box", str);

each time you format a string, it changes the Entire string notice i formatted str1 str2 str3 then strcatted ( adding a string to a string(strcat) or (strins))
Reply
#19

You are wrong, look at what I am doing before you believe you are right.

I'm putting whatever "str" is at the start of the new "str" hence it inherits itself and adds everything else after it.

It would work, I do this all of the time with 100% success.
Reply
#20

oh.. didnt notice that lol anyways ty
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)