SHARE
TWEET

Untitled

a guest Jul 24th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using GTANetworkAPI;
  2. using Models;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6.  
  7. public class WeaponTints : Script
  8. {
  9.     public WeaponTints()
  10.     {
  11.  
  12.     }
  13.  
  14.     public void setWeaponTint(Client client, WeaponHash wepHash, WeaponTint tint)
  15.     {
  16.         client.GetData("weaponTints")[wepHash] = tint;
  17.         if(client.CurrentWeapon == wepHash)
  18.         {
  19.             client.SetData("currentWeaponTint", $"{wepHash.ToString()}|{tint}");
  20.         }
  21.     }
  22.  
  23.     public int getWeaponTint(Client client, WeaponHash wepHash)
  24.     {
  25.         if (client.GetData("weaponTints").containsKey(wepHash.ToString()))
  26.         {
  27.             return client.GetData("weaponTints")[wepHash.ToString()];
  28.         }
  29.  
  30.         else
  31.         {
  32.             return 0;
  33.         }
  34.  
  35.     }
  36.  
  37.     [ServerEvent(Event.PlayerConnected)]
  38.     public void EVENT_OnPlayerConnected(Client client)
  39.     {
  40.         Dictionary<string, int> weaponTints = new Dictionary<string, int>();
  41.         client.SetData("weaponTints", weaponTints);
  42.     }
  43.    
  44.     [ServerEvent(Event.PlayerWeaponSwitch)]
  45.     public void EVENT_OnPlayerWeaponSwitch(Client client, WeaponHash oldWeapon, WeaponHash newWeapon)
  46.     {
  47.         Dictionary<string, int> weaponTints = client.GetData("weaponTints");
  48.         string newWep = newWeapon.ToString();
  49.         string tint = weaponTints.ContainsKey(newWep.ToString()) ? weaponTints[newWep].ToString() : "0";
  50.         client.SetData("currentWeaponTint", $"{newWeapon.ToString()}|{tint}");
  51.     }
  52. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top