hey there
![Smiley](images/smilies/smile.png)
im new to scripting too (i tried it about a year ago for a few weeks then i stopped lol)
but i know how to do this
ok 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 grove street (dont ask why lol). 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 grovestreet lol) 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
![Smiley](images/smilies/smile.png)
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.
Код:
#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):
Код:
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 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
Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
and write :
Код:
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-----
to create this, first go right to the bottom of your script and add
Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx - x);
tempposy = (oldposy - y);
tempposz = (oldposz - z);
if(((tempposx < radi)&& (tempposx > - radi))&& ((tempposy < radi)&& (tempposy > - radi))&& ((tempposz < radi)&& (tempposz > - radi)))
{
return 1;
}
}
return 0;
}
this adds "PlayerToPoint(radius,playerid,x,y,z)" which we will use for the enter command
now find "public OnPlayerCommandText(playerid, cmdtext[])"
and add
Код:
if (strcmp("/enter", cmdtext, true, 6) == 0)
{
if(PlayerToPoint(10,playerid,1480.9829,-1769.9470,18.7958))
{
SetPlayerPos(playerid,2495.4016,-1667.8710,13.3438);
return 1;
}
}
Going through.. the "if(PlayerToPoint..." line.. 10, is the radius, the coodinates are the building.
the "SetPlayPos" line is the coodinates for the location you want to goto.
and thats it
i think thats all
![Cheesy](images/smilies/biggrin.png)
have fun!