Mine bomb script probem
#1

Well this script detects if a player is near the mine and then start counting from 1 to 10 and when it reaches 10 then it blows and resets but its not working,i got problem with timers


Код:
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);
	MineObject = 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.");
    MineTimerUpdate[playerid] = SetTimer("MineTimer", 1000, true);
	MinePlaced[playerid] = 1;
	return 1;
}
Код:
forward MineTimer(playerid);
public MineTimer(playerid)
{
	new string[64];
	for(new i = 0; i < MAX_PLAYERS; i++)
    if(IsPlayerInRangeOfPoint(i, 2.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2]) || MineCount[i] >= 10)
	{
       if(GetPlayerState(i) != PLAYER_STATE_WASTED)
         {
            CreateExplosion(MinePos[i][0], MinePos[i][1], MinePos[i][2], 7, 25.0);
            SendClientMessage(i,COLOR_INDIANRED,"You got blown away by a land mine.");
 			DestroyObject(MineObject);
 			KillTimer(MineTimerUpdate[i]);
 			KillTimer(MineCountUpdate[i]);
 			DeletePlayer3DTextLabel(i,MineLabel[i]);
 			MinePlaced[i] = 0;
 			MineCount[i] = 0;
		 }
	}
	else if(IsPlayerInRangeOfPoint(i, 10.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2]))
	{
		MineCountUpdate[i] = SetTimerEx("MineCounting",1000,true,"i",i);
		format(string,sizeof(string),"DANGER!\n %i",MineCount);
		UpdatePlayer3DTextLabelText(i,MineLabel[i], COLOR_RED,string);
	}
	else
	{
		MineCount[i] = 0;
		format(string,sizeof(string),"MINE HERE");
		UpdatePlayer3DTextLabelText(i,MineLabel[i], COLOR_INDIANRED, string);
		KillTimer(MineCountUpdate[i]);
	}
	return 1;
}

forward MineCounting(playerid);
public MineCounting(playerid)
{
	MineCount[playerid]++;
}
Reply
#2

Код:
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);
	MineObject = 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.");
    MineTimerUpdate[playerid] = SetTimerEx("MineTimer", 1000, true, "i", playerid);
	MinePlaced[playerid] = 1;
	return 1;
}
That's how you're going to do it, with SetTimerEx... Also your MineTimer func needs a little edit. The honest truth is that there are a lot of things that are wrong but since you only mentioned that there is a timer problem, I got it solved for you, the rest is on you.
Reply
#3

Quote:
Originally Posted by Cypress
Посмотреть сообщение
Код:
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);
	MineObject = 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.");
    MineTimerUpdate[playerid] = SetTimerEx("MineTimer", 1000, true, "i", playerid);
	MinePlaced[playerid] = 1;
	return 1;
}
That's how you're going to do it, with SetTimerEx... Also your MineTimer func needs a little edit. The honest truth is that there are a lot of things that are wrong but since you only mentioned that there is a timer problem, I got it solved for you, the rest is on you.
Can you tell what mistakes did i do?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)