Kills And Deaths Textdraw
#1

I was trying to create a kills and deaths textdraw . it compiles with no errors or warnings but it crashes ingame . after a certain number of deaths
Code
pawn Код:
#include <a_samp>
#include <zcmd>

new Text:Textdraw0;
new Text:Textdraw1;
new Text:Textdraw2;

new t[400];
new l[8][400];

public OnFilterScriptInit()
{
    Textdraw0 = TextDrawCreate(480.000000, 460, "usebox");
    TextDrawLetterSize(Textdraw0, 0.000000, -15);
    TextDrawTextSize(Textdraw0, 640.000000, 0.000000);
    TextDrawAlignment(Textdraw0, 1);
    TextDrawColor(Textdraw0, 0);
    TextDrawUseBox(Textdraw0, true);
    TextDrawBoxColor(Textdraw0, 102);
    TextDrawSetShadow(Textdraw0, 0);
    TextDrawSetOutline(Textdraw0, 0);
    TextDrawFont(Textdraw0, 0);

    Textdraw1 = TextDrawCreate(480, 330, "~r~Kills ~b~And ~r~Deaths");
    TextDrawLetterSize(Textdraw1, 0.2, 1.1);
    TextDrawAlignment(Textdraw1, 1);
    TextDrawColor(Textdraw1, -1);
    TextDrawSetShadow(Textdraw1, 0);
    TextDrawSetOutline(Textdraw1, 0);
    TextDrawBackgroundColor(Textdraw1, 51);
    TextDrawFont(Textdraw1, 1);
    TextDrawSetProportional(Textdraw1, 1);

    Textdraw2 = TextDrawCreate(480, 342, " ");
    TextDrawLetterSize(Textdraw2, 0.2, 1.1);
    TextDrawAlignment(Textdraw2, 1);
    TextDrawColor(Textdraw2, -1);
    TextDrawSetShadow(Textdraw2, 0);
    TextDrawSetOutline(Textdraw2, 0);
    TextDrawBackgroundColor(Textdraw2, 51);
    TextDrawFont(Textdraw2, 1);
    TextDrawSetProportional(Textdraw2, 1);

    return 1;
}

public OnPlayerConnect(playerid)
{
    TextDrawShowForPlayer(playerid,Textdraw0);
    TextDrawShowForPlayer(playerid,Textdraw1);
    TextDrawShowForPlayer(playerid,Textdraw2);
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
   
   
    if(playerid != killerid && killerid != INVALID_PLAYER_ID)
    {
        new str[128];
        new playern[MAX_PLAYER_NAME];
        new killern[MAX_PLAYER_NAME];
        GetPlayerName(playerid,playern,MAX_PLAYER_NAME);
        GetPlayerName(killerid,killern,MAX_PLAYER_NAME);
        format(str,128,"~w~ %s ~r~Was Killed By ~w~%s",playern,killern);
        for(new i = 0 ; i <= 6 ; i++)
        {
            l[i] = l[i + 1];
        }
        l[7] = str;
        format(t,400,"%s ~n~ %s ~n~ %s ~n~ %s ~n~ %s ~n~ %s ~n~ %s ~n~ %s",l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7]);
        TextDrawSetString(Textdraw2,t);
        TextDrawShowForAll(Textdraw2);
    }
    else if(playerid == killerid || killerid == INVALID_PLAYER_ID)
    {
        new str[128];
        new playern[MAX_PLAYER_NAME];
        GetPlayerName(playerid,playern,MAX_PLAYER_NAME);
        format(str,128,"~w~ %s ~r~Has Committed Suicide",playern);
        for(new i = 0 ; i <= 6 ; i++)
        {
            l[i] = l[i + 1];
        }
        l[7] = str;
        format(t,400,"%s ~n~ %s ~n~ %s ~n~ %s ~n~ %s ~n~ %s ~n~ %s ~n~ %s ~n~ %s",l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7]);
        TextDrawSetString(Textdraw2,t);
        TextDrawShowForAll(Textdraw2);
    }
    return 1;
}
CMD:kill(playerid,params[])
{
    SetPlayerHealth(playerid,0);
    return 1;
}
Reply
#2

anybody and sorry for bumping by the way i just need help now coz i have to study in about 30 minutes
Reply
#3

Important Notes:
  • Maximum length of textdraw is 800 characters. Longer text will crash the client.
  • If you use color codes (such as ~R~ ~G~) beyond 255th character the client will crash trying to display the textdraw.
  • text[] must NOT be empty or the server will crash! If you need a textdraw that shows nothing, use " " (a space) or _ (underscore)
  • There are four font styles as shown below. Font value 4 specifies that this is a txd sprite; 5 specifies that this textdraw can display preview models. A font value greater than 5 does not display, and anything greater than 16 crashes the client.
  • Although the textdraw string limit is 1024 characters, if colour codes (e.g. ~r~) are used beyond the 255th character it may crash the client.
Make sure you don't have any of the above..
Reply
#4

none of the listed above
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)