safesethealth bei vendingmachines
This commit is contained in:
@@ -1,19 +1,20 @@
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
|
using ReallifeGamemode.Server.Extensions;
|
||||||
|
|
||||||
public class vMachnesRemote : Script
|
public class vMachnesRemote : Script
|
||||||
{
|
{
|
||||||
//IMPORTANT: THIS EVENT IS REQUIRED!
|
//IMPORTANT: THIS EVENT IS REQUIRED!
|
||||||
[RemoteEvent("vendingMachine.Remote.SharedData")]
|
[RemoteEvent("vendingMachine.Remote.SharedData")]
|
||||||
public void UpdatePlayerData(Player player, string key, object data)
|
public void UpdatePlayerData(Player player, string key, object data)
|
||||||
{
|
{
|
||||||
player.SetSharedData(key, data);
|
player.SetSharedData(key, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
//This event gets fired once the Animation finished playing. You can for example use it, to give a Player Health etc.
|
//This event gets fired once the Animation finished playing. You can for example use it, to give a Player Health etc.
|
||||||
[RemoteEvent("vendingMachines.Remote.Finish")]
|
[RemoteEvent("vendingMachines.Remote.Finish")]
|
||||||
public void OnVendingMachineInteractionFinish(Player player)
|
public void OnVendingMachineInteractionFinish(Player player)
|
||||||
{
|
{
|
||||||
var health = (player.Health + 25 < 100 ? player.Health + 25 : 100);
|
var health = (player.Health + 25 < 100 ? player.Health + 25 : 100);
|
||||||
NAPI.Player.SetPlayerHealth(player, health);
|
player.SafeSetHealth(health);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user