Textdraws disappearing / timers - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Textdraws disappearing / timers (
/showthread.php?tid=71111)
Textdraws disappearing / timers -
StrickenKid - 29.03.2009
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!!
Re: Textdraws disappearing / timers -
ICECOLDKILLAK8 - 29.03.2009
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?
Re: Textdraws disappearing / timers -
StrickenKid - 29.03.2009
oops meant just state change.....
EDIT: fixed it.
So anyone Know whats wrong

?
Re: Textdraws disappearing / timers -
StrickenKid - 30.03.2009
anyone

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

?
Re: Textdraws disappearing / timers -
StrickenKid - 30.03.2009
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?