Help with my placemine command
#1

The textdraw and progressbar doesn't destroy after i leave the area

Код:
forward MineTimer(playerid);
public MineTimer(playerid)
{
	new string[124];
	new Count2;
	for(new i = 0; i < MAX_PLAYERS; i++)
	if(IsPlayerConnected(i))
	{
	    if(IsPlayerInRangeOfPoint(i, 2.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2]))
		{
	       if(GetPlayerState(i) != PLAYER_STATE_WASTED)
	         {
	            CreateExplosion(MinePos[i][0], MinePos[i][1], MinePos[i][2], 7, 30.0);
	            SendClientMessage(i,COLOR_INDIANRED,"You got blown away by a land mine.");
	 			DestroyObject(MineObject);
	 			DeletePlayer3DTextLabel(i,MineLabel[i]);
	 			MinePlaced[i] = 0;
				KillTimer(MineTimerUpdate[i]);
			 }
		}
		else if(IsPlayerInRangeOfPoint(i, 2.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2]) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
		{
	       if(GetPlayerState(i) != PLAYER_STATE_WASTED)
	         {
	            CreateExplosion(MinePos[i][0], MinePos[i][1], MinePos[i][2], 7, 30.0);
	            SendClientMessage(i,COLOR_INDIANRED,"Your vehicle touched a land mine.");
	 			DestroyObject(MineObject);
	 			DeletePlayer3DTextLabel(i,MineLabel[i]);
	 			MinePlaced[i] = 0;
				KillTimer(MineTimerUpdate[i]);
			 }
		}
		else if(IsPlayerInRangeOfPoint(i, 10.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2]))
		{
			Count2++;
			format(string,sizeof(string),"!DANGER ZONE!\nWatch your steps");
			UpdatePlayer3DTextLabelText(i,MineLabel[i], COLOR_RED,string);
			MineBar[i] = CreatePlayerTextDraw(i, 134.871246, 302.916717, "usebox");
			PlayerTextDrawLetterSize(i, MineBar[i], 0.000000, 1.639824);
			PlayerTextDrawTextSize(i, MineBar[i], 39.698383, 0.000000);
			PlayerTextDrawAlignment(i, MineBar[i], 1);
			PlayerTextDrawColor(i, MineBar[i], 0);
			PlayerTextDrawUseBox(i, MineBar[i], true);
			PlayerTextDrawBoxColor(i, MineBar[i], -570405291);
			PlayerTextDrawSetShadow(i, MineBar[i], 0);
			PlayerTextDrawSetOutline(i, MineBar[i], 0);
			PlayerTextDrawFont(i, MineBar[i], 0);
	        PlayerTextDrawShow(i, MineBar[i]);
	        MineBar2[i] = CreatePlayerProgressBar(i, 45.000000, 305.000000, 88.000000, 12.000000, -16447233, 10.000000, BAR_DIRECTION_RIGHT);
	        ShowPlayerProgressBar(i,MineBar2[i]);
	        SetPlayerProgressBarValue(i, MineBar2[i], Count2);
		}
		else if(!IsPlayerInRangeOfPoint(i, 10.0, MinePos[playerid][0], MinePos[playerid][1], MinePos[playerid][2]))
		{
			format(string,sizeof(string),"MINE HERE");
			UpdatePlayer3DTextLabelText(i,MineLabel[i], COLOR_INDIANRED, string);
			PlayerTextDrawDestroy(i,MineBar[i]);
			DestroyPlayerProgressBar(i,MineBar2[i]);
			
		}
	}
	return 1;
}
Код:
CMD:placemine(playerid,params[])
{
	new Float:MineX,Float:MineY,Float:MineZ;
	new Mine[128],sec;
	new TMine[128];
	if(MinePlaced[playerid] == 1 || TimeBombPlaced[playerid] == 1)
	return SendClientMessage(playerid,COLOR_INDIANRED,"You have already place a mine or bomb somewhere.");
	if(GetPlayerState(playerid) == PLAYER_STATE_WASTED)
	return SendClientMessage(playerid,COLOR_INDIANRED,"You dead bruh.");
	if(sscanf(params,"s[128]",Mine,TMine))
	return SendClientMessage(playerid,COLOR_PAPAYAWHIP,"USAGE: /placemine [Mine]/[TMine]");
	else if(!strcmp(Mine, "Mine", true))
	{
		GetPlayerPos(playerid,MineX,MineY,MineZ);
		MineObject = CreateObject(1252,MineX,MineY,MineZ-1,0.0, 0.0, 96.0);
		MinePos[playerid][0] = MineX;
		MinePos[playerid][1] = MineY;
		MinePos[playerid][2] = MineZ;
		SendClientMessage(playerid,COLOR_PURPLE,"You have placed a mine.");
		MinePlaced[playerid] = 1;
		for(new i = 0; i < MAX_PLAYERS; i++)
		{
			if(IsPlayerConnected(i))
			{
				MineLabel[i] = CreatePlayer3DTextLabel(i,"MINE HERE",COLOR_INDIANRED, MineX, MineY, MineZ,20.0);
				MineTimerUpdate[i] = SetTimerEx("MineTimer", 1000, true,"i",i);
			}
		}
	}
Reply


Messages In This Thread
Help with my placemine command - by Nabster - 23.03.2015, 02:16
Re: Help with my placemine command - by Sew_Sumi - 23.03.2015, 03:12
Re: Help with my placemine command - by Nabster - 23.03.2015, 03:32
Re: Help with my placemine command - by Sew_Sumi - 23.03.2015, 04:20

Forum Jump:


Users browsing this thread: 1 Guest(s)