Speedo Textdraw Blinking
#1

Hi all.

Today i realized my new Speedo with Textdraws. It just displays one "I" for each 10 Km/h you do.

Here a preview: http://i.gyazo.com/d80095a9495a988f5c6d0fdcc8989476.png

The problem is that, sometimes, the Textdraw disappears. I costantly update it behind "OnPlayerUpdate(playerid)". There's a script which check, if player is in a vehicle, his speed and then it prints it out with the textdraw. I figured that the bug cames from OnPlayerUpdate, which updates player every second and this could bug the textdraws, but i don't know how to do better.

Any idea?
Reply
#2

OnPlayerUpdate is not the best place for textdraws, A timer of 200 - 300 ms should be fine for this situation.
You could detect when player enters vehicle with OnPlayerStateChange and saving that in boolean or integer,
and setting textdraw on/ off with it, then, use custom timer to update the speed.
Reply
#3

I'll try it now! Thank you!
Reply
#4

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
OnPlayerUpdate is not the best place for textdraws, A timer of 200 - 300 ms should be fine for this situation.
You could detect when player enters vehicle with OnPlayerStateChange and saving that in boolean or integer,
and setting textdraw on/ off with it, then, use custom timer to update the speed.
It's just a bit slower but it keeps blinking!
Reply
#5

Quote:
Originally Posted by ProjectGANTON
Посмотреть сообщение
It's just a bit slower but it keeps blinking!
Well, as once ****** said, we're not magicians and we can't guess your code.
Reply
#6

Are u using a image in textdrAW?
Reply
#7

Quote:
Originally Posted by Hanuman
Посмотреть сообщение
Are u using a image in textdrAW?
No, i am not using any image. Just look at the picture
Reply
#8

May you show us the code? Otherwise it's less likely somebody can help you at all
Reply
#9

Quote:
Originally Posted by [WSF]ThA_Devil
Посмотреть сообщение
Well, as once ****** said, we're not magicians and we can't guess your code.
I explained my method. Let me release my code, so:

Код:
forward UpdateCok(playerid);
public UpdateCok(playerid) {
if(!IsPlayerInAnyVehicle(playerid) || PlayerCok[playerid] == 0 || IsABike(GetPlayerVehicleID(playerid)) || GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return HideCok(playerid);
new PlayerVehicleSpeed[MAX_PLAYERS];
PlayerVehicleSpeed[playerid] = GetVehicleSpeed(playerid);
new string[200];
new tacche[350];
new x = PlayerVehicleSpeed[playerid];
if(RetroMarcia[playerid] == 1)
{
TextDrawSetString(CokMarcia[playerid],"R");
}
else
{
TextDrawSetString(CokMarcia[playerid],"1");
}
TextDrawHideForPlayer(playerid,CokNumero[playerid]);
TextDrawHideForPlayer(playerid,CokTacche[playerid]);
if(PlayerVehicleSpeed[playerid] >= 0 && PlayerVehicleSpeed[playerid] <= 9)
{
format(string,sizeof(string),"00%d",PlayerVehicleSpeed[playerid]);
}
if(PlayerVehicleSpeed[playerid] >= 10 && PlayerVehicleSpeed[playerid] <= 99)
{
format(string,sizeof(string),"0%d",PlayerVehicleSpeed[playerid]);
}
if(PlayerVehicleSpeed[playerid] >= 100)
{
format(string,sizeof(string),"%d",PlayerVehicleSpeed[playerid]);
}
if(x <= 1) {
    format(tacche,sizeof(tacche),"llllllllllllllllllllll");
} else if(x > 1 && x < 11) {
    format(tacche,sizeof(tacche),"~g~l~w~lllllllllllllllllllll");
} else if(x > 11 && x < 21) {
    format(tacche,sizeof(tacche),"~g~ll~w~llllllllllllllllllll");
} else if(x > 21 && x < 31) {
    format(tacche,sizeof(tacche),"~g~lll~w~lllllllllllllllllll");
} else if(x > 31 && x < 41) {
    format(tacche,sizeof(tacche),"~g~llll~w~llllllllllllllllll");
} else if(x > 41 && x < 51) {
    format(tacche,sizeof(tacche),"~g~lllll~w~lllllllllllllllll");
} else if(x > 51 && x < 61) {
    format(tacche,sizeof(tacche),"~g~llllll~w~llllllllllllllll");
} else if(x > 61 && x < 71) {
    format(tacche,sizeof(tacche),"~g~llllllll~w~llllllllllllll");
} else if(x > 71 && x < 81) {
    format(tacche,sizeof(tacche),"~g~lllllllll~w~lllllllllllll");
} else if(x > 81 && x < 91) {
    format(tacche,sizeof(tacche),"~g~llllllllll~w~llllllllllll");
} else if(x > 101 && x < 111) {
    format(tacche,sizeof(tacche),"~g~lllllllllll~w~lllllllllll");
} else if(x > 111 && x < 121) {
    format(tacche,sizeof(tacche),"~g~llllllllllll~w~llllllllll");
} else if(x > 121 && x < 131) {
    format(tacche,sizeof(tacche),"~g~lllllllllllll~w~lllllllll");
} else if(x > 131 && x < 141) {
    format(tacche,sizeof(tacche),"~g~llllllllllllll~w~llllllll");
} else if(x > 141 && x < 151) {
    format(tacche,sizeof(tacche),"~g~lllllllllllllll~w~lllllll");
} else if(x > 151 && x < 161) {
    format(tacche,sizeof(tacche),"~g~lllllllllllllllll~w~lllll");
} else if(x > 161 && x < 171) {
    format(tacche,sizeof(tacche),"~g~llllllllllllllllll~w~llll");
} else if(x > 181 && x < 191) {
    format(tacche,sizeof(tacche),"~g~lllllllllllllllllll~w~lll");
} else if(x > 191 && x < 195) {
    format(tacche,sizeof(tacche),"~g~llllllllllllllllllll~w~ll");
} else if(x > 195 && x < 196) {
    format(tacche,sizeof(tacche),"~g~lllllllllllllllllllll~w~l");
} else if(x > 196) {
    format(tacche,sizeof(tacche),"~g~llllllllllllllllllllll");
}
TextDrawSetString(CokTacche[playerid],tacche);
TextDrawSetString(CokNumero[playerid],string);
TextDrawShowForPlayer(playerid,CokNumero[playerid]);
TextDrawShowForPlayer(playerid,CokTacche[playerid]);
return 1;
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
	{
		if(!IsABike(vehicleid) && CarShop[playerid] == 0)
		{
		PlayerCok[playerid] = 1;
		ShowCok(playerid);
		CokTimer[playerid] = SetTimerEx("UpdateCok", 300, true, "i", playerid);
		}
         }
}
That's all. I excluded code where i hide the COK, won't help you i guess
Reply
#10

try hiding textdraws only when you update it, not hiding before.
Aswell that's a weird way of updating it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)