232 lines
11 KiB
C#
232 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using GrandTheftMultiplayer.Server.API;
|
|
using GrandTheftMultiplayer.Server.Constant;
|
|
using GrandTheftMultiplayer.Server.Elements;
|
|
using GrandTheftMultiplayer.Server.Managers;
|
|
using GrandTheftMultiplayer.Shared;
|
|
using GrandTheftMultiplayer.Shared.Math;
|
|
|
|
namespace Roleplay.Environment.Shop
|
|
{
|
|
class Shop : Script
|
|
{
|
|
public Shop()
|
|
{
|
|
API.onEntityEnterColShape += onCol;
|
|
API.onClientEventTrigger += onTrigger;
|
|
loadShops();
|
|
|
|
}
|
|
|
|
public const int CALLBACK = 7765416;
|
|
|
|
public void loadShops()
|
|
{
|
|
createShop(new Vector3(1163.42,-322.95,69.20),new Vector3(1164.823,-323.1262,69.20513),105);
|
|
createShop(new Vector3(-47.8, -1757.148, 29.42), new Vector3(-47, -1758.261, 29.42), 47);
|
|
createShop(new Vector3(-1222, -907.0714, 12.32635), new Vector3(-1221.8273,-908.286,12.326), 28);
|
|
createShop(new Vector3(-707.413, -913.581, 19.21559), new Vector3(-706.0665, -913.4593, 19.21559), 90);
|
|
createShop(new Vector3(-1487.54, -378.7891, 40.16339), new Vector3(-1486, -378.2238, 40.16344), 137);
|
|
createShop(new Vector3(-1821.042, 793.3005, 138.1134), new Vector3(-1819.799,793.9276,138.0863), 125);
|
|
createShop(new Vector3(-3242, 1001, 12.83), new Vector3(-3242.101,999.9,12.83071), 0);
|
|
createShop(new Vector3(-2967.855, 391.0161, 15.04331), new Vector3(-2966.35,390.7691,15.04331), 69);
|
|
createShop(new Vector3(547.8287,2670.949,42.15), new Vector3(549.1706,2671,42.156), 90);
|
|
createShop(new Vector3(1393.613, 3605.298, 34.98), new Vector3(1392.942,3606.509,34.98093), -155);
|
|
createShop(new Vector3(1961.131, 3740.768, 32.34374), new Vector3(1960,3740,32.34), -60);
|
|
createShop(new Vector3(-92.62419,6409.843,31.64037), new Vector3(0,0,0), -60);
|
|
API.consoleOutput("Shops geladen!");
|
|
}
|
|
|
|
public void createShop(Vector3 marker, Vector3 ped, int pedheading)
|
|
{
|
|
RAPI.Marker.createMarker(1, marker.Subtract(new Vector3(0,0,1)), 1, 255, 0, 0, "247shop", 0, 185, "24/7 Shop", 0);
|
|
API.createPed(PedHash.ShopKeep01, ped, pedheading, 0);
|
|
Blip blip = API.createBlip(marker);
|
|
blip.sprite = 52;
|
|
}
|
|
|
|
private void onCol(ColShape colshape, NetHandle entity)
|
|
{
|
|
if(colshape != null && entity != null && colshape.hasData("247shop") == true && colshape.getData("247shop") == true)
|
|
{
|
|
if(API.getEntityType(entity) == EntityType.Player)
|
|
{
|
|
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
if(player != null)
|
|
{
|
|
object[] argumentList = new object[60];
|
|
argumentList[0] = CALLBACK;
|
|
argumentList[1] = "24/7 Shop";
|
|
argumentList[2] = "Produkte:";
|
|
argumentList[3] = true;
|
|
int itemlength = 11;
|
|
argumentList[4] = itemlength;
|
|
argumentList[5] = "E-Cola";
|
|
argumentList[6] = "Sprunk";
|
|
argumentList[7] = "Flasche Wasser";
|
|
argumentList[8] = "Fahrzeug Repair-kit";
|
|
argumentList[9] = "Pflaster";
|
|
argumentList[10] = "Pflaster Paket";
|
|
argumentList[11] = "Treibstoff Kanister";
|
|
argumentList[12] = "Pißwasser";
|
|
argumentList[13] = "Pißwasser Sixpack";
|
|
argumentList[14] = "Pizza";
|
|
argumentList[15] = "Schliessen";
|
|
argumentList[16] = "~c~ 5$";
|
|
argumentList[17] = "~c~ 4$";
|
|
argumentList[18] = "~c~ 3$";
|
|
argumentList[19] = "~c~ 1000$";
|
|
argumentList[20] = "~c~ 10$";
|
|
argumentList[21] = "~c~ 40$";
|
|
argumentList[22] = "~c~ 50$";
|
|
argumentList[23] = "~c~ 7$";
|
|
argumentList[24] = "~c~ 40$";
|
|
argumentList[25] = "~c~ 50$";
|
|
argumentList[26] = " ";
|
|
API.triggerClientEvent(player, "menu_handler_create_menu3", argumentList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void onTrigger(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if(eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int) arguments[0];
|
|
if(callback == CALLBACK)
|
|
{
|
|
int index = (int) arguments[1];
|
|
int money = Environment.MONEY.Money.getBarMoney(sender);
|
|
Items.InventoryHolder inv = API.getEntityData(sender, "InventoryHolder");
|
|
if (index == 0)
|
|
{
|
|
if(money >= 5)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -5, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_ECOLA));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir eine E-Cola gekauft!");
|
|
}
|
|
}
|
|
else if(index == 1)
|
|
{
|
|
if (money >= 4)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -4, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_SPRUNK));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir eine Sprunk gekauft!");
|
|
}
|
|
}
|
|
else if (index == 2)
|
|
{
|
|
if (money >= 3)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -3, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_EWATER));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir ein Wasser gekauft!");
|
|
}
|
|
}
|
|
else if (index == 3)
|
|
{
|
|
if (sender.name != "Opa_Mike")
|
|
{
|
|
if (money >= 1000)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -1000, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_REPAIRKIT));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir ein Reperatur Kit gekauft!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (money >= 500)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -500, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_REPAIRKIT));
|
|
API.sendNotificationToPlayer(sender, "Aaachh Opaaa hier krichste Rabatt!");
|
|
}
|
|
}
|
|
}
|
|
else if (index == 4)
|
|
{
|
|
if (money >= 10)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -10, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_BANDAGE));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir ein Pflaster gekauft!");
|
|
}
|
|
}
|
|
else if (index == 5)
|
|
{
|
|
if (money >= 40)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -40, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_BANDAGE_PACKET));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir ein Pflaster Packet gekauft!");
|
|
}
|
|
}
|
|
else if (index == 6)
|
|
{
|
|
if (sender.name != "Opa_Mike")
|
|
{
|
|
if (money >= 50)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -50, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_KANISTER));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir ein Treibstoff Kanister gekauft!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (money >= 25)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -25, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_KANISTER));
|
|
API.sendNotificationToPlayer(sender, "Aaachh Opaaa hier krichste Rabatt!!");
|
|
}
|
|
}
|
|
}
|
|
else if (index == 7)
|
|
{
|
|
if (money >= 7)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -7, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_PIßWASSER));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir ein Pißwasser gekauft!");
|
|
}
|
|
}
|
|
else if (index == 8)
|
|
{
|
|
if (money >= 40)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -40, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_PIßWASSER_PACK));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir ein Pißwasser Sixpack gekauft!");
|
|
}
|
|
}else if(index == 9)
|
|
{
|
|
if(money >= 50)
|
|
{
|
|
Environment.MONEY.Money.giveBarMoney(sender, -50, API, "");
|
|
inv.AddItemToInventory(Items.ItemByID(Items.ITEM_ID_PIZZA));
|
|
API.sendNotificationToPlayer(sender, "Du hast dir eine Pizza gekauft!");
|
|
}
|
|
}
|
|
else if(index == 10)
|
|
{
|
|
API.triggerClientEvent(sender,"menu_handler_close_menu");
|
|
// Close menu
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|