11.01.2012, 00:27
Hello!
I got some trouble with a menu thats made with textdraws.
The menu is made to show what bomb you have activated, like this
__________
"Nothing"
"bombname1"
"bombname2"
"bombname3"
"bombname4"
__________
If you have ex "bombname2" activated, the "bombname2" text is green, and when you drop the bomb it is red during reloading.
So now to the problems.
1: The menu freeze so you cant see what bomb you have activated how much you even push the "next" button.
2: The menu disappears sometimes.
3: When someone flips between the bombs, you can see that on YOUR menu sometimes.
4: When you exit the vehicle the menu sometimes doesnt disappear.
Thats all bugs (i think) that happens sometimes (pretty often).
And now to the codes.
Here is everything about that textdraw.
I got some trouble with a menu thats made with textdraws.
The menu is made to show what bomb you have activated, like this
__________
"Nothing"
"bombname1"
"bombname2"
"bombname3"
"bombname4"
__________
If you have ex "bombname2" activated, the "bombname2" text is green, and when you drop the bomb it is red during reloading.
So now to the problems.
1: The menu freeze so you cant see what bomb you have activated how much you even push the "next" button.
2: The menu disappears sometimes.
3: When someone flips between the bombs, you can see that on YOUR menu sometimes.
4: When you exit the vehicle the menu sometimes doesnt disappear.
Thats all bugs (i think) that happens sometimes (pretty often).
And now to the codes.
Here is everything about that textdraw.
pawn Code:
forward ShowTextDraw(playerid, vehicleid, count);
forward RemoveTextDraw(playerid);
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
vmid[playerid] = GetVehicleStatID(GetVehicleModel(vehicleid));
if(vmid[playerid] > -1) {
bptype[playerid] = 0;
#if(USE_TEXTDRAWS)
SetTimerEx("ShowTextDraw", 500, 0, "iii", playerid, vehicleid, 0);
#endif
}
return 1;
}
public ShowTextDraw(playerid, vehicleid, count)
{
if(IsPlayerInVehicle(playerid, vehicleid)) {
bombtext[playerid] = TextDrawCreate(400, 200, " ");
TextDrawUseBox(bombtext[playerid], 1);
TextDrawBoxColor(bombtext[playerid], 0x00000066);
TextDrawFont(bombtext[playerid], 1);
UpdateTextDraw(playerid);
removetimer[playerid] = SetTimerEx("RemoveTextDraw", 2000, 1, "i", playerid);
TextDrawShowForPlayer(playerid, bombtext[playerid]);
} else {
count ++;
if(count < 20) SetTimerEx("ShowTextDraw", 500, 0, "iii", playerid, vehicleid, count);
}
}
public RemoveTextDraw(playerid)
{
if(!IsPlayerInAnyVehicle(playerid)) {
TextDrawHideForPlayer(playerid, bombtext[playerid]);
TextDrawDestroy(bombtext[playerid]);
KillTimer(removetimer[playerid]);
}
}
stock UpdateTextDraw(playerid)
{
new text[160] = " ";
#if(USE_TEXTDRAWS == 1)
if(bptype[playerid] == 0) text = "~r~Nothing~w~";
else text = "Nothing";
for(new i = 1; i < sizeof gBombTypes; i ++)
if(gVehicleBombs[vmid[playerid]][i + 1] == 1) {
if(bptype[playerid] == i) {
if(bfree[playerid] || !IsPlayerAllowedToDropBomb(playerid)) format(text, 160, "%s~n~~r~%s~w~", text, gBombTypes[i][bombName]);
else format(text, 160, "%s~n~~g~%s~w~", text, gBombTypes[i][bombName]);
} else format(text, 160, "%s~n~%s", text, gBombTypes[i][bombName]);
}
#elseif(USE_TEXTDRAWS == 2)
if(bfree[playerid] || bptype[playerid] == 0 || !IsPlayerAllowedToDropBomb(playerid)) format(text, 160, "~r~%s", gBombTypes[bptype[playerid]][bombName]);
else format(text, 160, "~g~%s", gBombTypes[bptype[playerid]][bombName]);
#endif
TextDrawSetString(bombtext[playerid], text);
}