221 lines
9.4 KiB
C#
221 lines
9.4 KiB
C#
using System;
|
|
using GrandTheftMultiplayer.Server;
|
|
using GrandTheftMultiplayer.Shared;
|
|
using GrandTheftMultiplayer.Server.API;
|
|
using GrandTheftMultiplayer.Shared.Math;
|
|
using GrandTheftMultiplayer.Server.Elements;
|
|
using System.Collections.Generic;
|
|
using GrandTheftMultiplayer.Server.Managers;
|
|
using GrandTheftMultiplayer.Server.Constant;
|
|
|
|
namespace Roleplay
|
|
{
|
|
public class Main : Script
|
|
{
|
|
private readonly Vector3 cameraPositionVinewoodSign = new Vector3(695.5733, 955.9597, 380.969);
|
|
|
|
public static readonly Vector3 spawnposition = new Vector3(-1041.419,-2745.225,21.3594);
|
|
public static String servername = "RPGerman" + " Reallife";
|
|
public static String ip = "rpgerman.net";
|
|
// 17e1f68566b6501a74f3c88ac2a2f16c
|
|
public static String databasepass = "";
|
|
// damnsonthisisamazing2311
|
|
// public static List<String> whitelistedplayers = new List<String>();
|
|
|
|
public Main()
|
|
{
|
|
API.requestIpl("shr_int"); //simeons
|
|
API.removeIpl("shutter_closed"); // simeons
|
|
API.removeIpl("fakeint"); // simeons
|
|
//onPlayer Chat Command
|
|
API.onChatCommand += onPlayerCommand;
|
|
//Player Finishes Download
|
|
API.onPlayerFinishedDownload += onPlayerDownload;
|
|
API.setServerName("[GER|VOICE] ~r~RPGerman ~w~Roleplay | ~y~Autos, Jobs, Gangs, Weed ~o~.~g~.~b~.");
|
|
API.setGamemodeName("RPGerman");
|
|
API.onServerResourceStop += SaveGas;
|
|
//Player leaves
|
|
API.onPlayerDisconnected += onPlayerLeave;
|
|
API.onPlayerConnected += Join;
|
|
krankenhausblips();
|
|
startRestartTimer();
|
|
|
|
}
|
|
|
|
public void startRestartTimer()
|
|
{
|
|
int currenthour = DateTime.Now.Hour;
|
|
int minute = DateTime.Now.Minute;
|
|
API.consoleOutput("RPGerman Gamemode started at: " + currenthour + ":" + minute + "");
|
|
API.consoleOutput("Scripted Restart at: " + (currenthour + 4) + ":" + minute + "");
|
|
API.delay(1000*60*60*4-1000*60*15, true,() => {
|
|
API.consoleOutput("Warning Players for the Restart!");
|
|
API.sendChatMessageToAll("~r~[Server] ~y~Sonnenwende in 15 Minuten!");
|
|
API.delay(1000*60*13,true,() => {
|
|
API.sendChatMessageToAll("~r~[Server] ~y~Sonnenwende in 2 Minuten! Bitte Disconnecten oder einige deiner Spielerdaten gehen verloren!");
|
|
});
|
|
});
|
|
}
|
|
|
|
|
|
[Command("updatepw")]
|
|
public void changepassword(Client player,string pass){
|
|
if(API.shared.getEntityData(player,"loggedin") == true){
|
|
int salt1 = new Random().Next(0,100);
|
|
int salt2 = new Random().Next(0,100);
|
|
int salt3 = new Random().Next(0,100);
|
|
int salt4 = new Random().Next(0,100);
|
|
string salt = API.shared.getHashSHA256(salt1 + salt2 + salt3 + salt4 + "SALT");
|
|
PlayerDatabase.setDatabaseDataString(player,"salt",salt);
|
|
string databasesalt = PlayerDatabase.getDatabaseDataString(player,"salt");
|
|
string hashed = API.shared.getHashSHA256(databasesalt + pass);
|
|
PlayerDatabase.setDatabaseDataString(player,"password",hashed);
|
|
API.shared.sendNotificationToPlayer(player,"Passwort Sicherheit geupdated! Sollte es zu problemen kommen meldet euch bei Eric.");
|
|
}
|
|
}
|
|
|
|
public static void changePWtoSHA256(Client player, string pass){
|
|
int salt1 = new Random().Next(0,100);
|
|
int salt2 = new Random().Next(0,100);
|
|
int salt3 = new Random().Next(0,100);
|
|
int salt4 = new Random().Next(0,100);
|
|
string salt = API.shared.getHashSHA256(salt1 + salt2 + salt3 + salt4 + "SALT");
|
|
PlayerDatabase.setDatabaseDataString(player,"salt",salt);
|
|
string databasesalt = PlayerDatabase.getDatabaseDataString(player,"salt");
|
|
string hashed = API.shared.getHashSHA256(databasesalt + pass);
|
|
PlayerDatabase.setDatabaseDataString(player,"password",hashed);
|
|
}
|
|
|
|
public static string generatePassSHA(string salt ,string pass){
|
|
string hashed = API.shared.getHashSHA256(salt + pass);
|
|
return hashed;
|
|
}
|
|
|
|
public static string salt()
|
|
{
|
|
int salt1 = new Random().Next(0,100);
|
|
int salt2 = new Random().Next(0,100);
|
|
int salt3 = new Random().Next(0,100);
|
|
int salt4 = new Random().Next(0,100);
|
|
string salt = API.shared.getHashSHA256(salt1 + salt2 + salt3 + salt4 + "SALT");
|
|
return salt;
|
|
}
|
|
|
|
|
|
public void krankenhausblips(){
|
|
Blip krankenhaus = API.createBlip(new Vector3(355,-596.75,28.77), 1.0f);
|
|
krankenhaus.sprite = 153;
|
|
krankenhaus.name = "Krankenhaus";
|
|
Blip krankenhaus2 = API.createBlip(new Vector3(342.4677,-1398,32), 1.0f);
|
|
krankenhaus2.sprite = 153;
|
|
krankenhaus2.name = "Krankenhaus";
|
|
Blip krankenhaus3 = API.createBlip(new Vector3(1839.224,3673.417,34.2767), 1.0f);
|
|
krankenhaus3.sprite = 153;
|
|
krankenhaus3.name = "Krankenhaus";
|
|
Blip krankenhaus5 = API.createBlip(new Vector3(-244.8481,6326.936,32.4269), 1.0f);
|
|
krankenhaus5.sprite = 153;
|
|
krankenhaus5.name = "Krankenhaus";
|
|
}
|
|
|
|
private void SaveGas(string resourceName)
|
|
{
|
|
foreach (NetHandle veh in API.getAllVehicles())
|
|
{
|
|
if (API.hasEntitySyncedData(veh, "tank") == true)
|
|
{
|
|
if (API.hasEntitySyncedData(veh, "motor") && API.getEntitySyncedData(veh, "motor") == true)
|
|
{
|
|
if (API.getEntitySyncedData(veh, "tank") != null)
|
|
{
|
|
if(API.hasEntityData(veh,"besitzer") == true && API.getEntityData(veh,"besitzer") != "System")
|
|
{
|
|
Vehiclesystem.VehicleMain.saveTank(veh);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void Join(Client player)
|
|
{
|
|
|
|
if(PlayerDatabase.isPlayerWhitelisted(player)){
|
|
API.sendNotificationToPlayer(player, "Bitte Verbinde dich mit unserem TS ~b~ts.rpgerman.net");
|
|
API.sendChatMessageToPlayer(player, "~r~BITTE VOICEPLUGIN INSTALLIEREN!");
|
|
API.sendChatMessageToPlayer(player, "Bitte Verbinde dich mit unserem TS ~b~ts.rpgerman.net. ~w~Tust du dies nicht, kannst du gebannt werden!");
|
|
API.setEntityPositionFrozen(player, true);
|
|
API.setEntityInvincible(player, true);
|
|
API.setPlayerHealthbarVisible(player, false);
|
|
API.setPlayerArmorbarVisible(player, false);
|
|
API.setPlayerNametagVisible(player, false);
|
|
API.setEntityData(player, "loggedin", false);
|
|
}else{
|
|
API.kickPlayer(player, "Du stehst nicht auf der Whitelist. Bitte schreibe eine kurze Bewerbung unter forum.rpgerman.net");
|
|
}
|
|
}
|
|
|
|
private void onPlayerLeave(Client player, string reason)
|
|
{
|
|
if(API.getEntityData(player,"loggedin") == true)
|
|
{
|
|
if(API.getEntityData(player,"jail") == 0)
|
|
{
|
|
if (API.getEntityData(player, "HOUSE:IN") != true)
|
|
{
|
|
if(player.dimension == 0)
|
|
{
|
|
PlayerDatabase.setSpawnPosition(player);
|
|
}
|
|
}
|
|
}
|
|
|
|
PlayerDatabase.setDatabaseData(player, "jailtime", API.getEntityData(player, "jail"));
|
|
PlayerDatabase.setDatabaseData(player, "payday", Jobs.Jobmanager.getPayDayMoney(player));
|
|
PlayerDatabase.setDatabaseData(player, "playingtime", Jobs.Jobmanager.getPlayingTime(player));
|
|
PlayerDatabase.setDataBaseObject(player,"essen", Environment.EssenTrinken.EssenTrinken.getEssen(player));
|
|
PlayerDatabase.setDataBaseObject(player,"trinken", Environment.EssenTrinken.EssenTrinken.getTrinken(player));
|
|
Environment.Items.save(player);
|
|
Commands.cmdLoginRegister.a.Remove(player);
|
|
Vehiclesystem.VehicleMain.deletePersonalVehicle(player);
|
|
|
|
if(player.hasData("nametag") == true){
|
|
TextLabel tx = player.getData("nametag");
|
|
tx.delete();
|
|
}
|
|
if (!(Fraktionen.Fraktionsmanager.isDuty(player)))
|
|
{
|
|
SaveWeapons.SaveWeapons.Save(player, API);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void onPlayerDownload(Client player)
|
|
{
|
|
API.setEntityData(player, "DOWNLOAD_FINISHED", true); API.setEntityPositionFrozen(player, true);
|
|
API.setEntityInvincible(player, true);
|
|
player.freeze(true);
|
|
|
|
}
|
|
|
|
public void onPlayerCommand(Client player, string arg, CancelEventArgs ce)
|
|
{
|
|
if (API.getEntityData(player, "DOWNLOAD_FINISHED") != true)
|
|
{
|
|
API.setEntityPositionFrozen(player, true);
|
|
API.setEntityInvincible(player, true);
|
|
ce.Cancel = true;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|