Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using GTANetworkAPI;
- using Models;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- public class WeaponTints : Script
- {
- public WeaponTints()
- {
- }
- public void setWeaponTint(Client client, WeaponHash wepHash, WeaponTint tint)
- {
- client.GetData("weaponTints")[wepHash] = tint;
- if(client.CurrentWeapon == wepHash)
- {
- client.SetData("currentWeaponTint", $"{wepHash.ToString()}|{tint}");
- }
- }
- public int getWeaponTint(Client client, WeaponHash wepHash)
- {
- if (client.GetData("weaponTints").containsKey(wepHash.ToString()))
- {
- return client.GetData("weaponTints")[wepHash.ToString()];
- }
- else
- {
- return 0;
- }
- }
- [ServerEvent(Event.PlayerConnected)]
- public void EVENT_OnPlayerConnected(Client client)
- {
- Dictionary<string, int> weaponTints = new Dictionary<string, int>();
- client.SetData("weaponTints", weaponTints);
- }
- [ServerEvent(Event.PlayerWeaponSwitch)]
- public void EVENT_OnPlayerWeaponSwitch(Client client, WeaponHash oldWeapon, WeaponHash newWeapon)
- {
- Dictionary<string, int> weaponTints = client.GetData("weaponTints");
- string newWep = newWeapon.ToString();
- string tint = weaponTints.ContainsKey(newWep.ToString()) ? weaponTints[newWep].ToString() : "0";
- client.SetData("currentWeaponTint", $"{newWeapon.ToString()}|{tint}");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement