Timer not working properly - 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)
+--- Thread: Timer not working properly (
/showthread.php?tid=594589)
Timer not working properly -
SystemX - 20.11.2015
I'm actually having problem with timer. This Timer given below is not showing player count down textdraws nor it is playing sound. Only SpawnTDMPlayers(); function is working.
One more thing that I would like to add is that IsPlayerInEvent(i); function is
working, As I'm using it in other places also.
Things that are not working are-
Код:
for(new i=0;i<=MAX_PLAYERS;i++)
{
if(IsPlayerInEvent(i))
{
TogglePlayerControllable(i, false);
new str[129];
format(str,129,"%d seconds",countd);
PlayerTextDrawShow(i,Count_TXD[i][0]);
PlayerTextDrawShow(i,Count_TXD[i][1]);
PlayerTextDrawShow(i,Count_TXD[i][2]);
PlayerTextDrawShow(i,Count_TXD[i][3]);
PlayerTextDrawSetString(i, Count_TXD[i][1],str);
new Float:x,Float:y,Float:z;
GetPlayerPos(i,x,y,z);
PlayerPlaySound(i,1054, x,y,z);
}
}
I'm using Variable instead of KillTimer, as sometimes it doesn't work
Код:
forward countdown();
public countdown()
{
countd--;
if(event_type==TDM)
{
if(countd==0)
{
for(new i=0;i<=MAX_PLAYERS;i++)
{
if(IsPlayerInEvent(i))
{
PlayerTextDrawHide(i,Count_TXD[i][0]);
PlayerTextDrawHide(i,Count_TXD[i][1]);
PlayerTextDrawHide(i,Count_TXD[i][2]);
PlayerTextDrawHide(i,Count_TXD[i][3]);
TogglePlayerControllable(i, true);
PlayerTextDrawShow(i,TDM_TXD[i][0]);
PlayerTextDrawShow(i,TDM_TXD[i][1]);
PlayerTextDrawShow(i,TDM_TXD[i][2]);
PlayerTextDrawShow(i,TDM_TXD[i][3]);
PlayerTextDrawShow(i,TDM_TXD[i][4]);
}
}
countd=15;
cd_timer=0;
}
else if(countd<6)
{
if(countd==5)
{
SpawnTDMPlayers();
}
cd_timer=1;
for(new i=0;i<=MAX_PLAYERS;i++)
{
if(IsPlayerInEvent(i))
{
TogglePlayerControllable(i, false);
new str[129];
format(str,129,"%d seconds",countd);
PlayerTextDrawShow(i,Count_TXD[i][0]);
PlayerTextDrawShow(i,Count_TXD[i][1]);
PlayerTextDrawShow(i,Count_TXD[i][2]);
PlayerTextDrawShow(i,Count_TXD[i][3]);
PlayerTextDrawSetString(i, Count_TXD[i][1],str);
new Float:x,Float:y,Float:z;
GetPlayerPos(i,x,y,z);
PlayerPlaySound(i,1054, x,y,z);
}
}
}
}
if(cd_timer=1)
{
SetTimer("countdown",1000,0);
}
}