[Tutorial] Pickup Teleports
#1

Pickup Teleports


A few things I would like to say before I start.
  • I'm aware that many tutorials for this have been already made.
  • Don't say shi**y things because its my first tutorial, still I'll try to do my best.
  • I'm not a noob.
  • Please tell me if I do something wrong in the script.
Okay, so lets start.
First of all, you need to "define" the pickup.
To define it, you need to make
pawn Code:
new MyPickup;
Where "MyPickup" is the name of your pickup [It will not appear in-game].


Adding the pickup


You need OnGameModeInit callback (Which you probably already have.) for the next step.
Now I need to tell what OnGameModeInit is. So it is a callback which is called when the gamemode is initiated.
In easy words you put everything you wanna load (Maps.. pickups.. and more) under OnGameModeInit.
Here's an example :
pawn Code:
public OnGameModeInit() //This is the function
{
     //You put maps.. pickups.. and many other things here.
}
I can't define it better than in the wiki - OnGameModeInit - SA-MP Wiki

And now, You need to use CreatePickup. (There is also another function to add a pickup but I'm not sure what it is; so forgive me.)
CreatePickup is the function which makes the pickup appear on the screen in easy words.
Wiki link - CreatePickup SA-MP Wiki
Format to use it :
pawn Code:
MyPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld);
Here "MyPickup" stands for the name you used for the pickup in the first step.
And Model stands for the "style" of the pickup = Game Object ID List - SA-MP Wiki
Type stands for the pickup spawn type. Look at the wiki - Wiki link
Float:X/Y/Z stands for the location (Coordinates) the pickup you want to spawn. To get coordinates go in-game, go to the location you want it. Then use /save somename. Then you can find it in My Documents\GTA San Andreas\SA-MP\savedpositions.txt.
Look here for further help about CreatePickup : CreatePickup SA-MP Wiki


Making the pickup teleport the player when reached!
You need to have the OnPlayerPickUpPickup function (Which you most probably already have.) for this step.
Here is an example of OnPlayerPickUpPickup.
pawn Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == MyPickup)
    {
        SetPlayerPos(playerid,0.0,0.0,6.0);
        return 1;
    }
    return 1;
}
I cannot explain this well(But I'm still not a noob) still..
now if(pickupid == MyPickup is checking if the pickup is named "MyPickup" Now if it is, it will teleport the player using SetPlayerPos, yet another function.
SetPlayerPos is quite easy if you have already done the CreatePickup.
So I don't think its needed to explain now. Check out the wiki for help with it - SetPlayerPos

And there you have it, your working Teleport Pickup.


Credits
  1. Me - all the work in the post
  2. Wiki - Refrence

Suggestion to be added to the tut are appreciated.
Reply
#2

But You Proved That you are a Noob :P
Reply
#3

Finished : 8:32 PM GMT +5:30 LOL
Reply
#4

Lolz wtf is that first you posted a noobish post after it edited to tut Hhaha:P
Reply
#5

@Wheelman_wm - I said that time that I clicked the wrong button.
And the second post is just to tell that I finished editing. Whats so wrong?
Reply
#6

ty i couldnt get multiple checkpoints so i had to use this. +1 rep!
Reply
#7

Nice post man. one question how would i change the camera angle once you have entered it. because when i enter it i am always looking into a wall.
Reply
#8

Yo I can't get multiple pickups to work... just the first one.
Reply
#9

Quote:
Originally Posted by Unfriendly
View Post
Yo I can't get multiple pickups to work... just the first one.
you have to have different names for each of the pickups
Reply
#10

This is a Good Tutorial
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)