127 lines
No EOL
5.8 KiB
C#
127 lines
No EOL
5.8 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.Foodshops
|
|
{
|
|
class Foodshops : Script
|
|
{
|
|
public Foodshops(){
|
|
loadFoodShops();
|
|
API.onClientEventTrigger += onCallBack;
|
|
API.onEntityEnterColShape += onCol;
|
|
}
|
|
|
|
public void loadFoodShops()
|
|
{
|
|
createFoodShop(new Vector3(793.7332,-735.7684,28.00));
|
|
createFoodShop(new Vector3(96.847, 284.665, 109.255));
|
|
createFoodShop(new Vector3(-860.9913, -1140.747, 7.195642));
|
|
createFoodShop(new Vector3(-184.6594, -1428.01, 31.47613));
|
|
createFoodShop(new Vector3(409.4756, -1911.069, 25.46042));
|
|
createFoodShop(new Vector3(-3047.306, 615.4216, 7.316735));
|
|
createFoodShop(new Vector3(1985.71, 3053.637, 47.21517));
|
|
createFoodShop(new Vector3(1983.164, 3708.355, 32.11463));
|
|
createFoodShop(new Vector3(1591.267, 6450.991, 25.31714));
|
|
createFoodShop(new Vector3(-575.8844, -880.7936, 25.37012));
|
|
|
|
}
|
|
|
|
public static void createFoodShop(Vector3 marker){
|
|
RAPI.Marker.createMarker(0, marker.Subtract(new Vector3(0,0,-1)),1,255,255,255,"foodshop",0,150,"Fastfood Restaurant",0);
|
|
Blip blip = API.shared.createBlip(marker);
|
|
blip.sprite = 354;
|
|
blip.name = "Fast Food";
|
|
}
|
|
|
|
|
|
public void onCol(ColShape col, NetHandle nh){
|
|
if(col != null && nh != null){
|
|
if(col.hasData("foodshop") == true && col.getData("foodshop") == true){
|
|
if(API.getEntityType(nh) == EntityType.Player){
|
|
Client player = API.getPlayerFromHandle(nh);
|
|
if(player != null){
|
|
openShopMenu(player);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public const int CALLBACK = 8964485;
|
|
public void openShopMenu(Client player){
|
|
object[] argumentList = new object[50];
|
|
argumentList[0] = CALLBACK;
|
|
argumentList[1] = "Fastfood Shop";
|
|
argumentList[2] = "Essen:";
|
|
argumentList[3] = true;
|
|
int itemlength = 5;
|
|
argumentList[4] = itemlength;
|
|
argumentList[5] = "Hamburger";
|
|
argumentList[6] = "Pizza";
|
|
argumentList[7] = "Hot Dog";
|
|
argumentList[8] = "E-Cola";
|
|
argumentList[9] = "~r~Schliessen";
|
|
argumentList[10] = "~y~8$";
|
|
argumentList[11] = "~y~15$";
|
|
argumentList[12] = "~y~5$";
|
|
argumentList[13] = "~y~5$";
|
|
API.triggerClientEvent(player, "menu_handler_create_menu3", argumentList);
|
|
}
|
|
|
|
public void onCallBack(Client sender, string eventname, object[] args)
|
|
{
|
|
if(eventname == "menu_handler_select_item"){
|
|
int callback = (int) args[0];
|
|
int index = (int) args[1];
|
|
if(callback == CALLBACK){
|
|
Environment.Items.InventoryHolder invh = API.getEntityData(sender,"InventoryHolder");
|
|
if(index == 0){
|
|
if(Environment.MONEY.Money.hasBarMoney(sender,8) == true){
|
|
invh.AddItemToInventory(Environment.Items.ItemByID(Environment.Items.ITEM_ID_HAMBURGER));
|
|
API.sendNotificationToPlayer(sender,"Du hast dir einen Hamburger gekauft!");
|
|
Environment.MONEY.Money.giveBarMoney(sender,-8,API);
|
|
} else {
|
|
API.sendNotificationToPlayer(sender,"Du hast nicht genug Geld dabei!");
|
|
}
|
|
} else if(index == 1){
|
|
if(Environment.MONEY.Money.hasBarMoney(sender,15) == true){
|
|
invh.AddItemToInventory(Environment.Items.ItemByID(Environment.Items.ITEM_ID_PIZZA));
|
|
API.sendNotificationToPlayer(sender,"Du hast dir eine Pizza gekauft!");
|
|
Environment.MONEY.Money.giveBarMoney(sender,-15,API);
|
|
} else {
|
|
API.sendNotificationToPlayer(sender,"Du hast nicht genug Geld dabei!");
|
|
}
|
|
} else if(index == 2){
|
|
if(Environment.MONEY.Money.hasBarMoney(sender,5) == true){
|
|
invh.AddItemToInventory(Environment.Items.ItemByID(Environment.Items.ITEM_ID_HOTDOG));
|
|
API.sendNotificationToPlayer(sender,"Du hast dir einen Hotdog gekauft!");
|
|
Environment.MONEY.Money.giveBarMoney(sender,-5,API);
|
|
} else {
|
|
API.sendNotificationToPlayer(sender,"Du hast nicht genug Geld dabei!");
|
|
}
|
|
} else if(index == 3){
|
|
if(Environment.MONEY.Money.hasBarMoney(sender,5) == true){
|
|
invh.AddItemToInventory(Environment.Items.ItemByID(Environment.Items.ITEM_ID_ECOLA));
|
|
API.sendNotificationToPlayer(sender,"Du hast dir eine E-Cola gekauft!");
|
|
Environment.MONEY.Money.giveBarMoney(sender,-5,API);
|
|
} else {
|
|
API.sendNotificationToPlayer(sender,"Du hast nicht genug Geld dabei!");
|
|
}
|
|
} else {
|
|
API.triggerClientEvent(sender,"menu_handler_close_menu");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
} |