problem with timer
#1

count++ not working good

new MineCount = 0;

Код:
CMD:placemine(playerid,params[])
{
	new Float:MineX,Float:MineY,Float:MineZ;
	if(MinePlaced[playerid] == 1)
	return SendClientMessage(playerid,COLOR_INDIANRED,"You have already place a mine somewhere.");
	GetPlayerPos(playerid,MineX,MineY,MineZ);
	CreateObject(1252,MineX,MineY,MineZ-1,0.0, 0.0, 96.0);
	for(new i = 0; i < MAX_PLAYERS; i++)
	MineLabel[i] = CreatePlayer3DTextLabel(i,"MINE HERE",COLOR_INDIANRED, MineX, MineY, MineZ,20.0);
 	MinePos[playerid][0] = MineX;
  	MinePos[playerid][1] = MineY;
   	MinePos[playerid][2] = MineZ;
	SendClientMessage(playerid,COLOR_PURPLE,"You have placed a mine.");
	SetTimerEx("MineTimer", 1000, true, "d", playerid);
	MinePlaced[playerid] = 1;
	return 1;
}
Код:
forward MineTimer(playerid);
public MineTimer(playerid)
{
	new string[128];
	for(new i = 0; i < MAX_PLAYERS; i++)
	if(IsPlayerInRangeOfPoint(i, 10.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2]))
		{
            MineCount++;
			format(string,sizeof(string),"DANGER!\n %i",MineCount);
			UpdatePlayer3DTextLabelText(i,MineLabel[i], COLOR_RED,string);
		}
	else if(IsPlayerInRangeOfPoint(i, 2.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2]))
		{
		  if(GetPlayerState(i) != PLAYER_STATE_WASTED)
			{
			    if(MineCount == 10)
			    {
					CreateExplosion(MinePos[i][0], MinePos[i][1], MinePos[i][2], 0, 10.0);
					SetPlayerHealth(i,0.0);
					SendClientMessage(i,COLOR_INDIANRED,"You got blown away by a land mine.");
					DestroyObject(1252);
				}
			}
		}
	else
		{
            MineCount = 0;
			format(string,sizeof(string),"MINE HERE\n %i",MineCount);
			UpdatePlayer3DTextLabelText(i,MineLabel[i], COLOR_INDIANRED, string);
		}
	return 1;
}
Reply
#2

The problem is in your code, not in ++.

It's because you used else if, in the order that you did.


My code was terrible, don't use it.


You need to do the check better as well.

Код:
if(distance<=10)
{
    if(distance<=2&&MineCount=10)
    {
        Boom!
    }
    else
    {
        MineCount++;
    }
}
Reply
#3

not working its not updating timer

when i go near its just 1 and not counting to 10
Reply
#4

Check that code.
Reply
#5

Well,i will try anyways ty for help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)