211 lines
7.9 KiB
C#
211 lines
7.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using GrandTheftMultiplayer.Server.Elements;
|
|
using GrandTheftMultiplayer.Server.API;
|
|
using GrandTheftMultiplayer.Server;
|
|
using GrandTheftMultiplayer.Server.Constant;
|
|
using GrandTheftMultiplayer.Shared;
|
|
using GrandTheftMultiplayer.Shared.Math;
|
|
using GrandTheftMultiplayer.Server.Managers;
|
|
|
|
namespace Roleplay.Environment
|
|
{
|
|
class Fahrschule : Script
|
|
{
|
|
public const int FAHRSCHULCALLBACK = 1771898;
|
|
public Fahrschule()
|
|
{
|
|
Blip blip = API.shared.createBlip(new Vector3(-177.1898,-1158.318,23.81));
|
|
blip.sprite = 85;
|
|
RAPI.Marker.createMarker(1, new Vector3(-177.1898, -1158.318, 22.81), 1, 255, 0, 0, "Fahrschule", 0, 185, "Fahrschule", 0);
|
|
API.onEntityEnterColShape += FahrschuleEnter;
|
|
API.onClientEventTrigger += onTrigger;
|
|
|
|
}
|
|
|
|
public Dictionary<Client, String> playerlicense = new Dictionary<Client, string>();
|
|
|
|
private void onTrigger(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if (eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int)arguments[0];
|
|
int index = (int)arguments[1];
|
|
if(callback == FAHRSCHULCALLBACK)
|
|
{
|
|
if (index == 0)
|
|
{
|
|
if(PlayerDatabase.hasDatabaseData(sender,"autoschein") == false)
|
|
{
|
|
|
|
createRoute(sender, "RancherXL", "autoschein", -176.9854, -1131.614, 22.69277, 90, 706, 663, 128);
|
|
|
|
}
|
|
}
|
|
else if (index == 1)
|
|
{
|
|
if (PlayerDatabase.hasDatabaseData(sender, "lkwschein") == false)
|
|
{
|
|
createRoute(sender, "Packer", "lkwschein", -176.9854, -1131.614, 22.69277, 90, 706, 663, 128);
|
|
|
|
}
|
|
}
|
|
else if (index == 2)
|
|
{
|
|
if (PlayerDatabase.hasDatabaseData(sender, "motorradschein") == false)
|
|
{
|
|
createRoute(sender, "Vader", "motorradschein", -176.9854, -1131.614, 22.69277, 90, 706, 663, 128);
|
|
|
|
}
|
|
}
|
|
else if (index == 3)
|
|
{
|
|
if (PlayerDatabase.hasDatabaseData(sender, "flugzeugschein") == false)
|
|
{
|
|
createRoute(sender, "Mammatus", "flugzeugschein", -1380.696, -2287.859, 14, 150, 1735, 3290, 40);
|
|
|
|
}
|
|
}
|
|
else if (index == 4)
|
|
{
|
|
if (PlayerDatabase.hasDatabaseData(sender, "bootschein") == false)
|
|
{
|
|
createRoute(sender, "Dinghy", "bootschein", -913.88, -1632.96, 0, 130, -1432, -826, 0);
|
|
|
|
}
|
|
}
|
|
else if (index == 6)
|
|
{
|
|
API.sendNotificationToPlayer(sender, "Dieser Schein ist noch nicht verfügbar!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void FahrschuleEnter(ColShape colshape, NetHandle entity)
|
|
{
|
|
if(colshape.getData("Schein") == true)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
object[] argumentList = new object[17];
|
|
argumentList[0] = FAHRSCHULCALLBACK;
|
|
argumentList[1] = "Scheine";
|
|
argumentList[2] = "Lizenzen:";
|
|
argumentList[3] = false;
|
|
int itemlength = 7;
|
|
argumentList[4] = itemlength;
|
|
argumentList[5] = "PKWschein";
|
|
argumentList[6] = "LKWschein";
|
|
argumentList[7] = "Motorradschein";
|
|
argumentList[8] = "Flugschein";
|
|
argumentList[9] = "Bootschein";
|
|
argumentList[10] = "Waffenschein";
|
|
argumentList[11] = "Personentransportschein";
|
|
for (var i = 0; i < itemlength; i++)
|
|
{
|
|
argumentList[11 + i] = "";
|
|
}
|
|
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
|
|
|
|
}
|
|
else if(colshape.getData("endmarker") == true)
|
|
{
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
string databaseflag = Convert.ToString(playerlicense[player]);
|
|
API.deleteEntity(player.vehicle);
|
|
player.position = new Vector3(-177.955,-1155,23);
|
|
player.dimension = 0;
|
|
API.sendNotificationToPlayer(player, "Du hast den Schein erhalten!", true);
|
|
PlayerDatabase.setDatabaseData(player, databaseflag, 1);
|
|
API.setEntityData(player, databaseflag, 1);
|
|
playerlicense.Remove(player);
|
|
|
|
}
|
|
}
|
|
|
|
// 706.8528 663.6704 128.54
|
|
public void createRoute(Client player, String model, String dataflag, double startx, double starty, double startz, float startrotz, int endmarkerx, int endmarkery, int endmarkerz)
|
|
{
|
|
Vehicle veh = RAPI.MainAPI.createRolePlayVehicleNonARGB(API.vehicleNameToModel(model), new Vector3(startx, starty, startz), new Vector3(0, 0, startrotz), "System");
|
|
int dimension = API.getEntityData(player, "ID");
|
|
API.setPlayerIntoVehicle(player, veh,-1);
|
|
player.dimension = dimension;
|
|
veh.dimension = dimension;
|
|
RAPI.Marker.createClientMarker(player, 1, new Vector3(endmarkerx, endmarkery, endmarkerz), 3, 255, 0, 0, "endmarker", 0, 185, "", 0);
|
|
RAPI.MainAPI.createWaypoint(player,new Vector3(endmarkerx, endmarkery, endmarkerz),0,0);
|
|
API.sendNotificationToPlayer(player, "Fahre nun zu dem Markierten Punkt!");
|
|
|
|
if (playerlicense.ContainsKey(player))
|
|
{
|
|
playerlicense.Add(player, dataflag);
|
|
}
|
|
else
|
|
{
|
|
playerlicense.Set(player, dataflag);
|
|
}
|
|
|
|
}
|
|
|
|
public static Boolean doesPlayerHaveFuehrerschein(Client player)
|
|
{
|
|
bool state = false;
|
|
if(API.shared.getEntityData(player,"autoschein") == 1)
|
|
{
|
|
state = true;
|
|
}
|
|
return state;
|
|
}
|
|
public static Boolean doesPlayerHaveLKWSchein(Client player)
|
|
{
|
|
bool state = false;
|
|
if (API.shared.getEntityData(player, "lkwschein") == 1)
|
|
{
|
|
state = true;
|
|
}
|
|
return state;
|
|
}
|
|
public static Boolean doesPlayerHaveMotorradSchein(Client player)
|
|
{
|
|
bool state = false;
|
|
if (API.shared.getEntityData(player, "motorradschein") == 1)
|
|
{
|
|
state = true;
|
|
}
|
|
return state;
|
|
}
|
|
public static Boolean doesPlayerhaveFlugzeugschein(Client player)
|
|
{
|
|
bool state = false;
|
|
if (API.shared.getEntityData(player, "flugzeugschein") == 1)
|
|
{
|
|
state = true;
|
|
}
|
|
return state;
|
|
}
|
|
public static Boolean doesPlayerHaveBootschein(Client player)
|
|
{
|
|
bool state = false;
|
|
if (API.shared.getEntityData(player, "bootschein") == 1)
|
|
{
|
|
state = true;
|
|
}
|
|
return state;
|
|
}
|
|
|
|
public static Boolean doesPlayerHaveWaffenschein(Client player)
|
|
{
|
|
bool state = false;
|
|
if (API.shared.getEntityData(player, "waffenschein") == 1)
|
|
{
|
|
state = true;
|
|
}
|
|
return state;
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|