317 lines
14 KiB
C#
317 lines
14 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.Environment.MONEY
|
|
{
|
|
class Money : Script
|
|
{
|
|
public const int ATM_CALLBACK = 37916452;
|
|
public const int ATM_TRANSFER = 379164532;
|
|
public Money()
|
|
{
|
|
createATMPoints();
|
|
API.onEntityEnterColShape += ATMHit;
|
|
API.onClientEventTrigger += onATMUse;
|
|
}
|
|
|
|
private void onATMUse(Client sender, string eventName, object[] arguments)
|
|
{
|
|
if(eventName == "menu_handler_select_item")
|
|
{
|
|
int callback = (int)arguments[0];
|
|
int index = (int)arguments[1];
|
|
if (callback == ATM_CALLBACK)
|
|
{
|
|
if(index == 0)
|
|
{
|
|
API.sendPictureNotificationToPlayer(sender, "Geldstand: " + PlayerDatabase.getMoney(sender) + " $", "CHAR_BANK_MAZE", 1, 0, "Maze Bank", "Geldstand");
|
|
}
|
|
else if(index == 1)
|
|
{
|
|
API.triggerClientEvent(sender, "get_user_input", ATM_CALLBACK, "Menge", 50, "Abheben");
|
|
}
|
|
else if (index == 2)
|
|
{
|
|
API.triggerClientEvent(sender, "get_user_input", ATM_CALLBACK, "Menge", 50 , "Einzahlen");
|
|
}
|
|
else if (index == 3)
|
|
{
|
|
var list = API.getAllPlayers();
|
|
list.Remove(sender);
|
|
var itemsLen = list.Count;
|
|
object[] argumentList = new object[5 + itemsLen + itemsLen];
|
|
argumentList[0] = ATM_TRANSFER;
|
|
argumentList[1] = "Ueberweisen";
|
|
argumentList[2] = "Waehle einen Spieler aus:";
|
|
argumentList[3] = false;
|
|
argumentList[4] = itemsLen;
|
|
var i = 0;
|
|
foreach (Client player in list)
|
|
{
|
|
argumentList[5 + i] = player.name;
|
|
argumentList[5 + itemsLen + i] = "";
|
|
i++;
|
|
}
|
|
API.shared.triggerClientEvent(sender, "menu_handler_create_menu", argumentList);
|
|
}
|
|
}else if(callback == ATM_TRANSFER)
|
|
{
|
|
string spieler = (String) arguments[2];
|
|
API.shared.triggerClientEvent(sender, "get_user_input", ATM_TRANSFER, "Menge", 100, spieler);
|
|
}
|
|
} else if(eventName == "menu_handler_user_input")
|
|
{
|
|
int callback = (int)arguments[0];
|
|
if(callback == ATM_CALLBACK)
|
|
{
|
|
string text = (string)arguments[1];
|
|
string callback2 = (string)arguments[2];
|
|
if (callback2 == "Abheben")
|
|
{
|
|
int amount = Convert.ToInt32(text);
|
|
if(amount > 1)
|
|
{
|
|
if (Money.hasBankMoney(sender, amount) == true)
|
|
{
|
|
Money.giveBankMoney(sender, -amount, API);
|
|
API.sendPictureNotificationToPlayer(sender, "Neuer Geldstand: " + PlayerDatabase.getMoney(sender) + " $", "CHAR_BANK_MAZE", 1, 0, "Maze Bank", "Geldstand");
|
|
Money.giveBarMoney(sender, amount, API);
|
|
}
|
|
}
|
|
} else if(callback2 == "Einzahlen")
|
|
{
|
|
int amount = Convert.ToInt32(text);
|
|
if (amount > 1)
|
|
{
|
|
if (Money.hasBarMoney(sender, amount) == true)
|
|
{
|
|
Money.giveBankMoney(sender, +amount, API);
|
|
API.sendPictureNotificationToPlayer(sender, "Neuer Geldstand: " + PlayerDatabase.getMoney(sender) + " $ ", "CHAR_BANK_MAZE", 1, 0, "Maze Bank", "Geldstand");
|
|
Money.giveBarMoney(sender, -amount, API);
|
|
}
|
|
}
|
|
}
|
|
} else if(callback == ATM_TRANSFER)
|
|
{
|
|
string text = (string)arguments[1];
|
|
string callback2 = (string)arguments[2];
|
|
string player = callback2;
|
|
int geld = Convert.ToInt32(text);
|
|
if (geld >= 1)
|
|
{
|
|
if(Money.hasBankMoney(sender,geld) == true)
|
|
{
|
|
Client targetplayer = API.getPlayerFromName(player);
|
|
Money.giveBankMoney(targetplayer, +geld, API);
|
|
Money.giveBankMoney(sender, -geld, API);
|
|
API.sendPictureNotificationToPlayer(targetplayer, "Der Spieler: " + targetplayer.name + " hat dir " + geld + " $ ueberwiesen. ", "CHAR_BANK_MAZE", 1, 0, "Maze Bank", "Ueberweisung");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
private void ATMHit(ColShape colshape, NetHandle entity)
|
|
{
|
|
if(colshape.getData("ATM") == true)
|
|
{
|
|
if(API.getEntityType(entity) == EntityType.Player)
|
|
{
|
|
|
|
Client player = API.getPlayerFromHandle(entity);
|
|
|
|
object[] argumentList = new object[13];
|
|
argumentList[0] = ATM_CALLBACK;
|
|
argumentList[1] = "ATM";
|
|
argumentList[2] = "Optionen:";
|
|
argumentList[3] = false;
|
|
argumentList[4] = 4;
|
|
argumentList[5] = "Geldstand";
|
|
argumentList[6] = "Abheben";
|
|
argumentList[7] = "Einzahlung";
|
|
argumentList[8] = "Ueberweisung";
|
|
for (var i = 0; i < 4; i++)
|
|
{
|
|
argumentList[9 + i] = "";
|
|
}
|
|
API.triggerClientEvent(player, "menu_handler_create_menu", argumentList);
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
public static void giveBankMoney(Client player, int amount, API api)
|
|
{
|
|
|
|
int money = API.shared.getEntityData(player,"money");
|
|
API.shared.setEntityData(player, "money", money + amount);
|
|
PlayerDatabase.setMoney(player, money + amount);
|
|
api.playSoundFrontEnd(player, "LOCAL_PLYR_CASH_COUNTER_INCREASE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS");
|
|
if(amount > 0)
|
|
{
|
|
API.shared.sendPictureNotificationToPlayer(player, "Dir wurden " + amount + "$ überwiesen.", "CHAR_BANK_MAZE", 1, 0, "Maze Bank", "Überweisung");
|
|
}
|
|
else if (amount < 0)
|
|
{
|
|
API.shared.sendPictureNotificationToPlayer(player, "Dir wurden " + amount + "$ abgebucht.", "CHAR_BANK_MAZE", 1, 0, "Maze Bank", "Abbuchung");
|
|
}
|
|
}
|
|
|
|
public static void giveBarMoney(Client player, int amount, API api, string grund = "")
|
|
{
|
|
|
|
int money = API.shared.getEntityData(player, "moneyhand");
|
|
API.shared.setEntityData(player, "moneyhand", money + amount);
|
|
PlayerDatabase.setMoneyHand(player, money + amount);
|
|
api.triggerClientEvent(player, "update_money_display", Convert.ToString(API.shared.getEntityData(player, "moneyhand")));
|
|
api.playSoundFrontEnd(player, "LOCAL_PLYR_CASH_COUNTER_INCREASE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS");
|
|
if (grund == "")
|
|
{
|
|
if (amount > 0)
|
|
{
|
|
API.shared.sendPictureNotificationToPlayer(player, "Du hast " + amount + "$ bekommen!", "CHAR_ARTHUR", 1, 0, "Bargeld", "");
|
|
}
|
|
else if (amount < 0)
|
|
{
|
|
API.shared.sendPictureNotificationToPlayer(player, "Du hast jemandem " + amount + "$ gegeben.", "CHAR_ARTHUR", 1, 0, "Bargeld", "");
|
|
}
|
|
} else
|
|
{
|
|
API.shared.sendPictureNotificationToPlayer(player, grund, "CHAR_ARTHUR", 1, 0, "Bargeld", "");
|
|
}
|
|
}
|
|
|
|
public static bool hasBankMoney(Client player, int amount)
|
|
{
|
|
int money = API.shared.getEntityData(player, "money");
|
|
if (money >= amount)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public static int getBankMoney(Client player)
|
|
{
|
|
return API.shared.getEntityData(player, "money");
|
|
}
|
|
|
|
public static int getBarMoney(Client player)
|
|
{
|
|
return API.shared.getEntityData(player, "moneyhand");
|
|
}
|
|
|
|
public static bool hasBarMoney(Client player, int amount)
|
|
{
|
|
int money = API.shared.getEntityData(player, "moneyhand");
|
|
if (money >= amount)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// CREATING ATM'S COL,BLIP's
|
|
public class ATM
|
|
{
|
|
public Vector3 Position { get; set; }
|
|
|
|
public ATM(Vector3 position)
|
|
{
|
|
Position = position;
|
|
ColShape col = API.shared.createSphereColShape(Position, 3);
|
|
col.setData("ATM", true);
|
|
}
|
|
}
|
|
|
|
public void createATMPoints()
|
|
{
|
|
new ATM(new Vector3(-846.6537, -341.509, 37.6685));
|
|
new ATM(new Vector3(-847.204, -340.4291, 37.6793));
|
|
new ATM(new Vector3(-1410.736, -98.9279, 51.397));
|
|
new ATM(new Vector3(-1410.183, -100.6454, 51.3965));
|
|
new ATM(new Vector3(-2295.853, 357.9348, 173.6014));
|
|
new ATM(new Vector3(-2295.069, 356.2556, 173.6014));
|
|
new ATM(new Vector3(-2294.3, 354.6056, 173.6014));
|
|
new ATM(new Vector3(-282.7141, 6226.43, 30.4965));
|
|
new ATM(new Vector3(-386.4596, 6046.411, 30.474));
|
|
new ATM(new Vector3(-846.6537, -341.509, 37.6685));
|
|
new ATM(new Vector3(-847.204, -340.4291, 37.6793));
|
|
new ATM(new Vector3(-1410.736, -98.9279, 51.397));
|
|
new ATM(new Vector3(-1410.183, -100.6454, 51.3965));
|
|
new ATM(new Vector3(-2295.853, 357.9348, 173.6014));
|
|
new ATM(new Vector3(-2295.069, 356.2556, 173.6014));
|
|
new ATM(new Vector3(-2294.3, 354.6056, 173.6014));
|
|
new ATM(new Vector3(-282.7141, 6226.43, 30.4965));
|
|
new ATM(new Vector3(-386.4596, 6046.411, 30.474));
|
|
new ATM(new Vector3(-712.9357, -818.4827, 22.7407));
|
|
new ATM(new Vector3(-710.0828, -818.4756, 22.7363));
|
|
new ATM(new Vector3(289.53, -1256.788, 28.4406));
|
|
new ATM(new Vector3(289.2679, -1282.32, 28.6552));
|
|
new ATM(new Vector3(-1569.84, -547.0309, 33.9322));
|
|
new ATM(new Vector3(-1570.765, -547.7035, 33.9322));
|
|
new ATM(new Vector3(-1305.708, -706.6881, 24.3145));
|
|
new ATM(new Vector3(-2071.928, -317.2862, 12.3181));
|
|
new ATM(new Vector3(-821.8936, -1081.555, 10.1366));
|
|
new ATM(new Vector3(-712.9357, -818.4827, 22.7407));
|
|
new ATM(new Vector3(-710.0828, -818.4756, 22.7363));
|
|
new ATM(new Vector3(289.53, -1256.788, 28.4406));
|
|
new ATM(new Vector3(289.2679, -1282.32, 28.6552));
|
|
new ATM(new Vector3(-1569.84, -547.0309, 33.9322));
|
|
new ATM(new Vector3(-1570.765, -547.7035, 33.9322));
|
|
new ATM(new Vector3(-1305.708, -706.6881, 24.3145));
|
|
new ATM(new Vector3(-2071.928, -317.2862, 12.3181));
|
|
new ATM(new Vector3(-821.8936, -1081.555, 10.1366));
|
|
new ATM(new Vector3(-867.013, -187.9928, 36.8822));
|
|
new ATM(new Vector3(-867.9745, -186.3419, 36.8822));
|
|
new ATM(new Vector3(-3043.835, 594.1639, 6.7328));
|
|
new ATM(new Vector3(-3241.455, 997.9085, 11.5484));
|
|
new ATM(new Vector3(-204.0193, -861.0091, 29.2713));
|
|
new ATM(new Vector3(-867.013, -187.9928, 36.8822));
|
|
new ATM(new Vector3(-867.9745, -186.3419, 36.8822));
|
|
new ATM(new Vector3(-3043.835, 594.1639, 6.7328));
|
|
new ATM(new Vector3(-3241.455, 997.9085, 11.5484));
|
|
new ATM(new Vector3(-204.0193, -861.0091, 29.2713));
|
|
new ATM(new Vector3(89.8134, 2.8803, 67.3521));
|
|
new ATM(new Vector3(-537.8052, -854.9357, 28.2754));
|
|
new ATM(new Vector3(-526.7791, -1223.374, 17.4527));
|
|
new ATM(new Vector3(-1315.416, -834.431, 15.9523));
|
|
new ATM(new Vector3(-1314.466, -835.6913, 15.9523));
|
|
new ATM(new Vector3(89.8134, 2.8803, 67.3521));
|
|
new ATM(new Vector3(-537.8052, -854.9357, 28.2754));
|
|
new ATM(new Vector3(-526.7791, -1223.374, 17.4527));
|
|
new ATM(new Vector3(-1315.416, -834.431, 15.9523));
|
|
new ATM(new Vector3(-1314.466, -835.6913, 15.9523));
|
|
new ATM(new Vector3(-1205.378, -326.5286, 36.851));
|
|
new ATM(new Vector3(-1206.142, -325.0316, 36.851));
|
|
new ATM(new Vector3(147.4731, -1036.218, 28.3678));
|
|
new ATM(new Vector3(145.8392, -1035.625, 28.3678));
|
|
new ATM(new Vector3(-1205.378, -326.5286, 36.851));
|
|
new ATM(new Vector3(-1206.142, -325.0316, 36.851));
|
|
new ATM(new Vector3(147.4731, -1036.218, 28.3678));
|
|
new ATM(new Vector3(145.8392, -1035.625, 28.3678));
|
|
new ATM(new Vector3(1968.117,3743.601,32.34375));
|
|
new ATM(new Vector3(540.2239,2671.121,42.15653));
|
|
}
|
|
|
|
}
|
|
}
|