Simple pickups -
RenSoprano - 21.08.2012
In this tutorial I will explain you everything about pickups
In this tutorial I will learn you everything what I know about pickups.
I will learn you how to make Teleport Pickup, Weapon Pickup, Repair Pickup, Nos Pickup, Health Pickup and Armour Pickup.
Pickup types
There are 23 pickup types. Now I will explain everyone from them.
Код:
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.
Teleport Pickup:
STEP 1:
First we need to add call of our pickup
STEP 2:
Here we will create our pickup. You can find cordinates when you go In Game and find location where you want to set your pickup and write /save. Later you need to go in your GTA:SA Directory and to find one .txt file savedpositions.txt and you will find your cordinates.
pawn Код:
public OnGameModeInit() //Callback
{
TPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
And If you want to make Filterscript
pawn Код:
public OnFilterScriptInit() //Callback
{
TPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
STEP 3:
Now we will set our teleport position
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == TPickup) // If player pickups the TPickup
{
SetPlayerPos(playerid, Float:X, Float:Y, Float:Z); // Change X,Y,Z with cordinates where you want to teleport.
SetPlayerFacingAngle(playerid, Float:Angel); // Change the Angel
return 1;
}
return 1;
}
STEP 4:
And we are ready with our Teleport Pickup. If you follow my instruction everything must be okay.
-------------------------------------------------------------------------------------------------------------------------
Weapon Pickup:
STEP 1:
First we need to add call of our pickup
STEP 2:
Here we will create our pickup.
pawn Код:
public OnGameModeInit() //Callback
{
WPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
And If you want to make Filterscript
pawn Код:
public OnFilterScriptInit() //Callback
{
WPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
STEP 3:
Now we will set weapon what you want to pick up and you will see callback what we use for pick pickup up.
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == WPickup) // If player pickups the WPickup
{
GivePlayerWeapon(playerid, Float:WeaponID, Float:Ammo) // Change Float:WeaponID with weapon what you want and Float:Ammo with how much ammo you want your weapon to have
return 1;
}
return 1;
}
STEP 4:
And we are ready with our Weapon Pickup. If you follow my instruction everything must be okay.
-------------------------------------------------------------------------------------------------------------------------
Health Pickup:
STEP 1:
First we need to add call of our pickup
STEP 2:
Here we will create our pickup.
pawn Код:
public OnGameModeInit() //Callback
{
HPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
And If you want to make Filterscript
pawn Код:
public OnFilterScriptInit() //Callback
{
HPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
STEP 3:
Now we will set your HP to 100
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == HPickup) // If player pickups the HPickup
{
SetPlayerHealth(playerid, 100);
return 1;
}
return 1;
}
STEP 4:
And we are ready with our Health Pickup. If you follow my instruction everything must be okay.
-------------------------------------------------------------------------------------------------------------------------
Armour Pickup:
STEP 1:
First we need to add call of our pickup
STEP 2:
Here we will create our pickup.
pawn Код:
public OnGameModeInit() //Callback
{
APickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
And If you want to make Filterscript
pawn Код:
public OnFilterScriptInit() //Callback
{
APickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
STEP 3:
Now we will set your Armour to 100
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == APickup) // If player pickups the APickup
{
SetPlayerArmour(playerid, 100);
return 1;
}
return 1;
}
STEP 4:
And we are ready with our Armour Pickup. If you follow my instruction everything must be okay.
-------------------------------------------------------------------------------------------------------------------------
Repair Pickup:
STEP 1:
First we need to add call of our pickup
and Grey Colour
Код:
#define COLOR_GREY 0xAFAFAFAA
STEP 2:
Here we will create our pickup.
pawn Код:
public OnGameModeInit() //Callback
{
RPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
And If you want to make Filterscript
pawn Код:
public OnFilterScriptInit() //Callback
{
RPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
STEP 3:
Now we will repair our car when you pick pickup up
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == RPickup) // If player pickups the RPickup
{
if(IsPlayerInAnyVehicle(playerid)) // Here we check is somebody is in the car
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // Here we check is he driver because only if you driver you can pick pickup up
{
switch(GetVehicleModel( GetPlayerVehicleID(playerid) )) // Here we will take vehicle models what we can't fix
{
case 611,610,608,607,606,595,592,593,509,510,481,449,450,441,464,465,501,564,594,591,590,584,577,570,569,563,554,548,538,537,520,519,513,512,511,497,493,488,487,484,476,473,472,496,460,452,447,446,435,432,430,417,409,407:
return SendClientMessage(playerid,COLOR_GREY,"You can't repair this vehicle!");
}
SetVehicleHealth(GetPlayerVehicleID(playerid),1000); // Here we check player vehicle model and fixing it
RepairVehicle(GetPlayerVehicleID(playerid)); // Now our vehicle look like to new
}
}
}
return 1;
}
STEP 4:
And we are ready with our Repair Pickup. If you follow my instruction everything must be okay.
-------------------------------------------------------------------------------------------------------------------------
Nos Pickup:
STEP 1:
First we need to add call of our pickup
STEP 2:
Here we will create our pickup.
pawn Код:
public OnGameModeInit() //Callback
{
NPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
And If you want to make Filterscript
pawn Код:
public OnFilterScriptInit() //Callback
{
NPickup = CreatePickup(model, type, Float:X, Float:Y, Float:Z, virtualworld = 0); // Here we create our pickup
return 1;
}
STEP 3:
Now we will add nos to our car when you pick pickup up
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == NPickup) // If player pickups the NPickup
{
if(IsPlayerInAnyVehicle(playerid)) // Here we check is somebody is in the car
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) // Here we check is he driver because only if you driver you can pick pickup up
{
switch(GetVehicleModel( GetPlayerVehicleID(playerid) )) // Here we will take vehicle models what we can't add nos
{
case 476,473,472,496,460,452,447,446,435,432,430,563,554,548,538,537,520,519,513,512,511,449,448,461,462,463,468,471,509,510,521,522,523,581,586,481,450,441,464,465,501,564,594,611,610,608,607,606,595,592,593,591,590,584,577,570,569,497,493,488,487,484,417,409,407:
return SendClientMessage(playerid,COLOR_GREY,"You can't add nos to this vehicle!");
}
AddVehicleComponent(GetPlayerVehicleID(playerid),1010); // Here we add our nos to our car
}
}
}
return 1;
}
STEP 4:
And we are ready with our Nos Pickup. If you follow my instruction everything must be okay.
-------------------------------------------------------------------------------------------------------------------------
This is end of my pickup tutorial I make it only for beginers and if you find wrong in my code please tell me to fix it.
Re: Simple pickups -
Psat - 21.08.2012
nice tutorial
Re: Simple pickups -
RenSoprano - 22.08.2012
Thank you. I make it for beginner scripters