In-game text draw creating problem
#1

Well, I got a problem. I can create the textdraw in game, and I see it, but I can't edit it. I added this at the top:

pawn Код:
new Text:TextDraw;
And this is my text draw creating command which works:

pawn Код:
dcmd_td(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
new string[256];
if(!strlen(params))
{
SendClientMessage(playerid, COLOR_RED, "Usage: /td [text]");
return 1;
}
format(string, sizeof(string), "%s", params);
TextDraw = TextDrawCreate(20.0, 260.0, string);
TextDrawColor(Text:TextDraw, COLOR_RED);
TextDrawFont(Text:TextDraw, 3);
TextDrawUseBox(Text:TextDraw, false);
TextDrawShowForAll(TextDraw);
return 1;
}
else return 0;
}
But my editing commands doesn't work. This is one of my editing commands:

pawn Код:
dcmd_tdusebox(playerid, params[])
{
if(IsPlayerAdmin(playerid))
{
if(!strlen(params))
{
SendClientMessage(playerid, COLOR_RED, "Usage: /tdusebox [yes/no]");
return 1;
}
if(strcmp(params, "yes", true) == 0)
{
TextDrawUseBox(Text:TextDraw, true);
return 1;
}
if(strcmp(params, "no", true) == 0)
{
TextDrawUseBox(Text:TextDraw, false);
return 1;
}
return 1;
}
else return 0;
}
There is no compiling errors, the edit commands just won't work in-game. Any help?
Reply
#2

No need to create any of that

use this http://forum.sa-mp.com/index.php?topic=29132.0
Reply
#3

I really want to create my own. I don't want to download one. And that's why I asked about help. Any solutions? :P
Reply
#4

dunno.. I'd probably make it like this

pawn Код:
new Text:TextDraw[200];
new count = 0;
pawn Код:
dcmd_tdcreate(playerid,params[]) {
  if(IsPlayerAdmin(playerid)) {
    new string[128];
    if(!strlen(params)) return SendClientMessage(playerid, WHITE, "Use: /tdcreate [text]");
    format(string, sizeof(string), "Created textdraw (ID:%d).", count);
    SendClientMessage(playerid, COLOR_RED, string);
    format(string, sizeof(string), "%s", params);
    TextDraw[count] = TextDrawCreate(20.0, 260.0, string);
    TextDrawColor(TextDraw[count], COLOR_RED);
    TextDrawFont(TextDraw[count], 3);
    TextDrawUseBox(TextDraw[count], false);
    TextDrawShowForPlayer(playerid,TextDraw[count]);
    count += 1;
  }else return 0;
}
pawn Код:
dcmd_edittext(playerid,params[]) {
  if(IsPlayerAdmin(playerid)) {
    new tmp[256], tmp2[256], str[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
    if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, WHITE, "Use: /edittext [textid] [text]");
    if(strval(tmp) < 0 || strval(tmp) > count) return SendClientMessage(playerid, WHITE, "This text doesn't exist.");
    TextDrawSetString(Textdraw[tmp], params[strlen(tmp)+1]);
  }else return 0;
}
pawn Код:
dcmd_usebox(playerid,params[]) {
  if(IsPlayerAdmin(playerid)) {
    new tmp[256], tmp2[256], str[128], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
    if(!strlen(tmp) || !strlen(tmp2)) return SendClientMessage(playerid, WHITE, "Use: /usebox [textid] [yes/no]");
    if(strval(tmp) < 0 || strval(tmp) > count) return SendClientMessage(playerid, WHITE, "This text doesn't exist.");
    if(strcmp(tmp2, "yes", true) ==0) TextDrawUseBox(TextDraw[tmp], true);
    else if(strcmp(tmp2, "no", true) ==0) TextDrawUseBox(TextDraw[tmp], false);
  }else return 0;
}
I would also make dcmd_tdfont, dcmd_tdcolor and a command to move textdraw and resize it.
Reply
#5

Ah, thank you. It works.
Reply
#6

Just hide your textraw and show it again. After that your textdraw should be updated.
Reply
#7

Quote:
Originally Posted by Scott[LT
]
Just hide your textraw and show it again. After that your textdraw should be updated.
That's also a choice. But I decided to show the text draw, and then return 0.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)