Hello, world. I have 2 TextDraw that need to be updated on a function call. The problem is that the TextDraw are not updated immediately, but only after a set of variable characters. Sometimes TextDraw disappear and reappear.
PHP Code:
const STR_CHEAT_LIM = 99;
new CheatO [STR_CHEAT_LIM];
new CheatW [STR_CHEAT_LIM];
new Text:CheatShow_O,
Text:CheatShow_W;
public OnGameModeInit()
{
SetGameModeText("Blank Script");
AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
CheatShow_O = TextDrawCreate(9.3, 423.4, "_");
TextDrawColor(CheatShow_O, 0xef8100FF);
TextDrawFont(CheatShow_O, 1);
TextDrawSetOutline(CheatShow_O, 1);
TextDrawLetterSize(CheatShow_O, 0.316, 1.282);
CheatShow_W = TextDrawCreate(9.3, 434.4, "_");
TextDrawColor(CheatShow_W, 0xffffffFF);
TextDrawFont(CheatShow_W, 1);
TextDrawSetOutline(CheatShow_W, 1);
TextDrawLetterSize(CheatShow_W, 0.316, 1.282);
SetTimer ("GOSTR", 2000, true);
return 1;
}
forward GOSTR();
public GOSTR()
{
new typel = random(3);
new st_player = random(500);
AddCheatStr(st_player, typel);
return 1;
}
public OnPlayerConnect(playerid)
{
TextDrawShowForPlayer (playerid, CheatShow_O);
TextDrawShowForPlayer (playerid, CheatShow_W);
return 1;
}
stock AddCheatStr(playerid, type){
new num_id;
switch (playerid)
{
case 0..9: num_id = 1;
case 10..99: num_id = 2;
case 100..999: num_id = 3;
case 1000..9999: num_id = 4;
}
static const
add_id_g [] = "~g~%d",
add_id_b [] = "~b~%d",
add_id_w [] = "~w~%d";
new add_diff = sizeof add_id_g -2 + num_id;
new num_str;
if (type == 0 || type == 2)
{
num_str = strlen (CheatO);
}
else
{
num_str = strlen (CheatW);
}
new diff = add_diff + num_str;
new tempcheat [7];
if (type == 0)
{
format (tempcheat, sizeof (tempcheat), add_id_g, playerid);
format (CheatO, sizeof (CheatO), "%s\t %s", tempcheat, CheatO);
}
else if (type == 2)
{
format (tempcheat, sizeof (tempcheat), add_id_b, playerid);
format (CheatO, sizeof (CheatO), "%s\t %s", tempcheat, CheatO);
}
else
{
format (tempcheat, sizeof (tempcheat), add_id_w, playerid);
format (CheatW, sizeof (CheatW), "%s\t %s", tempcheat, CheatW);
}
if (diff > STR_CHEAT_LIM)
{
if (type == 0 || type == 2)
{
num_str = strlen (CheatO);
if (CheatO[num_str-1] == 'b' || CheatO[num_str-1] == 'g')
{
strdel (CheatO, num_str-1-1, STR_CHEAT_LIM);
}
if (CheatO[num_str-1] == '~')
{
if (CheatO[num_str-1-1] == ' ')
{
strdel (CheatO, num_str-1, STR_CHEAT_LIM);
}
}
}
else
{
num_str = strlen (CheatW);
if (CheatW[num_str-1] == 'w')
{
strdel (CheatW, num_str-1-1, STR_CHEAT_LIM);
}
if (CheatW[num_str-1] == '~')
{
if (CheatW[num_str-1-1] == ' ')
{
strdel (CheatW, num_str-1, STR_CHEAT_LIM);
}
}
}
}
TextDrawSetString(CheatShow_O, CheatO);
TextDrawSetString(CheatShow_W, CheatW);
return true;
}