[Tutorial] How to make health/teleport/weapon menu OnPlayerPickupPickup
#1

In some servers people want briefcase pickup and when players enters it he can teleport and buy things so today i will show you.
First of all;
pawn Код:
#include <a_samp>
#pragma tabsize 0
which is ofcource needed for scripting samp server
Next;
pawn Код:
#define red 0xFF0000FF
This is the definition of red color se instead of writing
Код:
0xFF0000FF
in the sendclientmessage we will use
Код:
red
so it is not confusing.
Third;
PHP код:
new pickup
PHP код:
public OnGameModeInit()
{
    
pickup CreatePickup(1240232034.1999, -1403.199918.1000, -1);
    return 
1;

So over here we made our pick pick succsesfully but if the player will enetr it nothing will happen so we will have to define that as well.
Fourth;
PHP код:
public OnPlayerPickUpPickup(playeridpickupid)
{
    if(
pickupid == pickup)
    {
       
ShowPlayerDialog(playerid,253,DIALOG_STYLE_MSGBOX"Health","Buy Health ($1000)\nRocketLauncher\nLS Airport","Select""Close");
    }
    return 
1;

So over here when player will enter he will see this dialog but what ever he will select nothing will happed so we will have to set that also
Fifth;
PHP код:
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
 if(
dialogid == 253)
        {
            if(
response)
            {
                if(
listitem == 0)
                {
                    
GivePlayerMoney(playerid, -1000);
                    
SetPlayerHealth(playerid100); //Health
                    
GameTextForPlayer(playerid"~r~Item ~g~Purchase!"5000);
                        }
                        if(
listitem == 1)
                        {
                            
GivePlayerMoney(playerid, -15000);
                            
GivePlayerWeapon(playerid35 5);//rocketlaucher
                            
GameTextForPlayer(playerid"~r~Item ~g~Purchase!"5000);
                        }
                        if(
listitem == 2)
                        {
                            
SetPlayerPos(playeridz);
                            
GameTextForPlayer(playerid"~r~Teleported!"5000);
                        }
                }
                return 
1;
        }
        return 
0;

So over it shows when a player will select items on menu this will happen hope you understood
If i helped you +rep me and change x , y , z to where you want
Conclusion
pawn Код:
#include <a_samp>
#pragma tabsize 0

new pickup;

public OnGameModeInit()
{
    pickup = CreatePickup(1240, 23, 2034.1999, -1403.1999, 18.1000, -1);
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickup)
    {
       ShowPlayerDialog(playerid,253,DIALOG_STYLE_MSGBOX, "Health","Buy Health ($1000)\nRocketLauncher\nLS Airport","Select", "Close");
    }
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
 if(dialogid == 253)
        {
            if(response)
            {
                if(listitem == 0)
                {
                    GivePlayerMoney(playerid, -1000);
                    SetPlayerHealth(playerid, 100); //Health
                    GameTextForPlayer(playerid, "~r~Item ~g~Purchase!", 500, 0);
                        }
                if(listitem == 1)
                {
                    GivePlayerMoney(playerid, -15000);
                    GivePlayerWeapon(playerid, 35 , 5);//rocketlaucher
                    GameTextForPlayer(playerid, "~r~Item ~g~Purchase!", 500, 0);
                        }
                if(listitem == 2)
                {
                    SetPlayerPos(playerid, x , y , z);
                    GameTextForPlayer(playerid, "~r~Teleported!", 500, 0);
                    }
                }
                return 1;
        }
return 0;
}
If i helped you +rep me
Reply
#2

Before making a tutorial, you should know what you're doing yourself.
Reply
#3

pawn Код:
#pragma tabsize 0
Is just a work around for poor indentation.
Reply
#4

Again, another bad example of a tutorial, as Infinity started.Before making a tutorial you MUST know what you're doing yourself.
Reply
#5

what do u mean by : Before making a tutorial you MUST know what you're doing yourself.
Reply
#6

bump
Reply
#7

Quote:
Originally Posted by Pro_Scriptor
Посмотреть сообщение
what do u mean by : Before making a tutorial you MUST know what you're doing yourself.
Do you know how to understand english? By this, I'll take that as a no.

1/10, no explanation for anything. You are simply providing codes. How about you explain things instead of expecting new scripters to look at this and understand it.
Reply
#8

There are already like 50 tutorials on this topic. It's really not hard to search before posting.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)