18.01.2013, 17:09
So i use OnPlayerUpdate() to update a speedometer and a fuel indicator. But after some time it just stop working , The TextDraw just disapear and won't show again until i restart my server.
This is what i have on OnPlayerUpdate();
This is what i have on OnPlayerUpdate();
PHP код:
new Float:fPos[3],Float:Pos[4][2],Float:fSpeed;
new vehicle = GetPlayerVehicleID(playerid);
new string2[64];
if(IsPlayerInAnyVehicle(playerid))
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
format(string2,sizeof(string2),"F:%d",CarFuel[vehicle]);
TextDrawSetString(FuelTextDraw[playerid], string2);
new distance = GetDistance1(x, y, z, PlayerPos[0][playerid], PlayerPos[1][playerid], PlayerPos[2][playerid]);
PlayerPos[0][playerid] = x;
PlayerPos[1][playerid] = y;
PlayerPos[2][playerid] = z;
PlayerTotalDistance[playerid] += distance;
if (PlayerTotalDistance[playerid] > DISTANCE) {
CarFuel[vehicle] -= FUEL_INCREMENT;
PlayerTotalDistance[playerid] = 0;
}
if (CarFuel[vehicle] < 0) {
SendClientMessage(playerid, -1, "You have been forced out your vehicle because you have no gas!");
RemovePlayerFromVehicle(playerid);
}
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetVehicleVelocity(GetPlayerVehicleID(playerid), fPos[0], fPos[1], fPos[2]);
fSpeed = floatsqroot(floatpower(fPos[0], 2) + floatpower(fPos[1], 2) +
floatpower(fPos[2], 2)) * 200;
new Float:alpha = 320 - fSpeed;
if(alpha < 60)
alpha = 60;
for(new i; i < 4; i++)
{
TextDrawHideForPlayer(playerid, TextDrawsd[playerid][i]);
TextDrawDestroy(TextDrawsd[playerid][i]);
GetDotXY(548, 401, Pos[i][0], Pos[i][1], alpha, (i + 1) * 8);
TextDrawsd[playerid][i] = TextDrawCreate(Pos[i][0], Pos[i][1], "~b~.");
TextDrawLetterSize(TextDrawsd[playerid][i], 0.73, -2.60);
TextDrawSetOutline(TextDrawsd[playerid][i], 0);
TextDrawSetShadow(TextDrawsd[playerid][i], 1);
TextDrawShowForPlayer(playerid, TextDrawsd[playerid][i]);
}
}
return 1;