Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
zDevon - 31.03.2012
Introduction
This short and sweet tutorial was designed for the beginner scripter. By the end of this tutorial you should be able to create both entrances and exits for structures all over your server! I will explain everything as thoroughly as I feel it needs to be. If you feel that there is an aspect that needs expanding on, please post here, and I will do so.
References
During this tutorial we will use all of the below functions at one point or another, so it would behoove you to familiarize yourself with them before continuing on.
https://sampwiki.blast.hk/wiki/AddStaticPickup
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
https://sampwiki.blast.hk/wiki/SetPlayerPos
https://sampwiki.blast.hk/wiki/SetPlayerInterior
https://sampwiki.blast.hk/wiki/AddPlayerClass
Getting the coordinates for your entrance
The first step in creating an entry or exit point is gaining the coordinates (x, y, and z values) for the points. For this you will use /save. Go in-game, and move to the building you would like to script an entrance/exit for. We will use the Commerce Ammunation as an example. Once in front of the door, use
/save [Position name]. For our example,
/save AmmunationEntrance. Our exit coordinates will be found later.
Getting the coordinates for your entrance - pt. 2.
Once you've completed the above, /q, and navigate to your documents. Open the SAMP folder found in your San Andreas user files (In my case,
C:\Users\Devon\Documents\GTA San Andreas User Files\SAMP) and look for a
savedpositions.txt. Open the file and inside you will see a new AddPlayerClass (Or AddStaticVehicle, if you /save'd inside a car) line for each time you've used the /save command. The further down the list of lines the more recent the line was written. We will look for our AmmunationEntrance line that we made earlier.
pawn Код:
AddPlayerClass(105,1367.5817,-1279.9658,13.5469,271.7646,0,0,0,0,0,0); // AmmunationEntrance
Now, we only need the X, Y, and Z coordinates for our goal. When looking at the AddPlayerClass reference from above, we can see that the second, third, and fourth parameters of AddPlayerClass are the values we need. Select and copy those values.
Creating the Icon
Open your script and find your OnGameModeInit callback. This is where we will be creating our entrance icons, or pickups. We will use AddStaticPickup to do this. The parameters for AddStaticPickup are:
Код:
(model, type, Float:X, Float:Y, Float:Z, Virtualworld)
Within the model parameter, enter any value you find here:
http://weedarr.wikidot.com/pickups. We will use the "i" icon, ID 1239.
The different icon types are found here:
http://weedarr.wikidot.com/pickups. We will use type 1, as it causes the icon to simply spawn and to stay present no matter what.
The Float:X, Float:Y, and Float:Z are the values you copied from the
savedpositions.txt earlier in this tutorial. For these three parameters, you will right-click and paste them onto your AddStaticPickup line.
The last parameter is the virtualworld value. Unless you have a complete understanding of how virtual worlds work and know what you are doing, enter
-1 in this field to show the icon in all worlds. The below AddStaticPickup line is what you should have at this point:
pawn Код:
public OnGameModeInit()
{
AddStaticPickup(1239, 1, 1366.3108,-1279.5417,13.5469, -1);//AmmunationEntrance
//Your other OnGameModeInit code.
return 1;
}
Moving on to the commands
Now for the commands themselves. /enter and /exit.
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/enter", true))
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, 1366.3108,-1279.5417,13.5469))
{
SetPlayerPos(playerid, 286.148986,-40.644397,1001.515625);//AmmunationEntrance
SetPlayerInterior(playerid, 1);
}
}
if(!strcmp(cmdtext, "/exit", true))
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, 286.148986,-40.644397,1001.515625))
{
SetPlayerPos(playerid, 1366.3108,-1279.5417,13.5469);//AmmunationExit
SetPlayerInterior(playerid, 0);
}
}
return 1;
}
Here we used three main functions. The first, IsPlayerInRangeOfPoint, the wiki link of which is posted in the references section above, is used to detect if the player is near (3.0 unit radius in this case) the specified point. We put this function to use to detect first if the player is near the Ammunation door, for /enter, and second to detect if the player is in the interior of Ammunation, for /exit.
Next was SetPlayerPos. In /enter, we set the position of
playerid (the user of /enter) to the coordinates of the Ammunation interior, and in /exit, to set the position of
playerid (the user of /exit) to the coordinates we saved earlier, the Ammunation front door. You may find the coordinates of every interior here:
http://weedarr.wikidot.com/interior. The same place where you find the ID for each interior, an ID that we used in our next function:
SetPlayerInterior. In /enter, we found and set the player to not only the coordinates of the Ammunation interior, but also to the Ammunation interior ID (1). 0, the default (no interior) interior ID, was set on /exit, to remove the player from the Ammunation interior's world and replace him to your realm.
Adding multiple entry and exit points.
To add a second, third, and even a fourth entry and exit point it really is no pain at all. Repeat the steps from above with your new building's X, Y, and Z coordinates and copy your already-existing enter and exit lines, changing obviously the interior ids (unless they are the same) and the IsPlayerInRangeOfPoint and SetPlayerPos coordinates.
An example of the above, excluding the AddStaticPickup bits
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/enter", true))
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, 1366.3108,-1279.5417,13.5469))
{
SetPlayerPos(playerid, 286.148986,-40.644397,1001.515625);//AmmunationEntrance
SetPlayerInterior(playerid, 1);
}
if(IsPlayerInRangeOfPoint(playerid, 3.0, 2229.5374,-1721.7302,13.5658))
{
SetPlayerPos(playerid, 773.579956,-77.096694,1000.655029);//GantonGymEntrance
SetPlayerInterior(playerid, 7);
}
if(IsPlayerInRangeOfPoint(playerid, 3.0, 1284.6202,-1585.2909,13.5469))
{
SetPlayerPos(playerid, -2029.798339,-106.675910,1035.171875);//LicenseCenterEntrance
SetPlayerInterior(playerid, 3);
}
}
if(!strcmp(cmdtext, "/exit", true))
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, 286.148986,-40.644397,1001.515625))
{
SetPlayerPos(playerid, 1366.3108,-1279.5417,13.5469);//AmmunationExit
SetPlayerInterior(playerid, 0);
}
if(IsPlayerInRangeOfPoint(playerid, 3.0, 286.148986,-40.644397,1001.515625))
{
SetPlayerPos(playerid, 1366.3108,-1279.5417,13.5469);//AmmunationExit
SetPlayerInterior(playerid, 0);
}
if(IsPlayerInRangeOfPoint(playerid, 3.0, 773.579956,-77.096694,1000.655029))
{
SetPlayerPos(playerid, 2229.5374,-1721.7302,13.5658);//GantonGymExit
SetPlayerInterior(playerid, 0);
}
if(IsPlayerInRangeOfPoint(playerid, 3.0, -2029.798339,-106.675910,1035.171875))
{
SetPlayerInterior(playerid, 0);
SetPlayerPos(playerid, 1284.6202,-1585.2909,13.5469);//LicenseCenterExit
}
}
return 1;
}
The end. That really is all there is to it, looks like I was thorough enough with everthing. I hope I helped!
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Luis- - 31.03.2012
Nicely done mate. Properly explained, should help some new scripters!
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
shayan122 - 05.07.2012
Thanks man but how can i add Simple red checkpoint without /enter /exit command?
just when he enter checkpoint go in building/or out of it...
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Bug. - 13.09.2012
Good.
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
xMCx - 13.09.2012
thanks easy but really good explaining
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Bug. - 24.09.2012
Hey, i have problem with cmd i have no errors but
When use (/enter) i says : SERVER:UnKnow Command.
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
zDevon - 24.09.2012
Quote:
Originally Posted by Bug.
Hey, i have problem with cmd i have no errors but
When use (/enter) i says : SERVER:UnKnow Command.
|
Try returning 1 inside the command.
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Shane_Kingston - 30.09.2012
Good man i will give you +1 rep
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
x96664 - 26.11.2012
It's well explained!
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Red_Dragon. - 26.11.2012
Thats what i have been looking for a long time. Thanks alot !!
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Bug. - 27.11.2012
How to make a new "IsPlayerInRangeOfPoint", i IG "/save", and is not work!
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Red_Dragon. - 27.11.2012
How can i add words above the pickup
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Socan - 27.11.2012
Nice ! Well explained! Keep up the good work.
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
atiqfajar - 12.12.2012
Quote:
Originally Posted by shayan122
Thanks man but how can i add Simple red checkpoint without /enter /exit command?
just when he enter checkpoint go in building/or out of it...
|
put it under public OnPlayerEnterCheckpoint
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
zDevon - 12.12.2012
Quote:
Originally Posted by Red_Dragon.
How can i add words above the pickup
|
Create a 3D text label (
https://sampwiki.blast.hk/wiki/Create3DTextLabel) under OnGameModeInit using the same coords as your /enter and /exit commands.
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
SilencedPistol - 16.02.2013
Can you sort this command out for me? I have no errors, I've returned everything, I can do the /enter but not the /exit. Can somebody write a CMD in ZCMD format for me please? Thanks.
I need it both in World 0 as it's from one part of the mapping I have to another.
Entrance Co-Ords: AddPlayerClass(0,2538.7358,-2529.8491,13.6254,180.7422,0,0,0,0,0,0); //
Exit Co-Ords: AddPlayerClass(0,2538.7598,-2533.5776,13.7359,1.8646,0,0,0,0,0,0); //
Thank you, rep to anybody who does one.
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
Toxik - 30.06.2014
better make it without command/key
just when u get in point u tp inside or outside an interior
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
fullaninho - 25.06.2015
I can't put at the end return 0; because pawno gives me the warning 225, but I also can't use that script without returning to 0 because it cancels the other commands, how can I solve the problem?
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
fullaninho - 26.06.2015
I no longer need help, I've solved the problem like this:
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/enterb", true) ==0)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, 1298.2000,-798.5759,84.1406))
{
SetPlayerPos(playerid, 1299.14,-794.77,1084.00);//mansгo entrar
SetPlayerInterior(playerid, 5);
return 1;
}
}
if(strcmp(cmdtext, "/exitb", true) ==0)
{
if(IsPlayerInRangeOfPoint(playerid, 3.0, 1299.14,-794.77,1084.00))
{
SetPlayerPos(playerid, 1298.2000,-798.5759,84.1406);//mansгo sair
SetPlayerInterior(playerid, 0);
return 1;
}
}
return 0;
}
It probably wasn't working well currently because this script wasn't made for this version of samp, but is well made and it doesn't need to be much changed and the changes are easy to make, I've started scripting about 3 to 4 weeks ago (I'm a beginner) and it took me shortly to solve the problem. It's a great script, It helped me a lot creating entrances for places in the game. Thanks
Re: Simple Entry and Exit Points [Adding icons + Creating /enter and /exit commands] -
AndreiWow - 18.07.2015
Thanks alot, great tutorial.