26.11.2010, 03:08
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:
Put this:
^ 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:
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:
And under it put this:
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:
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:
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:
Since this variable still doesnt represent a pickup id we will do this:
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:
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:
Put this:
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:
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:
So together the code would look like this:
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:
So now the player will be sent to coords:
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:
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:
So now we want the player to get text instead of teleporting to somewhere!
We keep our pickup but this time on:
We dont add:
But we add this:
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:
What that will do is when the player picks up our pickup it will send him this message:
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 ^-^!
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()
Код:
new (choose a name);
For a example lets use storeenter, so it would become like this:
Код:
new storeenter; public OnGameModeInit() { return 1; }
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
Код:
CreatePickup(pickup model id,pickup type,cooards,virtualworld that shows pickup);
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);
Then we chose to put the pickup at the coords:
Код:
2244.3882,-1665.2316,15.4766
Now after we made our pickup its time to use that variable we created earlier which was:
Код:
new storeenter;
Код:
storeenter = CreatePickup(1239,23,2244.3882,-1665.2316,15.4766,0);
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; }
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)
Код:
if(pickupid==storeenter) { //Code coming soon :P. }
Код:
{ //here }
So lets make them teleport, so we do this:
Код:
SetPlayerPos(playerid, coords);
Код:
if(pickupid==storeenter) { SetPlayerPos(playerid, coords); }
Код:
if(pickupid==storeenter) { SetPlayerPos(playerid, -25.8083,-185.8391,1003.5469); }
Код:
-25.8083,-185.8391,1003.5469
So we do this:
Код:
SetPlayerInterior(playerid, 17);
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); }
We keep our pickup but this time on:
Код:
if(pickupid==storeenter) { }
Код:
SetPlayerInterior(playerid, 17); SetPlayerPos(playerid,-25.8083,-185.8391,1003.5469);
Код:
SendClientMessage(playerid, YOUR_COLOR, "Message Here");
Код:
SendClientMessage(playerid, COLOR_GREEN, "-------------Gas Station Store-------------");
Код:
-------------Gas Station Store-------------