[Tutorial] Single command multiple task
#1

Hi guys. Today i am going to show you how to make a command to do multiple task by just 1 command.
Before we start learning about what and how it works let me explain where can we use it.

Usage

Firstly, we use it mostly for ENTER and EXIT commands.
Secondly, for multiple timeattack races. Like if you want to start a race by a command. If you are near X point race number 1 will start. If other point race number 2 starts.
Mainly , for doing multiple task but by 1 command.

Let's start by making a simple ENTER command at multiple places.

Step 1

First you need to save 2 type of points. 1 from where the command must be typed. Second to where you must reach after you type the command.
So, get to co-ordinates. I am oping the position of 4 dragons casino and the interior of it.
The co-ordinates are :
Код:
2019.3992,1007.7200,10.8203 // Enter point
2015.4500,1017.0900,996.8750 // Reaching point
Now we have to define the ENTER point to one universal/global Float value.
Код:
new Float:Enter[][] =
{
//This will be our base.
};
Now let us define the co-ordinate.
Код:
new Float:Enter[][] =
{
    {2019.3992,1007.7200,10.8203}
};
Now we will start making our command.

Step 2

COMMAND, our command will be enter. I will use ZCMD here.

Код:
CMD:enter(playerid,params[])
{
        return 1;
}
This is our command base.
As this will be a loop from our global value of enter, we will use for loop.
Код:
CMD:enter(playerid,params[])
{
	for(new i = 0; i < sizeof(Enter);i++)
	{
        
	}
	return 1;
}
It is clear of what's done above. We will go forward now.
For making the command only to be used at the ENTER points. We will use Range Point.
So, we go further adding the condition that if the player is at the enter point he can use the command orelse he/she will receive a message.
Код:
CMD:enter(playerid,params[])
{
	for(new i = 0; i < sizeof(Enter);i++)
	{
        if(IsPlayerInRangeOfPoint(playerid,1.0,Enter[i][0],Enter[i][1], Enter[i][2])) // IF the player is in range of any of the enter points the command goes true. 
        {

        }
        else SendClientMessage(playerid,colorexit,"[ ! ] You must be near a valid enter point!");//If he is not then he will receive this message.
	}
	return 1;
}
Now as we have to define each of the co-ordinates a spawning point, we will use switch case here.
We will switch cases of the global enter value. Remember the first value will start from 0 in our codes. We can change it to start from 1 if we want.
So, the codes for the switch case would be as follow :
Код:
CMD:enter(playerid,params[])
{
	for(new i = 0; i < sizeof(Enter);i++)
	{
        if(IsPlayerInRangeOfPoint(playerid,1.0,Enter[i][0],Enter[i][1], Enter[i][2]))
        {
			switch(i) //Switching cases of ENTER point.
			{

			}

        }
        else SendClientMessage(playerid,colorexit,"[ ! ] You must be near a valid enter point!");
	}
	return 1;
}
Now our final last task. Our co-ordinates of ENTER point is in 0. So, our case would be 0.
Код:
CMD:enter(playerid,params[])
{
	for(new i = 0; i < sizeof(Enter);i++)
	{
        if(IsPlayerInRangeOfPoint(playerid,1.0,Enter[i][0],Enter[i][1], Enter[i][2]))
        {
			switch(i)
			{
			    case 0:
			    {
			    	SetPlayerInterior(playerid,10); // Interior of casino it can be checked by pressing /interior when you are inside any interior
			        SetPlayerPos(playerid,2015.4500,1017.0900,996.8750);// Position of the casino interior where the player will be spawned.
			        SetPlayerFacingAngle(playerid,90.0000);// Facing angle of the player.
			    }
			}
        
        }
        else SendClientMessage(playerid,colorexit,"[ ! ] You must be near a valid enter point!");
	}
	return 1;
}
Now the player will spawn at the point.
This was how we have learnt to make an ENTER command. The exit commands goes the same. So, you may try making an EXIT command to learn these codes.

Thank you. I have tried my best to explain it. Please let me know if there are any bugs/glitches/errors. And any easy method of things. I welcome your comments.

- John_Blaze ( WSRPG )
Reply


Messages In This Thread
Single command multiple task - by JohnBlaze1971 - 03.04.2016, 15:13
Re: Single command multiple task - by Vanter - 03.04.2016, 15:14
Re: Single command multiple task - by fuckingcruse - 03.04.2016, 15:50
Re: Single command multiple task - by AndySedeyn - 03.04.2016, 15:51
Re: Single command multiple task - by fuckingcruse - 03.04.2016, 15:53
Re: Single command multiple task - by Kasis - 05.04.2016, 11:46
Re: Single command multiple task - by AndySedeyn - 05.04.2016, 12:01
Re: Single command multiple task - by Kasis - 05.04.2016, 14:24
Re: Single command multiple task - by AndySedeyn - 05.04.2016, 14:25
Re: Single command multiple task - by Kasis - 05.04.2016, 14:48

Forum Jump:


Users browsing this thread: 1 Guest(s)