Airport Security
#1

Hey guys, so I am making a system where you need to type a command to get into the airport, and it checks the player for a drivers license, flying license and other things (Still in the works command is not 100% complete)

here is the code for the command

Код:
CMD:checkme(playerid, params[])
{
	if(!IsPlayerInRangeOfPoint(playerid, 5.0, 1960.4540,-2188.0190,13.5469))
	{
	    SendClientMessage(playerid, COLOR_RED, "You are not near the airport!");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_GREEN, "Please wait while the airport security checks your vehicle and registration.");
		if(PlayerInfo[playerid][pCarLic] != 1)
		{
		    if(PlayerInfo[playerid][pSex] == 1)
		    {
				SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a drivers license, the police have been informed and are on their way.");
			}
			else
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a drivers license, the police have been informed and are on their way.");
			}
		}
		else if(PlayerInfo[playerid][pFlyLic] != 1)
		{
			if(PlayerInfo[playerid][pSex] == 1)
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a flying license, the police have been informed and are on their way to question you.");
			}
			else
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a flying license, the police have been informed and are on their way to question you.");
			}
		}
		else
		{
		    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ok, you are free to enter the airport, have a wonderful day!(Gate will close in 6 seconds.)");
			SetTimeer("AirportGate", 6000, false);
		}
	}
	return 1;
}
But I want a timer to go off after each check like when it checks their license it make them wait a couple seconds then it goes to the next part.

Also the gate system, I am trying to have it open the gate for 6 seconds and then close to reset the command.

public for the gate

Код:
public AirportGate()
{
	MoveDynamicObject(1095, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0);
}
I got to here, and then I was confused on how I would set up a timer.

If you see anything wrong or have any help it is much appreciated!
Reply
#2

Check out this wiki page https://sampwiki.blast.hk/wiki/SetTimer if you haven't already.
From what I see, your code will open the gate but not close it. To close it, add another timer after MoveDynamicObject and lead it to another public method moving it back to it's original location, or use a global boolean to check if it is open or closed and toggle that. Note that you will need to add another timer in to close it, something like this could work:
Код:
public AirportGate()
{
	if(!GateOpened)
	{
		MoveDynamicObject(1095, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0); //opened location
		SetTimer("AirportGate", 6000, false);
		GateOpened = true;
	}
	else
	{
		MoveDynamicObject(1095, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0); //closed location
		GateOpened = false;
	}
}
Reply
#3

Quote:
Originally Posted by BlackSirrah239
Посмотреть сообщение
Check out this wiki page https://sampwiki.blast.hk/wiki/SetTimer if you haven't already.
From what I see, your code will open the gate but not close it. To close it, add another timer after MoveDynamicObject and lead it to another public method moving it back to it's original location, or use a global boolean to check if it is open or closed and toggle that. Note that you will need to add another timer in to close it, something like this could work:
Код:
public AirportGate()
{
	if(!GateOpened)
	{
		MoveDynamicObject(1095, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0); //opened location
		SetTimer("AirportGate", 6000, false);
		GateOpened = true;
	}
	else
	{
		MoveDynamicObject(1095, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0); //closed location
		GateOpened = false;
	}
}
Yea I did look at the wiki post about it, didn't help much. But reading yours I do see it a lot better. I also ask, how would I get the id of the object, new to the public making and this part of it all.
Reply
#4

Код:
/* Wherever the object is created */
new GateObject = CreateDynamicObject(1095, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 200.0);

public AirportGate()
{
	if(!GateOpened)
	{
		MoveDynamicObject(GateObject, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0); //opened location
		SetTimer("AirportGate", 6000, false);
		GateOpened = true;
	}
	else
	{
		MoveDynamicObject(GateObject, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0); //closed location
		GateOpened = false;
	}
}
Reply
#5

Quote:
Originally Posted by BlackSirrah239
Посмотреть сообщение
Код:
/* Wherever the object is created */
new GateObject = CreateDynamicObject(1095, Float:x, Float:y, Float:z, Float:rx, Float:ry, Float:rz, worldid = -1, interiorid = -1, playerid = -1, Float:streamdistance = 200.0);

