SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 18/07/2012, 03:21 PM   #1
JustinAn
Huge Clucker
 
JustinAn's Avatar
 
Join Date: Apr 2012
Location: stfu
Posts: 236
Reputation: 28
Default How To Make A Simple Pickup

How To Make A Simple Pickup


Hello guys, today I will be showing you how to make a simple pickup

First, your going to want to define the include 'a_samp' at the top of your script, this include gets to access functions like SendClientMessage, SendClientMessageToAll, SetWeather, SetWorldTime, SetTimer, SetTimerEx, all those functions that are in 'a_samp' include.

pawn Code:
#include <a_samp>

Next, we're going to want to define the pickup's name.
Place this maybe at the bottom of your color defines as I recommend.
pawn Code:
new pickup; // You can change the word 'pickup' to a different name, but don't remove the ';', it's very important.

Now, we will have to create a armor pickup.
Place this code in 'OnGameModeInit'.

pawn Code:
public OnGameModeInit()
{
    pickup = CreatePickup(1242, 2, 1930.9042,-1776.4119,13.5469, 0);
    return 1;
}
Okay, so this code, pickup = CreatePickup(1242, 2, 1930.9042,-1776.4119,13.5469, 0);
basically means to create a pickup, with a armor model, and the '2', is the type of the pickup, this '2' type of pickup is pickupable, but it will respawn after some time.The 3rd parameter to the 5th parameter is the X, Y, Z position, the postion the pickup will spawn.After the last parameter is the virtual world, the pickup will only be in virtual world 0.


You can see the types of models here.

Types of pickups:
Code:
0 - The pickup does not display.
1 - Not pickupable, exists all the time. (Suitable for completely scripted pickups using OnPlayerPickUpPickup)
2 - Pickupable, respawns after some time.
3 - Pickupable, respawns after death
4 - Disappears shortly after created (perhaps for weapon drops?)
5 - Disappears shortly after created (perhaps for weapon drops?)
8 - Pickupable, but has no effect. Disappears automatically.
11 - Blows up a few seconds after being created (bombs?)
12 - Blows up a few seconds after being created.
13 - Slowly decends to the ground.
14 - Pickupable, but only when in a vehicle.
15 - Pickupable, respawns after death
19 - Pickupable, but has no effect (information icons?)
22 - Pickupable, respawns after death.
23 - Pickupable, but doesn't disappear on pickup.
_____________________________________________
Refer here: PickupTypes
Parameters for the function, 'CreatePickup'
Code:
CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld);
Next, we will have to add what happens when they pickup the pickup.
Which we will use a callback called 'OnPlayerPickUpPickup'.
If you have trouble finding that callback in your script, do as the following:
Press CTRL+F, a box will pop up, type in the blank 'OnPlayerPickUpPickup', click 'OK', and it will direct you to the callback, 'OnPlayerPickUpPickup'

pawn Code:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickup)
    {
        SetPlayerArmour(playerid, 100);
        GameTextForPlayer(playerid, "ARMOR REFILLED!", 3000, 6);
    }
    return 1;
}

So, this code basically means if the player pickups a pickup named 'pickup' which is the armor pickup we've created in the callback 'OnGameModeInit', it will set the player's armor to 100 percent, and a game text will pop up on the player's screen saying 'ARMOR REFILLED!' for 3000 seconds, in milliseconds. But it is acutally 3 seconds, and the '6' is the style of the text.
You can refer here for GameTextStyles


Final Code:
pawn Code:
#include <a_samp>

new pickup; // You can change the word 'pickup' to a different name, but don't remove the ';', it's very important.

public OnGameModeInit()
{
    pickup = CreatePickup(1242, 2, 1930.9042,-1776.4119,13.5469, 0);
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickup)
    {
        SetPlayerArmour(playerid, 100);
        GameTextForPlayer(playerid, "ARMOR REFILLED!", 3000, 6);
    }
    return 1;
}

That's pretty much it guys, a how to make a simple pickup tutorial.
__________________

Last edited by JustinAn; 03/09/2014 at 12:43 AM.
JustinAn is offline   Reply With Quote
Old 03/09/2012, 10:00 AM   #2
Mr.Faqahat
Huge Clucker
 
Join Date: Nov 2011
Location: Īle-de-France
Posts: 327
Reputation: 29
Default Re: How To Make A Simple Pickup

Thank you very much it really helped me Rep +
Mr.Faqahat is offline   Reply With Quote
Old 05/09/2012, 02:04 AM   #3
JustinAn
Huge Clucker
 
JustinAn's Avatar
 
Join Date: Apr 2012
Location: stfu
Posts: 236
Reputation: 28
Default Re: How To Make A Simple Pickup

Quote:
Originally Posted by Mr.Faqahat View Post
Thank you very much it really helped me Rep +
Thanks for the feed back, and I'm glad it helped you in scripting. Keep Learning.
__________________
JustinAn is offline   Reply With Quote
Old 06/10/2012, 11:34 PM   #4
Ghost_Boii
Huge Clucker
 
Ghost_Boii's Avatar
 
Join Date: Sep 2012
Location: Don of Dubai :)
Posts: 311
Reputation: 42
Default Re: How To Make A Simple Pickup

Nice Tutorial
__________________
My Works

Ghost_Boii is offline   Reply With Quote
Old 09/12/2012, 05:51 PM   #5
fate003142
Little Clucker
 
Join Date: Dec 2012
Posts: 3
Reputation: 0
Default Re: How To Make A Simple Pickup

Ok I did this now how do I actually add it to the game?
fate003142 is offline   Reply With Quote
Old 13/12/2012, 02:13 AM   #6
Djean
Gangsta
 
Djean's Avatar
 
Join Date: Jul 2012
Location: Jamaica
Posts: 592
Reputation: 44
Default Re: How To Make A Simple Pickup

Nice one.. Helped me out alot.
__________________







Quote:
The aim is not to create a 300+ player-base server, but to have a knit server to bring together people from all cultures,nations and religions into a whole functional community - D'Jean Allwood
Djean is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tutorial] Simple Pickup Mento Tutorials 18 10/06/2012 03:07 AM
I wanna make a simple housing system with a pickup Michael_Cuellar Server Support 1 01/05/2012 09:31 PM
[Tutorial] Simple vehicle and pickup spawning system mckennie Tutorials 2 26/08/2010 01:15 AM
simple question in for pickup code Sfinx_17 Help Archive 4 23/08/2009 05:16 PM


All times are GMT. The time now is 06:09 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.