Why will this not work. -
BP13 - 11.01.2010
This works perfectly:
pawn Код:
public timer2()
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i, 80.0, -3362.7395,-75.1055,14.1891) && ISADMIN[i] == false)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(i,X,Y,Z);
CreateExplosion(X, Y , Z, 7, 10.0);
}
}
}
return 1;
}
But I like to use little timers. So I combined all of my things that need a timer together. Every single one of the things work except the "Second5" one that should be equivalent with the timer above.
pawn Код:
public MasterTimer() //This is on a one second timer.
{
Second ++;
Second2 ++;
Second3 ++;
Second4 ++;
Second5 ++;
if(Second == 1) // 1 Second
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
// Gate3 (Cage) U
if(IsPlayerInRangeOfPoint(i, 5.0, -423.6993, 2201.7231, 40.9262) && OpenGateCage[i] == false) // Close --> Open
{
OpenGateCage[i] = true;
MoveDynamicObject(Gate3, -423.692413, 2201.705811, 50.923096, 10.0);
MoveDynamicObject(Gate4, -423.686127, 2206.743164, 45.926369, 10.0);
MoveDynamicObject(Gate5, -418.655365, 2201.730713, 45.926369, 10.0);
MoveDynamicObject(Gate6, -423.685608, 2196.700928, 45.913692, 10.0);
MoveDynamicObject(Gate7, -428.733124, 2201.718506, 45.926338, 10.0);
}
else if(!IsPlayerInRangeOfPoint(i, 5.0, -423.699341, 2201.723145, 40.926292) && OpenGateCage[i] == true) // Open --> Close
{
OpenGateCage[i] = false;
MoveDynamicObject(Gate3, -423.692413, 2201.705811, 59.923141, 1.5);
MoveDynamicObject(Gate4, -423.686127, 2215.716309, 45.926369, 1.5);
MoveDynamicObject(Gate5, -409.680603, 2201.730713, 45.926369, 1.5);
MoveDynamicObject(Gate6, -423.685608, 2187.702881, 45.913692, 1.5);
MoveDynamicObject(Gate7, -437.683075, 2201.718506, 45.926338, 1.5);
}
Second = 0;
}
}
if(Second2 == 180)
{
SendClientMessageToAll(COLOR_ORANGE, RandMessages[random(sizeof(RandMessages))]);
Second2 = 0;
}
if(Second3 == 138)
{
DestroyDynamicObject(PirateObject2);
PirateObject1 = CreateDynamicObject(8493, 3751.8791503906, 1508.7846679688, 14.907380104065, 0.000000, 0.000000, 180,0,0,-1); //
MoveDynamicObject(PirateObject1, 3752.7321777344, 1203.7044677734, 14.907380104065, 2.00 );
}
if(Second3 == 276)
{
DestroyDynamicObject(PirateObject1);
PirateObject2 = CreateDynamicObject(8493, 3752.7321777344, 1203.7044677734, 14.907380104065, 0.000000, 0.000000, 0.000000,0,0,-1); //
MoveDynamicObject(PirateObject2, 3751.8791503906, 1508.7846679688, 14.907380104065, 2.00);
Second3 = 0;
}
if(Second4 == 120)
{
new var0 = 0, var1 = 0;
function25C(var0, var1);
for(new var2 = 0; var2 < 4; var2++)
{
if(IsPlayerConnected(var2))
{
SetPlayerTime(var2, var0, var1);
}
}
Second4 = 0;
}
if(Second5 == 2) //The only one that does not work.
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i, 80.0, -3362.7395,-75.1055,14.1891) && ISADMIN[i] == false)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(i,X,Y,Z);
CreateExplosion(X, Y , Z, 7, 10.0);
}
Second5 = 0;
}
}
}
}
return 1;
}
Re: Why will this not work. -
mansonh - 11.01.2010
You try to redefine i which has previously been defined, not sure why it isn't throwing an error in your compiler.
Try using a different variable.
pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
// Gate3 (Cage) U
if(IsPlayerInRangeOfPoint(i, 5.0, -423.6993, 2201.7231, 40.9262) && OpenGateCage[i] == false) // Close --> Open
{
OpenGateCage[i] = true;
MoveDynamicObject(Gate3, -423.692413, 2201.705811, 50.923096, 10.0);
MoveDynamicObject(Gate4, -423.686127, 2206.743164, 45.926369, 10.0);
MoveDynamicObject(Gate5, -418.655365, 2201.730713, 45.926369, 10.0);
MoveDynamicObject(Gate6, -423.685608, 2196.700928, 45.913692, 10.0);
MoveDynamicObject(Gate7, -428.733124, 2201.718506, 45.926338, 10.0);
}
else if(!IsPlayerInRangeOfPoint(i, 5.0, -423.699341, 2201.723145, 40.926292) && OpenGateCage[i] == true) // Open --> Close
{
OpenGateCage[i] = false;
MoveDynamicObject(Gate3, -423.692413, 2201.705811, 59.923141, 1.5);
MoveDynamicObject(Gate4, -423.686127, 2215.716309, 45.926369, 1.5);
MoveDynamicObject(Gate5, -409.680603, 2201.730713, 45.926369, 1.5);
MoveDynamicObject(Gate6, -423.685608, 2187.702881, 45.913692, 1.5);
MoveDynamicObject(Gate7, -437.683075, 2201.718506, 45.926338, 1.5);
}
Second = 0;
}
}
...
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i, 80.0, -3362.7395,-75.1055,14.1891) && ISADMIN[i] == false)
{
new Float:X, Float:Y, Float:Z;
GetPlayerPos(i,X,Y,Z);
CreateExplosion(X, Y , Z, 7, 10.0);
}
Second5 = 0;
}
}
Re: Why will this not work. -
Joe Staff - 11.01.2010
Also note that multiple smaller timers running at different times is better than 1 big fat timer. The server will update between timers but can't if there's just 1 fat timer, so you'll end up with lag spikes.
Although frankly in your case it doesn't really matter.