public AirportGate()
{
	if(!GateOpened)
	{
		MoveDynamicObject(GateObject, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0); //opened location
		SetTimer("AirportGate", 6000, false);
		GateOpened = true;
	}
	else
	{
		MoveDynamicObject(GateObject, 0.0, 0.0, 0.0, 1, 90.0, 0.0, 0.0); //closed location
		GateOpened = false;
	}
}
Ok, i altered what you did and got this

Код:
CMD:checkme(playerid, params[])
{
	if(!IsPlayerInRangeOfPoint(playerid, 10.0, 1960.4540,-2188.0190,13.5469))
	{
	    SendClientMessage(playerid, COLOR_RED, "You are not near the airport!");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_GREEN, "Please wait while the airport security checks your vehicle and registration.");
		if(PlayerInfo[playerid][pCarLic] != 1)
		{
		    if(PlayerInfo[playerid][pSex] == 1)
		    {
				SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a drivers license, the police have been informed and are on their way.");
			}
			else
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a drivers license, the police have been informed and are on their way.");
			}
		}
		else if(PlayerInfo[playerid][pFlyLic] != 1)
		{
			if(PlayerInfo[playerid][pSex] == 1)
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a flying license, the police have been informed and are on their way to question you.");
			}
			else
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a flying license, the police have been informed and are on their way to question you.");
			}
		}
		else
		{
		    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ok, you are free to enter the airport, have a wonderful day!(Gate will close in 6 seconds.)");
		    SetTimer("AirportGate", 200, 0);
			MoveDynamicObject(GateObject, 1956.54541, -2189.80908, 13.32070,   0.00000, 0.00000, 0.00000);
		}
	}
	return 1;
}
public AirportGate(playerid)
{
	MoveDynamicObject(GateObject, 1956.54541, -2189.80908, 13.32070,   0.00000, 90.00000, 0.00000);
}
But the gate doesn't move when the command is used, any ideas?
Reply
#6

Quote:
Originally Posted by KtotheYle
Посмотреть сообщение
Ok, i altered what you did and got this

Код:
CMD:checkme(playerid, params[])
{
	if(!IsPlayerInRangeOfPoint(playerid, 10.0, 1960.4540,-2188.0190,13.5469))
	{
	    SendClientMessage(playerid, COLOR_RED, "You are not near the airport!");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_GREEN, "Please wait while the airport security checks your vehicle and registration.");
		if(PlayerInfo[playerid][pCarLic] != 1)
		{
		    if(PlayerInfo[playerid][pSex] == 1)
		    {
				SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a drivers license, the police have been informed and are on their way.");
			}
			else
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a drivers license, the police have been informed and are on their way.");
			}
		}
		else if(PlayerInfo[playerid][pFlyLic] != 1)
		{
			if(PlayerInfo[playerid][pSex] == 1)
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a flying license, the police have been informed and are on their way to question you.");
			}
			else
			{
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a flying license, the police have been informed and are on their way to question you.");
			}
		}
		else
		{
		    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ok, you are free to enter the airport, have a wonderful day!(Gate will close in 6 seconds.)");
		    SetTimer("AirportGate", 200, 0);
			MoveDynamicObject(GateObject, 1956.54541, -2189.80908, 13.32070,   0.00000, 0.00000, 0.00000);
		}
	}
	return 1;
}
public AirportGate(playerid)
{
	MoveDynamicObject(GateObject, 1956.54541, -2189.80908, 13.32070,   0.00000, 90.00000, 0.00000);
}
But the gate doesn't move when the command is used, any ideas?
Try this:
Код:
CMD:checkme(playerid, params[])
{
	if(!IsPlayerInRangeOfPoint(playerid, 10.0, 1960.4540,-2188.0190,13.5469))
	{
	    SendClientMessage(playerid, COLOR_RED, "You are not near the airport!");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_GREEN, "Please wait while the airport security checks your vehicle and registration.");
		if(PlayerInfo[playerid][pCarLic] != 1)
		{
		    switch(PlayerInfo[playerid][pSex])
		    {
		    	case 1:
				SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a drivers license, the police have been informed and are on their way.");
				case 2:
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a drivers license, the police have been informed and are on their way.");
			}
		}
		else if(PlayerInfo[playerid][pFlyLic] != 1)
		{
			switch(PlayerInfo[playerid][pSex])
		    {
		    	case 1:
				SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a flying license, the police have been informed and are on their way.");
				case 2:
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a flying license, the police have been informed and are on their way.");
			}
		}
		else
		{
		    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ok, you are free to enter the airport, have a wonderful day!(Gate will close in 6 seconds.)");
		    SetTimer("AirportGate", 200, 0);
			MoveDynamicObject(GateObject, 1956.54541, -2189.80908, 13.32070, 3.0,  0.00000, 0.00000, 0.00000);
			/*
			 * MoveDynamicObject(objectid, Float:x, Float:y, Float:z, Float:speed, Float:rx = -1000.0, Float:ry = -1000.0, Float:rz = -1000.0);
			 * I noticed you forgot the speed, so it assumed the speed of 0.00000 (which I assume you meant for x rotation)
			 * check out https://sampforum.blast.hk/showthread.php?tid=102865 for more info.
			 */
		}
	}
	return 1;
}
public AirportGate()
{
	MoveDynamicObject(GateObject, 1956.54541, -2189.80908, 13.32070, 3.0,  0.00000, 90.00000, 0.00000); //The gate will not close as this is the same position. Change these coords.
}
EDIT: I assumed you were using an NGRP variant with pSex, hence it switches between 1 and 2.
Reply
#7

