[Tutorial] Pickup Activated Commands

Moderator: Leut.Adv

Locked
User avatar
CataLynHD
Membru
Membru
Posts: 381
Joined: 5 years ago
Location: Rm.Valcea
Has thanked: 0
Been thanked: 0
Zodiac:
Age: 20
Contact:
Status: Offline

5 years ago

Pickup Activated Commands

In this basic tutorial, i am going to show you how to make a command that re-fills your health.

Preperations:

1) Go in game and type '/save [pickupid]' in the spot you want the pickup to appear.
2) Find the pickup style(( pickup id )) you want to use. (( You can find them here: [Please login or register to view this link] ))
3) Do you want this pickup to delete upon the person stepping in it, or respawn after some time, or stay when picked up?

Step 1:

In this step you want to create and define the pickup or the script will not compile, and the pickup will not appear ingame.
For this example i am going to create the pickup at the coords: x0, y0, z0 to make it easier on you.
Add this in the top of the script or wherever you keep your defines: new pickupid;
Now that we have defined the pickup, we need to create it.
Add this under 'OnGameModeInit': pickupid = CreatePickup(1274, 23, coordX, coordY, coordZ);

Explanation:

*The '1274' is the pickup's object id:

*The '23' next to the pickup object id, tells the pickup whether or not to delete/respawn or stay when picked up. In this case '23' means to not delete/respawn after pickup, and it will stay there no matter what.

*The 'coordX, coordY, coordZ' is the position of the pickup, and is where it will appear ingame. After you have gone ingame and typed '/save pickupid' you can goto 'My Documents >> Gta SA User Files >> SAMP >> Savedpositions.txt' to find your coords.

Step 2:

In this step we will make it so when you step into the pickup, it re-fills your health.
Ok, if you already completed Step 1, you are ready to proceed, if not, i suggest you read it now, or your pickup will not appear!
Now, you need to make sure you have 'public OnPlayerPickUpPickup(playerid, pickupid)' in your script, if not, add it now!
Now that you have added that you can proceed to making the command:

Add this under 'OnPlayerPickUpPickup;:
Code:
if(pickupid == pickupid)
{
new Float: Health, HealthI;
GetPlayerHealth( playerid, Health);
HealthI = floatround(Health, floatround_ceil);
if(HealthI != 100)
{
SetPlayerHealth( playerid, 100);
SendClientMessage(playerid,LIGHTGREEN,"You Have Been Healed 100 Percent!");
}
else
{
SendClientMessage(playerid,ORANGE,"You Already Have Full Health!");
}
}
Explanation:

*The 'HealthI' is used to grab the players health.
*We use the SendClientMessage function to let the player know the command is working, or there health is too full to refill.
*"if(pickupid == pickupid)" is used to tell the server that you are standing in the pickup, and that it can proceed with the command.
*'SetPlayerHealth' is used to set the players health to the defined amount, you can change 100 to whatever you would like!

At this time, the pickup should appear, and work!

If it doesnt, please let me know in this topic!
__________________
Image
Image
Locked

Return to “Tutoriale”