18.07.2012, 14:21
(
Last edited by JustinAn; 02/09/2014 at 11:43 PM.
)
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>
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.
Place this code in 'OnGameModeInit'.
pawn Code:
public OnGameModeInit()
{
pickup = CreatePickup(1242, 2, 1930.9042,-1776.4119,13.5469, 0);
return 1;
}
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
Code:
CreatePickup(model, type, Float:X, Float:Y, Float:Z, Virtualworld);
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;
}
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;
}