29.03.2009, 23:09
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:
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!!
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]);
}
}
}
Any Help Please!!