Ragemp-roleplay-skript/Fraktionen/Aktionen/Waffenshop.cs
2019-04-16 13:59:07 +02:00

164 lines
7.3 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.Elements;
using GrandTheftMultiplayer.Server.Managers;
using GrandTheftMultiplayer.Shared;
using GrandTheftMultiplayer.Shared.Math;
namespace Roleplay.Fraktionen.Aktionen
{
class Waffenshop : Script
{
public Waffenshop()
{
API.onEntityEnterColShape += onWaffenShop;
API.onClientEventTrigger += onCallback;
loadwaffenshops();
}
private void onCallback(Client sender, string eventName, object[] arguments)
{
if(eventName == "menu_handler_select_item")
{
int callback = (int) arguments[0];
if(callback == WaffenSHOP_CALLBACK)
{
int index = (int)arguments[1];
if(index == 0)
{
if(Environment.MONEY.Money.hasBarMoney(sender,50) == true)
{
Environment.MONEY.Money.giveBarMoney(sender, -50, API);
API.givePlayerWeapon(sender, WeaponHash.Flashlight, 1, true, true);
} else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
}
else if(index == 1)
{
if (Environment.MONEY.Money.hasBarMoney(sender, 150) == true)
{
Environment.MONEY.Money.giveBarMoney(sender, -150, API);
API.givePlayerWeapon(sender, WeaponHash.KnuckleDuster, 1, true, true);
}
else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
}
else if(index == 2)
{
if (Environment.MONEY.Money.hasBarMoney(sender, 500) == true)
{
Environment.MONEY.Money.giveBarMoney(sender, -500, API);
API.givePlayerWeapon(sender, WeaponHash.SwitchBlade, 1, true, true);
}
else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
}else if(index == 3)
{
if (Environment.MONEY.Money.hasBarMoney(sender, 1000) == true)
{
Environment.MONEY.Money.giveBarMoney(sender, -1000, API);
API.givePlayerWeapon(sender, WeaponHash.Pistol, 1, true, true);
API.setPlayerWeaponAmmo(sender, WeaponHash.Pistol, 250);
}
else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
}else if(index == 4)
{
if (Environment.MONEY.Money.hasBarMoney(sender, 1500) == true)
{
Environment.MONEY.Money.giveBarMoney(sender, -1500, API);
API.givePlayerWeapon(sender, WeaponHash.APPistol, 1, true, true);
API.setPlayerWeaponAmmo(sender, WeaponHash.APPistol, 250);
}
else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
}else if(index == 5)
{
if (Environment.MONEY.Money.hasBarMoney(sender, 150) == true)
{
API.setPlayerWeaponAmmo(sender, WeaponHash.Pistol, API.getPlayerWeaponAmmo(sender, WeaponHash.Pistol) + 30);
Environment.MONEY.Money.giveBarMoney(sender, -150, API);
}
else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
}else if(index == 6)
{
if (Environment.MONEY.Money.hasBarMoney(sender, 150) == true)
{
API.setPlayerWeaponAmmo(sender, WeaponHash.APPistol, API.getPlayerWeaponAmmo(sender, WeaponHash.APPistol) + 30);
Environment.MONEY.Money.giveBarMoney(sender, -150, API);
}
else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
}
}
}
}
public const int WaffenSHOP_CALLBACK = 554168;
private void onWaffenShop(ColShape colshape, NetHandle entity)
{
if(colshape != null && entity != null)
{
if (colshape.hasData("waffenshop") == true && colshape.getData("waffenshop") == true)
{
if (API.getEntityType(entity) == EntityType.Player)
{
Client player = API.getPlayerFromHandle(entity);
object[] argumentList = new object[20];
argumentList[0] = WaffenSHOP_CALLBACK;
argumentList[1] = "Waffenshop";
argumentList[2] = "Waffen:";
argumentList[3] = false;
argumentList[4] = 7;
argumentList[5] = "Taschenlampe";
argumentList[6] = "Schlagring";
argumentList[7] = "Klappmesser";
argumentList[8] = "Pistole";
argumentList[9] = "APPistole";
argumentList[10] = "Pistolen Magazin";
argumentList[11] = "APP Magazin";
argumentList[12] = "~y~ 50$";
argumentList[13] = "~y~ 150$";
argumentList[14] = "~y~ 500$";
argumentList[15] = "~y~ 1000$";
argumentList[16] = "~y~ 1500$";
argumentList[17] = "~y~ 150$";
argumentList[18] = "~y~ 150$";
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
}
}
}
}
public void loadwaffenshops()
{
Blip blip = API.createBlip(new Vector3(17.05834,-1115.564,29.79));
blip.sprite = 110;
blip.name = "Ammunation";
RAPI.Marker.createMarker(0, new Vector3(17.05834, -1115.564, 29.79), 1, 255, 0, 0, "waffenshop", 0, 185, "Waffenshop", 0);
}
}
}