15.05.2011, 14:25
(
Last edited by anant; 15/05/2011 at 03:12 PM.
)
Pickup Teleports
A few things I would like to say before I start.
First of all, you need to "define" the pickup.
To define it, you need to make
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 :
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 :
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.
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
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.
First of all, you need to "define" the pickup.
To define it, you need to make
pawn Code:
new MyPickup;
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.
}
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);
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;
}
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
- Me - all the work in the post
- Wiki - Refrence
Suggestion to be added to the tut are appreciated.