Questions to nested if-else statements, how to realise that? Read..
#1

Ahoy friends..

This command is part of my latest release Last Bed Standing, but i want to improve something.

Thats the command to /blow an enemies bed up, a bed of another team.
The problem is: You can even blow up the bed of your own team but now i want to avoid that, but unfortunately i dont know how because its a complicated situation.

Код:
if(strcmp(cmdtext, "/blowup", true) == 0)
	{
		for(new i = 0; i < sizeof(beds[]); i++)
		{
			new Float:health;
			GetPlayerHealth(playerid,health);

			if(running !=1 && IsPlayerInRangeOfPoint(playerid,10.0,beds[i][0],beds[i][1],beds[i][2]) && health > 0 && !IsPlayerInAnyVehicle(playerid)) // In this script we deal with players only
			{
				running = 1;


				if(i == 0 && bedstateviolet !=-1 )
				{
					bedstateviolet=-1;
					SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team {610D96}VIOLET");
				}
				if(i == 1 && bedstatebrown !=-1 )
				{
					bedstatebrown=-1;
					SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team {8B4513}BROWN");
				}
				if(i == 2 && bedstateyellow !=-1 )
				{
					bedstateyellow=-1;
					SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are blowing up the bed of Team {FFFF00}YELLOW");
				}
				
					SendClientMessage(playerid, COLOR_WHITE, "SERVER: Planted Bomb Successfully. Lets Blow This Bed Up!");
					SetPlayerScore(playerid, GetPlayerScore(playerid) + 1);
					SendClientMessage(playerid, COLOR_WHITE, "SERVER: Keep Running! Bed Will Blow Up In 5 seconds!");
					GetPlayerPos(playerid, x1, y1, z1);
					ApplyAnimation(playerid, "BOMBER", "BOM_Plant_Loop", 4.0, 1, 0, 0, 1, 1);
					for(new k = 0; k < MAX_PLAYERS; k++)
					{
						PlayerPlaySound(k,7416,x1,y1,z1);
					}
					SetTimer("BlowUpThisBed", bombtimer, false);
					CountDownTimer = SetTimer("CountDown", 1000, true);
					new Float:dist = GetDistance(beds[i][0],beds[i][1],beds[i][2],x1,y1,z1);
					printf("Distance to closest bed: %f, Index: %d", dist, i);
				
				

				return 1;

			}



		}
		return 0;

	}
The player team is set with gPlayerTeamSelection[playerid] = TEAM_EXAMPLE
So the player should be able to blow up a bed if the bed doesnt belong to its team.


There are 3 Teams.
TEAM_VIOLET, TEAM_YELLOW TEAM_BROWN
The array which is necessary to locate the closest bed for this command

Код:
new const Float:beds[][3] = {
	{-2340.7637,-2024.7919,270.5094},//VIOLET
	{-2812.6035,-1515.9814,140.8438},//Brown
	{-2326.8735,-1356.4872,300.2661}//Yellow
};
i == 0 // Bed of TEAM_VIOLET
i == 1 // Bed of TEAM_BROWN
i == 2 // Bed of TEAM_YELLOW

So im searching for some help because i dont know how to realise that without changing absolutely everything!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)