[Tutorial] How to open shops interiors! and make a system!

Started by SA:MP, May 06, 2023, 06:51 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

SA:MP

[Tutorial] How to open shops interiors! and make a system!

Hi This is my first tutorial in this tutorial i am going to show you how do you can open shop interior.

Shops interiors coord,ids from here: http://weedarr.wikidot.com/interior pickups ids from here:http://weedarr.wikidot.com/pickups weapons ids from here:https://sampwiki.blast.hk/wiki/Weapons



You'll need to type /save <text> in game to create a enter pickup for the shops also for the exit

and you'll find it in documents/GTA SAN ANDREAS USER FILES/SAMP/savedpositions

Let's begin

You'll need to add a pickup like this


Code:

// The entry pickup
new AmmuPickupEntry;

// The exit pickup
new AmmuPickupExit;

public OnGameModeInit() {
    // 1318 is the pickup model ID, followed by the coordinates in the world
    AmmuPickupEntry = CreatePickup(1318, 1, 1367.8782, -1279.7295, 13.5469);

    // And this is the exit pickup that exists inside the store
    AmmuPickupExit = CreatePickup(1318, 1, 285.3757, -41.3928, 1001.5156);
}

Step 2:

Now the pickups is created sucessfully now we will need to make what players will be teleported to if he stand on the pickups


Code:

You'll need to go to OnPlayerPickUpPickUp
}
if(pickupid == ammupickupentry)//LS Enter ammu market the pickup that we've created
  {
      SetPlayerPos(playerid, 286.1017,-41.8042, 1001.5156);// if the player stand on it he gets teleported to ammu coord
      SetPlayerInterior ( playerid, 1 );// and we set him into ammu-natioin id you can get both of this in http://weedarr.wikidot.com/interiornl645...4.03518027 }
  if(pickupid == ammuoutpickupexit)//LS exit ammu market the exit pickup that we've created
  {
      SetPlayerPos(playerid, 1364.8909,-1279.5602,13.5469);// if the player stand on it he gets teleported to out of ammu you can teleport him the place that you want by /save <text>
      SetPlayerInterior (playerid, 0);// here we get the player out of interior by setting his interior to 0
  }

Step 3:

Now it's done and players can gets into the ammu-nation!

Let's add a checkpoint by entering it let them buy weapons!


Code:

We will have to add
new ammuCP;// you can add it before ongamemodeinit
Now we go to the ammu-nation type /save in the place that we want to put the Checkpoint
After that we go to OnGamodeinit
ammuCP= CreateDynamicCP(296.6336,-38.0615,1001.5156,2,-1,-1,-1);// now we've created the cp Just put your X,y,z dont touch anything else
After that go to your dialog defines!
type
#Define DIALOG_AMMU 788// if you have this in your gamemode so change it to another id
After that go to OnPlayerEnterDynamicCP
}
if(checkpointid == ammuCP)// now we will create what happens if player enter this checkpoint dialog will appear i've just added few Weapons you can add what you want
{
format(str, 956, "Sawn-off\nCombat Shotgun.nMicro SMG\nMP5\nAK47\nM4\nTec9\nSniper Rifle\nDetonator\nDesert Eagle\nBody Armour\nMinigun\n");
  ShowPlayerDialog(playerid, DIALOG_AMMU, DIALOG_STYLE_LIST, "{FF0000}Ammu-Nation", str, "Confirm", ".: Close :.");
  }
The Pickups is done also the Checkpoint also the Dialog

Step 4:

So now we'll go to OnDialogResponse


Code:

if(dialogid == DIALOG_AMMU)
{
    if(response)
    {
        if(listitem == 0)// Sawn-off
{
    if(GetPlayerMoney(playerid) < 12000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");// We will check if the player have 12k to buy sawn-off if he dont have, we will send him message! that he cant buy it
    GivePlayerWeapon(playerid, 26, 100);// this function is used to giveplayerweapon(playerid, 26 is the weapon id, 100 is the ammo
        GivePlayerMoney(playerid, -12000);// now we will take from the player 12k
          GameTextForPlayer(playerid,"~r~-12000~g~$",5000,1);// this is a gametext for player will appear when he buy sawn-off
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: Sawnoff Shotgun");//a message will appear

}
if(listitem == 1)//Combat Shotgun
{
    if(GetPlayerMoney(playerid) < 10000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 27, 50);
        GivePlayerMoney(playerid, -10000);
          GameTextForPlayer(playerid,"~r~-10000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: Combat Shotgun");
    }
    if(listitem == 2)//Micro SMG
    {
        if(GetPlayerMoney(playerid) < 6000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 28, 400);
        GivePlayerMoney(playerid, -6000);
          GameTextForPlayer(playerid,"~r~-6000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: Micro SMG");
    }
    if(listitem == 3)//MP5
    {
        if(GetPlayerMoney(playerid) < 15000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 29, 300);
        GivePlayerMoney(playerid, -15000);
          GameTextForPlayer(playerid,"~r~-15000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: MP5");
}
if(listitem == 4)// M4
{
                if(GetPlayerMoney(playerid) < 20000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 30, 600);
        GivePlayerMoney(playerid, -20000);
          GameTextForPlayer(playerid,"~r~-20000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: M4");
    }
    if(listitem == 5)//tec9
    {
        if(GetPlayerMoney(playerid) < 4000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 32, 500);
        GivePlayerMoney(playerid, -4000);
          GameTextForPlayer(playerid,"~r~-4000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: Tec9");
}
if(listitem == 6)//Sniper Rifle
{
    if(GetPlayerMoney(playerid) < 15000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 34, 100);
        GivePlayerMoney(playerid, -15000);
          GameTextForPlayer(playerid,"~r~-15000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: Sniper Rifle");
    }
    if(listitem == 7)//Detonator
    {
        if(GetPlayerMoney(playerid) < 25000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 40, 5);
        GivePlayerMoney(playerid, -25000);
          GameTextForPlayer(playerid,"~r~-25000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: Detonator");
  }
    if(listitem == 8)//Desert eagle
    {
        if(GetPlayerMoney(playerid) < 20000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 24, 300);
        GivePlayerMoney(playerid, -20000);
          GameTextForPlayer(playerid,"~r~-25000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: Desert Eagle");
}
if(listitem == 9)//body armour
{
    if(GetPlayerMoney(playerid) < 2000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    SetPlayerArmour(playerid, 100);
GameTextForPlayer(playerid,"~r~-2000~g~$",5000,1);
SendClientMessage(playerid, 0x22B998AA,"You Bought: Body Armour");
}
if(listitem == 10)//Minigun
{
    if(GetPlayerMoney(playerid) < 150000) return SendClientMessage(playerid, COLOR_RED, "Error: {FFFFFF} You don't have enough money!");
    GivePlayerWeapon(playerid, 38, 20);
        GivePlayerMoney(playerid, -150000);
          GameTextForPlayer(playerid,"~r~-150000~g~$",5000,1);
    SendClientMessage(playerid, 0x22B998AA,"You Bought Weapon: Minigun");
return 1;
}
}
}

This was my first tutorial here i hope i can have time making more tutorials!

Give Feedbacks!

Also if there's something i didn't explain you can tell me in the comments i will edit it asap!

Note: you dont have to use the same colors that i've typed you can use your own colors in your gamemode that you've defined

Source: [Tutorial] How to open shops interiors! and make a system!