11.07.2010, 15:52
(
Last edited by diddychop313; 15/07/2010 at 12:37 PM.
Reason: change some things round :)
)
hey there i originally posted this as a help to someone and i got asked 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.
now under "public OnGameModeInit" add (along these lines):
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
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
and write :
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
this is because its quicker than using "PlayerToPoint" (thanks to Carloton)
now find "public OnPlayerCommandText(playerid, cmdtext[])"
and add
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.
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
----------------------------------------------------------------------------------------------------------------------------------------------
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");
}
Code:
infopickup = CreatePickup(1239,1,1480.9829,-1769.9470,18.7958);
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();
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;
}
pawn Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == infopickup)
{
GameTextForPlayer(playerid,"~r~ /enter ~y~ to enter this building",3000,1);
}
return 1;
}
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);
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;
}
}
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......
}
and thats it!
thanks for looking