[Tutorial] How to make /enter command with text tht shows up
#1

hey there i originally posted this as a help to someone and i got asked
Quote:
Originally Posted by [DK]JaloNik
View Post
Why don't you post this as an tutorial? :P It's great!
i didn't know whether to post a link to it or just copy and paste but i have decided to copy and paste but change things seen as its a tutorial
----------------------------------------------------------------------------------------------------------------------------------------------

in this tutorial i will be creating a information icon that displays "/enter to enter this building" also, when you do type "/enter" you will be teleported into the building. Edit: also i will make an exit command so you can exit the building after :P
/imageshack/img94/4474/69880874.png <- that

so first of all we need to get the "info icon" model id From Here or somewhere like the sa:mp wiki. As you can see the model id of the info icon is 1239

in my example i am going to /enter the building near the LSPD in Los Santos and this will teleport me to the inside of that place in LV (city planning department). First i am going to go into SAMP DEBUG and press Launch debug. This is so i can get the coodinates of the building and the place i want to teleport to. when you get to the location, type "/save" w/o quotes (you can also type /save "write something here" eg. /save outside building. This is so its easier to find what you are looking for afterwards. next, go to the teleport location (in my eg it city planning department) and /save. (To get around, type /v 541. this spawns a bullet.

-------info icon that says : do /enter to enter building-------
ok so first we gonna do the info icon open up pawno and press new (or open your existing work)
at the top, under "#include <a_samp>" write "new infopickup;" ... infopickup can be anything, aslong as you can remember what it is exactly. it should look something like this.
pawn Code:
#include <a_samp>

new infopickup;

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by Your Name Here");
    print("----------------------------------\n");
}
now under "public OnGameModeInit" add (along these lines):
Code:
infopickup = CreatePickup(1239,1,1480.9829,-1769.9470,18.7958);
This creates a pickup under the id "infopickup" the first two terms in red are the model id (remember?) and the type. (for list of type of model, please refer to here.
the other bit (blue) are the coordinates of where the point is. To get these coordinates. go into san andreas directory, and look for savedpositions.txt and find the /save you did earlier. it should look like this: AddPlayerClass(0,1480.9829,-1769.9470,18.7958,181.4338,0,0,0,0,0,0); // building location
all you need is the 3 bits after the 0, "609.0391,-1458.7411,14.3820" <-- them (these are the coordinates)

you could also add
Code:
DisableInteriorEnterExits();
this gets rid of them yellow markers. (because we create /enter ourself)

you now have an info icon (it doesnt come up with writing yet tho)... the reason we gave it a class(?) is so we can add things to it like text and this is what we are going to do now..
Find
pawn Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
   
    return 1;
}
and write :
pawn Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == infopickup)
        {
        GameTextForPlayer(playerid,"~r~ /enter ~y~ to enter this building",3000,1);
        }
    return 1;
}
this basically says that when the player picks up "infopickup" (what we created earlier) then text should appear saying "/enter to enter this building" the ~r~ and ~y~ are colours. the "3000" is the time (3000 = 3 second) and the "1" is the style of writing. Look Here For them
COMPILE and you should have a info icon at your location that tells you to write /enter to enter.
THIS IS WHAT IT SHOULD LOOK LIKE:
/imageshack/img94/4474/69880874.png

NOW WE CREATE /ENTER COMMAND.

-----Creating enter command-----
We are goin to use
Code:
 IsPlayerInPointOfRange(playerid,range,x,y,z);
this is because its quicker than using "PlayerToPoint" (thanks to Carloton)
Quote:
Originally Posted by Carlton
View Post
PlayerToPoint is slower than IsPlayerInRangeOfPoint.
now find "public OnPlayerCommandText(playerid, cmdtext[])"
and add
pawn Code:
if (strcmp("/enter", cmdtext, true, 6) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid,10,1480.9829,-1769.9470,18.7958))
            {
                SetPlayerPos(playerid,388.8720,173.8050,1008.3828);
                return 1;
            }
    }
Going through.. the "if(IsPlayerInRangeOfPoint..." line.. 10, is the radius, the coodinates are the building.
the "SetPlayPos" line is the coodinates for the location you want to goto.
basically, if the player is in the coordinates when he/she types /enter, then he/she will be teleported to the location specified.
EDIT: Making /exit command
this is really easy because all we have to do is the same as /enter command but reverse the coodinates around.
pawn Code:
if (strcmp("/enter", cmdtext, true, 6) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid,10,1480.9829,-1769.9470,18.7958))
            {
                SetPlayerPos(playerid,388.8720,173.8050,1008.3828);
                return 1;
            }
        //other enter commands go here if(player......
    }
if (strcmp("/exit", cmdtext, true, 6) == 0)
    {
        if(IsPlayerInRangeOfPoint(playerid,10,388.8720,173.8050,1008.3828))
            {
                SetPlayerPos(playerid,1480.9829,-1769.9470,18.7958);
                return 1;
            }
        //other exit commands go here if(player......
    }
if you look at the enter and exit command.. all we have done is switch the coordinates around so in the exit command, its looking to see if the player is in the area, then teleporting him/her to the original area (outside)

and thats it!
thanks for looking
Reply
#2

PlayerToPoint is slower than IsPlayerInRangeOfPoint.
Reply
#3

ok i'll edit the post
thanks! i didnt know about IsPlayerInRangeOfPoint (im kindof new to this)
Reply
#4

Nice tut.
Reply
#5

Nice TuT for Beginners
Sorry for my bad english
Reply
#6

Thanks (Im begginer) Sorry for bad english thanks!!
Reply
#7

nice tutorial for beginners
SOrry for my bad english xD :P
Reply
#8

Thank you for a nice tutorial!
Reply
#9

Saves alot of newbies asking about it. I swear the most common thing said on this forum is "Sorry for my bad english" or something close to that.
Reply
#10

Quote:
Originally Posted by [HiC]TheKiller
View Post
I swear the most common thing said on this forum is "Sorry for my bad english" or something close to that.
haha

and thanks guys glad i helped

I HAVE EDITED THE ORIGINAL POST AND ADDED AN /exit COMMAND TOO!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)