Textdraws disappearing / timers
#1

Ok, i have tetxrdaws on the screen that tell location, speed, vehicle name... etc... and after a while of being in the server, either the timer just stops looping, or the textdraws just stop coming up. Can Anyone please help! its very urgent!

heres the code for the speedo:
pawn Код:
// very top
new Text:SpeedO[MAX_PLAYERS];

forward Speed();

// under game mode init
SetTimer("Speed",1000,1);

// state chnage
if (oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
    {
      TextDrawShowForPlayer(playerid,SpeedO[playerid]);
    }
if (oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
    {
      TextDrawHideForPlayer(playerid,SpeedO[playerid]);
    }

// bottom
public Speed()
{
    for(new i=0;i<MAX_PLAYERS;i++)
    {
       
        if(IsPlayerConnected(i))
        {
            GetVehiclePos(GetPlayerVehicleID(i), CurPos[i][1], CurPos[i][2], CurPos[i][3]);
           
          new Float:A = OldPos[i][1] - CurPos[i][1];
          if(A < 0.0) A = -A;
          new Float:B = OldPos[i][2] - CurPos[i][2];
          if(B < 0.0) B = -B;
          new Float:C = OldPos[i][3] - CurPos[i][3];
          if(C < 0.0) C = -C;
            new Float:sp = A + B + C;
            sp *= 2;
            new VehSpeed[128];
            format(VehSpeed, sizeof(VehSpeed), "~w~%0.0f MPH", sp);
            if(IsPlayerInAnyVehicle(i))
            {
                TextDrawHideForPlayer(i,SpeedO[i]);
                    SpeedO[i] = TextDrawCreate(625.000000,415.000000,VehSpeed);
                    TextDrawAlignment(SpeedO[i],3);
                    TextDrawBackgroundColor(SpeedO[i],0x000000ff);
                    TextDrawFont(SpeedO[i],2);
                    TextDrawLetterSize(SpeedO[i],0.299999,1.100000);
                    TextDrawColor(SpeedO[i],0xffffffff);
                    TextDrawSetOutline(SpeedO[i],1);
                    TextDrawSetProportional(SpeedO[i],1);
                    TextDrawSetShadow(SpeedO[i],1);
                    TextDrawShowForPlayer(i,SpeedO[i]);
            }
            GetVehiclePos(GetPlayerVehicleID(i), OldPos[i][1], OldPos[i][2], OldPos[i][3]);
        }
    }
}
that's only for 1 textdraw out of 3... they all randomly stop showing after a while of being in the server.

Any Help Please!!
Reply
#2

Why do you have
pawn Код:
// keystae chnage
if (oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
  TextDrawShowForPlayer(playerid,SpeedO[playerid]);
}
if (oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT)
{
  TextDrawHideForPlayer(playerid,SpeedO[playerid]);
}
in OnPlayerKeyStateChange?
Reply
#3

oops meant just state change.....

EDIT: fixed it.

So anyone Know whats wrong?
Reply
#4

anyone i think its the textdraws, because others went showing up.... after a while n textdraws will show... and ideas?
Reply
#5

ok but how often should i set the timer to refresh? and also i have a total of 3 diff textdraws should i refresh them all on 1 timer or 3 diff timers?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)