21.08.2010, 16:51
So, I've got this script from another post on this forum and modified it so that only players in 10 meters range can see the timer but there is a problem with it. When only the user is in the set range (10m) the countdown works perfectly, but when someone else is in the radius it freaks out. Like one gets 2 then go and the other one gets 3,1 and go. I tried anything I could possibly think of so now I decided to look for some help here. Thanks in advance for those who decide to give me a hand.
pawn Код:
#define FILTERSCRIPT
#include <a_samp>
new Counter;
new Float:X,Float:Y,Float:Z;
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
Counter = 0;
return 1;
}
public OnFilterScriptExit()
{
Counter = 0;
return 1;
}
#else
main()
{
print("\n------------------------------------------");
print(" Countdown");
print("------------------------------------------\n");
}
#endif
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/countdown", true))
{
GetPlayerPos(playerid,X,Y,Z);
if(Counter != 0) return SendClientMessage(playerid,0x004BFFFF, "ERROR: /countdown is already in use, Try again in a few seconds.");
Counter = 3;
Timer();
return 1;
}
return 0;
}
forward Timer();
public Timer()
{
new String[64];
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(IsPlayerInRangeOfPoint(i,10,X,Y,Z))
{
if(Counter== 0)
{
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
GameTextForPlayer(i,"~g~~h~Go Go Go !!", 2000, 5);
TogglePlayerControllable(i,1);
return 1;
}
format(String,sizeof(String),"~r~~h~%d",Counter);
GameTextForPlayer(i,String, 800, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
TogglePlayerControllable(i,0);
Counter--;
SetTimer("Timer", 1000, false);
}
}
return 0;
}