SA-MP Forums Archive
A somewhat of an interesting problem. (Regarding object roadblocks) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: A somewhat of an interesting problem. (Regarding object roadblocks) (/showthread.php?tid=93640)



A somewhat of an interesting problem. (Regarding object roadblocks) - jbtech - 26.08.2009

Hello everyone,

I have yet another problem that I come to the community of SA:MP for support. It is regarding the use of roadblock objects. For those that have played on Los Santos Role Play will understand what I'm talking about. (The little mobile orange barriers).

I have created my own system, but I would like to see what it would take to convert what I have at the moment into something of the following manner.

Where someone would have to use /roadblock and a small menu like this comes up. Which my little bit of coding already has. Then, you have to type the appropriate roadblock ID that you want to deploy, but even after you hit enter, the roadblock won't deploy unless, you put a 1 at the end of the command.

Like so: /roadblock 1 1 to place the roadblock and /roadblock 1 0 to remove the roadblock.

I hope you get what I'm trying to say here.

Here is my little bit of coding that I put together in hopes to create something similar, if someone can lend me their ideas, thoughts, etc., to enhance the coding, it will be GREATLY appreciated! Thanks for visiting.

Код:
	if(strcmp(cmd, "/roadblock", true) == 0)
	{
	  if(IsPlayerConnected(playerid))
	  {
	    if(PlayerInfo[playerid][pFaction] != 255 && IsACop(playerid))
	    {
				if(OnDuty[playerid] == 0)
  			{
	    		SendClientMessage(playerid, COLOR_GREY, "[Error:] Your not on duty.");
	    		return 1;
  			}
	      new x_nr[256];
				x_nr = strtok(cmdtext, idx);
				if(!strlen(x_nr))
				{
				  new text1[20];
			    new text2[20];
			    new text3[20];
			    new text4[20];
			    new text5[20];
				  new text6[20];
			    new text7[20];
			    new text8[20];
			    new text9[20];
			    new text10[20];
					if(Roadblock_One) { text1 = "Inactive"; } else { text1 = "Active"; }
	        if(Roadblock_Two) { text2 = "Inactive"; } else { text2 = "Active"; }
					if(Roadblock_Three) { text3 = "Inactive"; } else { text3 = "Active"; }
	        if(Roadblock_Four) { text4 = "Inactive"; } else { text4 = "Active"; }
					if(Roadblock_Five) { text5 = "Inactive"; } else { text5 = "Active"; }
					if(Roadblock_Six) { text6 = "Inactive"; } else { text6 = "Active"; }
	        if(Roadblock_Seven) { text7 = "Inactive"; } else { text7 = "Active"; }
					if(Roadblock_Eight) { text8 = "Inactive"; } else { text8 = "Active"; }
	        if(Roadblock_Nine) { text9 = "Inactive"; } else { text9 = "Active"; }
					if(Roadblock_Ten) { text10 = "Inactive"; } else { text10 = "Active"; }
					SendClientMessage(giveplayerid, COLOR_GREEN, "(/r)oad(b)lock [Block ID]");
			    format(string, sizeof(string), "Roadblock 1: %s.", text1);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 2: %s.", text2);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 3: %s.", text3);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 4: %s.", text4);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 5: %s.", text5);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 6: %s.", text6);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 7: %s.", text7);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 8: %s.", text8);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 9: %s.", text9);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
			    format(string, sizeof(string), "Roadblock 10: %s.", text10);
					SendClientMessage(giveplayerid, COLOR_WHITE, string);
					return 1;
				}
			  if(strcmp(x_nr,"one",true) == 0)
				{
    			if(Roadblock_One)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_1 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 1 placed successfully.");
						Roadblock_One = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_1, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_One(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 1 removed successfully.");
						}
					}
				}
			  if(strcmp(x_nr,"two",true) == 0)
				{
			    if(Roadblock_Two)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_2 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 2 placed successfully.");
						Roadblock_Two = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_2, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Two(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 2 removed successfully.");
						}
					}
				}
			  if(strcmp(x_nr,"three",true) == 0)
				{
				  if(Roadblock_Three)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_3 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 3 placed successfully.");
						Roadblock_Three = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_3, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Three(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 3 removed successfully.");
						}
					}
				}
			  else if(strcmp(x_nr,"four",true) == 0)
				{
				  if(Roadblock_Four)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_4 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 4 placed successfully.");
						Roadblock_Four = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_4, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Four(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 4 removed successfully.");
						}
					}
				}
			  if(strcmp(x_nr,"five",true) == 0)
				{
				  if(Roadblock_Five)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_5 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 5 placed successfully.");
						Roadblock_Five = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_5, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Five(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 5 removed successfully.");
						}
					}
				}
			  if(strcmp(x_nr,"six",true) == 0)
				{
				  if(Roadblock_Six)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_6 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 6 placed successfully.");
						Roadblock_Six = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_6, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Six(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 6 removed successfully.");
						}
					}
				}
			  if(strcmp(x_nr,"seven",true) == 0)
				{
				  if(Roadblock_Seven)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_7 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 7 placed successfully.");
						Roadblock_Seven = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_7, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Seven(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 7 removed successfully.");
						}
					}
				}
			  if(strcmp(x_nr,"eight",true) == 0)
				{
				  if(Roadblock_Eight)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_8 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 8 placed successfully.");
						Roadblock_Eight = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_8, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Eight(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 8 removed successfully.");
						}
					}
				}
			  if(strcmp(x_nr,"nine",true) == 0)
				{
				  if(Roadblock_Nine)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_9 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 9 placed successfully.");
						Roadblock_Nine = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_9, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Nine(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 9 removed successfully.");
						}
					}
				}
			  if(strcmp(x_nr,"ten",true) == 0)
				{
				  if(Roadblock_Ten)
				  {
						new Float:BlockX, Float:BlockY, Float:BlockZ, Float:BlockA;
						GetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						GetPlayerFacingAngle(playerid, BlockA);
						Roadblock_10 = CreateObject(979, BlockX, BlockY, BlockZ, 0.0, 0.0, BlockA);
						SetPlayerPos(playerid, BlockX, BlockY, BlockZ);
						SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 10 placed successfully.");
						Roadblock_Ten = false;
					}
					else
					{
						new Float:BlockX, Float:BlockY, Float:BlockZ;
						GetObjectPos(Roadblock_10, BlockX, BlockY, BlockZ);
					  if(PlayerToPoint(5, playerid, BlockX, BlockY, BlockZ))
					  {
							RemoveRoadblock_Ten(playerid);
							SendClientMessage(playerid, COLOR_GREEN, "[Info:] Roadblock 10 removed successfully.");
						}
					}
				}
	    }
	  }
	  return 1;
	}
I'm sorry for the messiness of the code, the (code)(/code) function likes to mess things up like commands and such, please bare with it, much appreciated!