Textdraw Fail
#1

Textdraw crashes player when /stat

pawn Код:
dcmd_stat(playerid,params[]) {
    new string[128], pDeaths, player1, h, m, s;
    if(!strlen(params)) player1 = playerid;
    else player1 = strval(params);
   
    if(IsPlayerConnected(player1)) {
        TotalGameTime(player1, h, m, s);
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
        Stats = TextDrawCreate(740.0,620.0,"~g~~h~ Stats: \n~b~h~~Kills:  \nDeaths:  ~r~~h~\nRatio:  ~g~~h~\nMoney:  ~b~~h~\nTime:  hrs  mins  secs ~r~~h~\n Stats");
        TextDrawBoxColor(Stats,0x000000AA);
        TextDrawAlignment(Stats,2);
        TextDrawFont(Stats,2);
        TextDrawLetterSize(Stats,3.2,5.1);
        TextDrawTextSize(Stats,2.0,3.6);
        TextDrawSetOutline(Stats,1);
        format(string,sizeof(string),"~%s's Stats: \nKills: %d \nDeaths: %d \nRatio: %0.2f \nMoney: $%d \nTime: %d hrs %d mins %d secs \n%s's Stats",PlayerName2(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), h, m, s, PlayerName2(player1));
        TextDrawSetString(Stats,string);
        return TextDrawShowForPlayer(playerid,Stats);
    } else return SendClientMessage(playerid, red, "Player Not Connected!");
}
its the LAdmin /stats but i changed command && put in as textdraw but i cant get it to work or stop crashing player, any help?
Reply
#2

why are u creating the textdraw on the cmd.. maybe that crashes it put it under gamemodeinit and try

offtopic: why are the forums so dead today D:
Reply
#3

Try:

pawn Код:
Stats = TextDrawCreate(740.0,620.0,"~g~~h~ Stats: \n~b~~h~Kills:  \nDeaths:  ~r~~h~\nRatio:  ~g~~h~\nMoney:  ~b~~h~\nTime:  hrs  mins  secs ~r~~h~\n Stats");
Reply
#4

I've never worked with txtdraws that much, but maybe ~n~ instead of \n?
Reply
#5

still failed jeffry && kar let me try

EDIT: \n makes new line for textdraw ~n~is for new line in gametext

EDIT 2: Kar it failed 2
Reply
#6

pawn Код:
dcmd_stat(playerid,params[]) {
    new string[128], pDeaths, player1, h, m, s;
    if(!strlen(params)) player1 = playerid;
    else player1 = strval(params);
   
    if(IsPlayerConnected(player1)) {
        TotalGameTime(player1, h, m, s);
        if(PlayerInfo[player1][Deaths] == 0) pDeaths = 1; else pDeaths = PlayerInfo[player1][Deaths];
        Stats = TextDrawCreate(740.0,620.0,"~g~~h~ Stats: ~n~~b~~h~Kills:  ~n~Deaths:  ~r~~h~~n~Ratio:  ~g~~h~~n~Money:  ~b~~h~~n~Time:  hrs  mins  secs ~r~~h~~n~ Stats");
        TextDrawBoxColor(Stats,0x000000AA);
        TextDrawAlignment(Stats,2);
        TextDrawFont(Stats,2);
        TextDrawLetterSize(Stats,3.2,5.1);
        TextDrawTextSize(Stats,2.0,3.6);
        TextDrawSetOutline(Stats,1);
        format(string,sizeof(string),"%s's Stats: ~n~Kills: %d ~n~Deaths: %d ~n~Ratio: %0.2f ~n~Money: $%d ~n~Time: %d hrs %d mins %d secs ~n~%s's Stats",PlayerName2(player1), PlayerInfo[player1][Kills], PlayerInfo[player1][Deaths], Float:PlayerInfo[player1][Kills]/Float:pDeaths,GetPlayerMoney(player1), h, m, s, PlayerName2(player1));
        TextDrawSetString(Stats,string);
        return TextDrawShowForPlayer(playerid,Stats);
    } else return SendClientMessage(playerid, red, "Player Not Connected!");
}
Try this. If this still fails: /slap Jeffry.
Reply
#7

Well ~n~ in game text creates a new line :P and since it's possible to do ~r~ and stuff as well, I thought it might be possible ^^
Reply
#8

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
Well ~n~ in game text creates a new line :P and since it's possible to do ~r~ and stuff as well, I thought it might be possible ^^
It is. Good combined, Sherlock.
Reply
#9

the textdraw don't crash the server just noaw i cant get text to show -_-
Reply
#10

Quote:
Originally Posted by From Wiki
Note: The x,y coordinate is the top left coordinate for the text draw area based on a 640x480 "canvas" (irrespective of screen resolution). If you plan on using TextDrawAlignment with alignment 3 (right), the x,y coordinate is the top right coordinate for the text draw.
Change the coords after TextDrawCreate to e.g. 50, 100 just to test.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)