Quote:
Originally Posted by BlackSirrah239
Посмотреть сообщение
Try this:
Код:
CMD:checkme(playerid, params[])
{
	if(!IsPlayerInRangeOfPoint(playerid, 10.0, 1960.4540,-2188.0190,13.5469))
	{
	    SendClientMessage(playerid, COLOR_RED, "You are not near the airport!");
	}
	else
	{
	    SendClientMessage(playerid, COLOR_GREEN, "Please wait while the airport security checks your vehicle and registration.");
		if(PlayerInfo[playerid][pCarLic] != 1)
		{
		    switch(PlayerInfo[playerid][pSex])
		    {
		    	case 1:
				SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a drivers license, the police have been informed and are on their way.");
				case 2:
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a drivers license, the police have been informed and are on their way.");
			}
		}
		else if(PlayerInfo[playerid][pFlyLic] != 1)
		{
			switch(PlayerInfo[playerid][pSex])
		    {
		    	case 1:
				SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Sir, you do not have a flying license, the police have been informed and are on their way.");
				case 2:
			    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ma'am, you do not have a flying license, the police have been informed and are on their way.");
			}
		}
		else
		{
		    SendClientMessage(playerid, COLOR_WHITE, "Secruity Guard: Ok, you are free to enter the airport, have a wonderful day!(Gate will close in 6 seconds.)");
		    SetTimer("AirportGate", 200, 0);
			MoveDynamicObject(GateObject, 1956.54541, -2189.80908, 13.32070, 3.0,  0.00000, 0.00000, 0.00000);
			/*
			 * MoveDynamicObject(objectid, Float:x, Float:y, Float:z, Float:speed, Float:rx = -1000.0, Float:ry = -1000.0, Float:rz = -1000.0);
			 * I noticed you forgot the speed, so it assumed the speed of 0.00000 (which I assume you meant for x rotation)
			 * check out https://sampforum.blast.hk/showthread.php?tid=102865 for more info.
			 */
		}
	}
	return 1;
}
public AirportGate()
{
	MoveDynamicObject(GateObject, 1956.54541, -2189.80908, 13.32070, 3.0,  0.00000, 90.00000, 0.00000); //The gate will not close as this is the same position. Change these coords.
}
EDIT: I assumed you were using an NGRP variant with pSex, hence it switches between 1 and 2.
No actually, custom script, made by a friend but no doubt using stuff from NGRP, either way worked! so thanks man!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)