Ragemp-roleplay-skript/Vehiclesystem/PayNSpray.cs
2019-04-16 13:59:07 +02:00

185 lines
7.7 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GrandTheftMultiplayer.Server;
using GrandTheftMultiplayer.Shared;
using GrandTheftMultiplayer.Server.API;
using GrandTheftMultiplayer.Shared.Math;
using GrandTheftMultiplayer.Server.Elements;
using GrandTheftMultiplayer.Server.Constant;
using GrandTheftMultiplayer.Server.Managers;
namespace Roleplay.Vehiclesystem
{
class PayNSpray : Script
{
public const int PAYNSPRAY_MENU_CALLBACK = 54017654;
public const int PAYNSPRAY_MENU_CALLBACK2 = 540176542;
public PayNSpray()
{
API.onEntityEnterColShape += PayNSprayHandler;
API.onClientEventTrigger += onCallBack;
createPayNSprayPoints();
// PayNSpray more needed!
API.consoleOutput("PayNSprays loaded!");
}
private void onCallBack(Client sender, string eventName, object[] arguments)
{
if(eventName == "menu_handler_select_item")
{
int callbackid = (int) arguments[0];
if(callbackid == PAYNSPRAY_MENU_CALLBACK)
{
int index = (int)arguments[1];
if(index == 0)
{
API.setEntityPositionFrozen(sender.vehicle, false);
API.setVehicleLocked(sender.vehicle, false);
API.triggerClientEvent(sender, "menu_handler_close_menu");
}
else if(index == 1)
{
if(Environment.MONEY.Money.hasBarMoney(sender,150) == true)
{
API.repairVehicle(sender.vehicle);
API.setEntityPositionFrozen(sender.vehicle, false);
API.setVehicleLocked(sender.vehicle, false);
API.triggerClientEvent(sender, "menu_handler_close_menu");
Environment.MONEY.Money.giveBarMoney(sender, -150,API);
}
else
{
API.sendNotificationToPlayer(sender, "Du hast nicht genug Bargeld dabei!");
}
} else if(index == 2)
{
API.triggerClientEvent(sender, "menu_handler_close_menu");
API.triggerClientEvent(sender, "createColorMenu",sender.vehicle);
API.setEntityPositionFrozen(sender.vehicle, false);
API.setVehicleLocked(sender.vehicle, false);
}
}
}
else if(eventName == "buyVehicleColor")
{
int color = (int) arguments[0];
if (Environment.MONEY.Money.hasBarMoney(sender, 1250))
{
Environment.MONEY.Money.giveBarMoney(sender, -1250, API);
API.setVehiclePrimaryColor(sender.vehicle, color);
Vehiclesystem.VehicleMain.setDatabaseVar(sender, sender.vehicle, "color", color);
Vehiclesystem.VehicleMain.setDatabaseVar(sender, sender.vehicle, "color2", color);
Vehiclesystem.VehicleMain.remapTunings(sender, sender.vehicle, API);
API.setEntitySyncedData(sender.vehicle, "data:primary_color", color);
API.setEntitySyncedData(sender.vehicle, "data:secondary_color", color);
}
else
{
API.sendNotificationToPlayer(sender, "Du hast keine 1250$ Bar dabei!", true);
}
}
else if(eventName == "unfreeze")
{
API.setVehicleLocked(sender.vehicle, false);
API.setEntityPositionFrozen(sender.vehicle, false);
}
else if(eventName == "ApplyColor")
{
int color = (int)arguments[0];
API.setVehiclePrimaryColor(sender.vehicle, color);
API.setVehicleSecondaryColor(sender.vehicle, color);
//API.setVehicleCustomPrimaryColor(sender.vehicle, 0, 0, 0);
//API.setVehicleCustomSecondaryColor(sender.vehicle, 0, 0, 0);
}
}
private void PayNSprayHandler(ColShape colshape, NetHandle entity)
{
if(entity != null && colshape != null && colshape.hasData("paynspray") == true && colshape.getData("paynspray") == true)
{
if (API.getEntityType(entity) == EntityType.Vehicle)
{
Vehicle veh = API.getEntityFromHandle<Vehicle>(entity);
Client[] players = API.getVehicleOccupants(veh);
Client player = players[0];
if (API.getEntityData(veh, "besitzer") == player.name)
{
///////////////////////////////////////////////////////////////
object[] argumentList = new object[13];
argumentList[0] = PAYNSPRAY_MENU_CALLBACK;
argumentList[1] = "PayNSpray";
argumentList[2] = "Optionen:";
argumentList[3] = true;
int itemlength = 3;
argumentList[4] = itemlength;
argumentList[5] = "~r~Verlassen";
argumentList[6] = "~g~Reparieren";
argumentList[7] = "~b~Faerben";
/*argumentList[8] = "~b~Felgen faerben";
argumentList[9] = "~b~Neonlichter anbringen";*/
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
///////////////////////////////////////////////////////////////
API.setEntityPositionFrozen(veh, false);
API.setVehicleLocked(veh, true);
}
else
{
API.sendNotificationToPlayer(player, "Du kannst nur Privatfahrzeuge faerben!");
}
}
}
}
// CREATING ATM'S COL,BLIP's
public class PayNSprays
{
public Vector3 Position { get; set; }
public PayNSprays(Vector3 position)
{
Position = position;
RAPI.Marker.createMarker(2, Position, 1, 255, 0, 0, "paynspray", 0, 80, "PaynSpray", 90);
}
}
public void createPayNSprayPoints()
{
new PayNSprays(new Vector3(540.3726, -176.694, 54.48134));
new PayNSprays(new Vector3(486.9341, -1314.667, 29.23));
new PayNSprays(new Vector3(2465.155, 1589.128, 32.72038));
new PayNSprays(new Vector3(-1269.744, -3377.65, 13.94016));
new PayNSprays(new Vector3(257.9501, 2593.37, 44.95409));
Blip PayNSpray1 = API.createBlip(new Vector3(540.3726, -176.694, 54.48134));
PayNSpray1.sprite = 72;
PayNSpray1.name = "PayNSpray";
Blip PayNSpray2 = API.createBlip(new Vector3(486.9341, -1314.667, 29.23));
PayNSpray2.sprite = 72;
PayNSpray2.name = "PayNSpray";
Blip PayNSpray3 = API.createBlip(new Vector3(2465.155, 1589.128, 32.72038));
PayNSpray3.sprite = 72;
PayNSpray3.name = "PayNSpray";
Blip PayNSpray4 = API.createBlip(new Vector3(-1269.744, -3377.65, 13.94016));
PayNSpray4.sprite = 72;
PayNSpray4.name = "PayNSpray";
}
}
}