[Tutorial] Adding Pickups & More
#1

Adding Pickups & More

When adding pickups you can make them send you to another interior, send you a message, or even heal your character! I am going to be telling you about adding the pickups and making them teleport you and give you a message!

Step 1:
On the top of the script just above:

Код:
public OnGameModeInit()
Put this:

Код:
new (choose a name);
^ The above creates a variable to represent the the Pickup ID , it will be helpful very soon.
For a example lets use storeenter, so it would become like this:

Код:
new storeenter;
public OnGameModeInit()
{
	return 1;
}
Step 2:
Now we created a variable that is ready to represent our pickup, but where is the pickup? To create one we need to go to:

Код:
public OnGameModeInit
And under it put this:

Код:
CreatePickup(pickup model id,pickup type,cooards,virtualworld that shows pickup);
For Pickup Model IDs and Pickup Types go here: https://sampwiki.blast.hk/wiki/Pickup_help

Anyway what we just did is created a pickup, but you have to edit the pickup model id, pickup type, coords, and Virtual World, for the example we will use this:

Код:
CreatePickup(1239,23,2244.3882,-1665.2316,15.4766,0);
What we did there is we created a Information Icon Pickup and then we made the Pickup Type as 23 which is, Pickupable, but doesn't disappear on pickup. That means after you go over it and pick it up it wont disapear!
Then we chose to put the pickup at the coords:
Код:
2244.3882,-1665.2316,15.4766
and the virtual world is set to 0, so the pickup will show only in virtual world 0 (the default) You can make it -1 so it shows up in all virtual worlds though!

Now after we made our pickup its time to use that variable we created earlier which was:

Код:
new storeenter;
Since this variable still doesnt represent a pickup id we will do this:

Код:
storeenter = CreatePickup(1239,23,2244.3882,-1665.2316,15.4766,0);
The code is simple, we made the variable (storeenter) result to The Pickup We Created!

Now after we did that we want this pickup to take us to a somewhere when the player picks it up, or show the player text! So what we do now is we find this:

Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}
It pretty much does as it says, when the player picks up the pickup it does a action .
So lets first make it teleport the player somewhere when he picks the pickup we created, this is where the variable comes in!

So under:

Код:
public OnPlayerPickUpPickup(playerid, pickupid)
Put this:

Код:
if(pickupid==storeenter)
{
//Code coming soon :P.
}
So what we did there is we told it if the player picks up our pickup "storeenter" then it will do a action, but we havent made the action yet. So in between the:

Код:
{
//here
}
We will be putting our action that we want to happen after the player picks up our pickup!
So lets make them teleport, so we do this:

Код:
SetPlayerPos(playerid, coords);
So together the code would look like this:

Код:
if(pickupid==storeenter)
{
SetPlayerPos(playerid, coords);
}
What we did there is we made it so that when the player picks up, our pickup storeenter their position will be set to the coords we put! All you have to do is change the coords to something you want the player to go to, for example inside a 24/7 store! So we do this:

Код:
if(pickupid==storeenter)
{
SetPlayerPos(playerid, -25.8083,-185.8391,1003.5469);
}
So now the player will be sent to coords:

Код:
-25.8083,-185.8391,1003.5469
When they pick up our pickup! But hmm... the player is being sent to a gray area. Why? Well because the 24/7 store is in another interior, and we need to set the player's interior as well so they will go inside the 24/7 store!
So we do this:

Код:
SetPlayerInterior(playerid, 17);
What the code does is it sets the player's interior to: 17, which is the 24/7's interior! You can change the interior to any number you want it, but dont forget to change the coords!
To find out interiors and coords go here: http://weedarr.wikidot.com/interior

So all together it looks like this:

Код:
	
if(pickupid==storeenter)
{
SetPlayerInterior(playerid, 17);
SetPlayerPos(playerid,-25.8083,-185.8391,1003.5469);
}
So now we want the player to get text instead of teleporting to somewhere!
We keep our pickup but this time on:

Код:
if(pickupid==storeenter)
{
}
We dont add:

Код:
SetPlayerInterior(playerid, 17);
SetPlayerPos(playerid,-25.8083,-185.8391,1003.5469);
But we add this:

Код:
SendClientMessage(playerid, YOUR_COLOR, "Message Here");
What that does is it sends a message to (playerid) The ID of the player that picked up the pickup, with the color: YOUR_COLOR (which you change to the color you want) and the "Message". So for example we can do this:

Код:
SendClientMessage(playerid, COLOR_GREEN, "-------------Gas Station Store-------------");
What that will do is when the player picks up our pickup it will send him this message:

Код:
-------------Gas Station Store-------------
So now you learned how to make the pickup and make it either teleport or send the player a message! Now you have to edit it to your needs and make it so that it works for you, . Good luck and if you need any help just post on the thread ^-^!
Reply
#2

You really described how to do it, thumbs up.
It could come in handy once I start to script again
Reply
#3

thanks a lot ^-^, I tried to be as detailed as possible hopefully as I learn more I can make more tutorials lol, thanks again and goodluck !
Reply
#4

Very nice .. XoSarahMoX Well Explained...
Reply
#5

Thank you very much ! If anyone needs help with a error or something I will try to help just post a comment on the thread Thanks again guys ^-^
Reply
#6

Код:
C:\Users\xxxx\Desktop\Empty\gamemodes\Script1.pwn(475) : error 017: undefined symbol "COLOR_YELLOW"
Can't compile it if I add SendClientMessage
Reply
#7

Quote:
Originally Posted by Huxley
Посмотреть сообщение
Код:
C:\Users\xxxx\Desktop\Empty\gamemodes\Script1.pwn(475) : error 017: undefined symbol "COLOR_YELLOW"
Can't compile it if I add SendClientMessage
Put this under include's.
pawn Код:
#define COLOR_YELLOW 0xFFFF00AA
Reply
#8

I have +1 suggestion here
Add how to make 2/3 pickups more!
Reply
#9

@ Clive,thanks for that
@ Hoss,if you want to make 2 pickups,you need to make 2 Scripts,compile them and put in filterscript folder.Good luck!
Reply
#10

Quote:
Originally Posted by Huxley
Посмотреть сообщение
@ Clive,thanks for that
@ Hoss,if you want to make 2 pickups,you need to make 2 Scripts,compile them and put in filterscript folder.Good luck!
You're Welcome.
Want to add more Pickups?
Check this:
pawn Код:
#include <a_samp>

//top
new pickup1;
new pickup2;

public OnGameModeInit() //or on filterscriptinit
{
    pickup1 = CreatePickup(1239, 23, x,y,z);
    pickup2 = CreatePickup(1239, 23, x,y,z);
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickup1)
    {
        GameTextForPlayer(playerid, "pickup 1!",2000,5);
        return 1;
    }
    if(pickupid == pickup2)
    {
        GameTextForPlayer(playerid, "pickup 2!",2000,5);
        return 1;
    }
    return 1;
}
Btw nice TUT.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)