[HELP]TextDraw Problem[HELP]!!!
#1

So,I am making a speed system for vehicles,but the problem is that when I enter a car the speed bar doesn't shoow up,here's the code:

pawn Код:
forward UpdateSpeed(playerid);
new uSpeed;

new Text:vSpeed;

stock GetPlayerSpeed(playerid, bool:kmh = true)
{
    new
        Float:xx,
        Float:yy,
        Float:zz,
        Float:pSpeed;

    if(IsPlayerInAnyVehicle(playerid))
    {
        GetVehicleVelocity(GetPlayerVehicleID(playerid),xx,yy,zz);
    }
    else
    {
        GetPlayerVelocity(playerid,xx,yy,zz);
    }

    pSpeed  = floatsqroot((xx * xx) + (yy * yy) + (zz * zz));
    return kmh ? floatround((pSpeed * 195.12)) : floatround((pSpeed * 136.66667));
}//WARNING:This works for vehicle also,event if the name of the function is not relevant :P

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
      new vString[128];
      format(vString,sizeof(vString),"Speed:%d",GetPlayerSpeed(playerid));
      new Float:x,Float:y;
      vSpeed = TextDrawCreate(x,y,vString);
      TextDrawAlignment(vSpeed,3);
      TextDrawColor(vSpeed,COLOR_WHITE);
      TextDrawFont(vSpeed,0);
      TextDrawShowForPlayer(playerid,vSpeed);
      uSpeed = SetTimer("UpdateSpeed",1000,true);
          if(oldstate == PLAYER_STATE_DRIVER&&newstate==PLAYER_STATE_ONFOOT)
         {
        TextDrawDestroy(vSpeed);
        KillTimer(uSpeed);
     }
   }
   return 1;
}

public UpdateSpeed(playerid)
{
      new vString[128];
      format(vString,sizeof(vString),"Speed:%d",GetPlayerSpeed(playerid));
      new Float:x,Float:y;
      vSpeed = TextDrawCreate(x,y,vString);
      TextDrawAlignment(vSpeed,3);
      TextDrawColor(vSpeed,COLOR_WHITE);
      TextDrawFont(vSpeed,0);
      TextDrawShowForPlayer(playerid,vSpeed);
      return 1;
}
Sp,that's all?Can anyone tell me why isn't working?Please help me asap.Thanks in advance.
Reply


Messages In This Thread
[HELP]TextDraw Problem[HELP]!!! - by Cjgogo - 10.07.2012, 08:08
Re: [HELP]TextDraw Problem[HELP]!!! - by SomebodyAndMe - 10.07.2012, 08:11
Re: [HELP]TextDraw Problem[HELP]!!! - by Cjgogo - 10.07.2012, 08:28
Re: [HELP]TextDraw Problem[HELP]!!! - by Vince - 10.07.2012, 08:31
Re: [HELP]TextDraw Problem[HELP]!!! - by Cjgogo - 10.07.2012, 08:38
Re: [HELP]TextDraw Problem[HELP]!!! - by Cjgogo - 11.07.2012, 07:47
Re: [HELP]TextDraw Problem[HELP]!!! - by [MM]RoXoR[FS] - 11.07.2012, 10:32

Forum Jump:


Users browsing this thread: 1 Guest(s)