[Tutorial] /enter -- Making a simple enter command.
#1

/ENTER - Making a simple enter command.

Hello. Today, I'll be showing you how you can make a very simple /enter command for your server. I will be showing you how you can do this in the following command processors: ZCMD and strcmp. Now, let's get started.

Now, let's get everything set-up. The first part of this tutorial will be done in ZCMD. Let's get our includes ready. If you don't already have a_samp included in your script you might wanna do that.

Code:
#include <a_samp>
Then, the ZCMD include...
Code:
#include ZCMD
Of-course, you'll need the actual ZCMD include so make sure you have that. You can get it from here.

Let's start the actual command now...

The first thing you need to do is set-up your command.

Code:
CMD:enter(playerid, params[])
{
}
After the first bracket({) you'll input the actual code. Now, the first thing you need is "IsPlayerInRangeOfPoint". This will determine whether the player(playerid) is near the point, where you want to /enter at. You'll need two different coordinates for this command. You'll need one set of coordinates(coordinates A) which will be where the player(playerid) will use the /enter command. Then, the next set of coordinates(coordinates B) will be where the player(playerid) enters into. Let's use LSPD as an example. LSPD's coordinate A set is "1554.682495,-1675.988403,16.195312" so the IsPlayerInRangeOfPoint would be:

Code:
if(!IsPlayerInRangeOfPoint(playerid,2,1554.682495,-1675.988403,16.195312))
If they are not near LSPD, send them a message...
Code:
return SendClientMessage(playerid,-1,"You are not near LSPD");
If they are near LSPD then they'll enter the building. You'll need to set their position to LSPD's interior(coordinates B).

Code:
SetPlayerPos(playerid, 246.391220,62.97142,1003.640625);
Then, you'll need to set their interior to 6 or they will just fall from the sky, which we don't want.

Code:
SetPlayerInterior(playerid,6);
And finally, you'll want to return a value...
Code:
return 1;
There you go! Just replace the coordinates with your coordinates and you're all good to go! You should have this if you've followed the tutorial properly...

Code:
// If you're making this a seperate filter-script you'll need to define it as so.
// #define filterscript

#include <a_samp>
#include ZCMD
Code:
CMD:enter(playerid, params[])
{
if(!IsPlayerInRangeOfPoint(playerid,2,1554.682495,-1675.988403,16.195312)) return SendClientMessage(playerid,-1,"You are not at the entrance of the Los Santos PD(LSPD)!"; // Or whatever your coordinates A are for.
SetPlayerPos(playerid, 246.391220,62.97142,1003.640625); // Coordinates B
SetPlayerInterior(playerid,6); // The interior of Coordinates B(if a different interior is used, other than 0).
return 1;
}
It's basically the same thing as if you do it without ZCMD, with the exception of a few things. This is what it would be without using ZCMD.

Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/enter", cmdtext, true, 10) == 0)
	{
		if(!IsPlayerInRangeOfPoint(playerid,2,1554.682495,-1675.988403,16.195312)) return SendClientMessage(playerid,-1,"You are not at the entrance of the Los Santos PD(LSPD)!"); // Or whatever your coordinates A are for.
        SetPlayerPos(playerid, 246.391220,62.97142,1003.640625); // Coordinates B
        SetPlayerInterior(playerid,6); // The interior of Coordinates B(if a different interior is used, other than 0).
		return 1;
	}
	return 0;
}
If you do use the code above, you won't need to have #include ZCMD in your script.

If you want to know how you can use pick-ups for the /enter command just comment below.

Thanks and if you want to see how to do something just PM me, or leave a comment below. Thanks guys!
Reply
#2

I'm sick of seeing the IsPlayerInRangeOfPoint() method for this use dynamic areas.
Reply
#3

Thanks for the feedback/suggestion!
Reply
#4

Good Job..!
Reply
#5

Better dude Keep it up
Reply
#6

Thanks.
Reply
#7

Quote:
Originally Posted by [uL]Pottus
View Post
I'm sick of seeing the IsPlayerInRangeOfPoint() method for this use dynamic areas.
I am on the same boat with him. You should think of another effective way of making a /enter command without it.
Reply
#8

Thank you for helping me
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)