Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Xml.Serialization;
- using V_MP.Server.API;
- using V_MP.Server.APIStreamed;
- namespace Atlantis_Gamemode
- {
- /// <summary>
- /// Main class for handling all player commands and events
- /// </summary>
- public class RegisteredUser
- {
- public string Name { get; set; }
- public string UID;
- public uint SkinID;
- public Vector3 LoginPos;
- public System.DateTime lastDied;
- public string Password { get; set; }
- public int AdminLevel;
- public int PlayerLevel;
- public int XP;
- public int Cash;
- public string JobName;
- public int PRoute;
- public int DRoute;
- public int HInsurance;
- public int JobID;
- public int PayCheck;
- #region Licnese's
- public int TruckLicense;
- public int LightCargo;
- #endregion
- #region Inventory
- public int Phone;
- public int Suitcase;
- #endregion
- public List<Job.Requirements> AllPlayerLicences = new List<Job.Requirements>();
- /// <summary>
- /// User's current job
- /// </summary>
- [XmlIgnore]
- public Job PlayerJob { get; private set; } = Job.NONE;
- /// <summary>
- /// This session reference for API's User. (Simplifies RegisteredUser - User communication)
- /// </summary>
- [XmlIgnore]
- public User userReference;
- public RegisteredUser(string name, string password)
- {
- Name = name;
- Password = Extensions.CalculateMD5Hash(password);
- AdminLevel = 0;
- PlayerLevel = 1;
- XP = 0;
- Cash = 1000;
- Phone = 0;
- Suitcase = 1;
- PRoute = 0;
- DRoute = 0;
- TruckLicense = 0;
- LightCargo = 0;
- HInsurance = 0;
- JobID = 0;
- JobName = "NONE";
- lastDied = System.DateTime.Now;
- SkinID = (uint)APIScript.PedHash.StripperLite;
- LoginPos = new Vector3(-1034.62f, -2732.11f, 13.756f);
- AllPlayerLicences.Add(Job.Requirements.NONE);
- }
- /// <summary>
- /// Empty constructor for Xml
- /// </summary>
- public RegisteredUser()
- {
- }
- /// <summary>
- /// Returns true if user is admin (of any level)
- /// </summary>
- /// <returns></returns>
- public bool IsUserAdmin() => AdminLevel > 0;
- /// <summary>
- /// Returns true if user is admin of level "<paramref name="level"/>" or above
- /// </summary>
- /// <param name="level"></param>
- /// <returns></returns>
- public bool IsUserAdminOfLevel(int level) => AdminLevel >= level;
- /// <summary>
- /// Returns true only if user's admin level is <paramref name="level"/> exactly
- /// </summary>
- /// <param name="level"></param>
- /// <returns></returns>
- public bool IsUserAdminOfLevelEx(int level) => AdminLevel == level;
- /// <summary>
- /// Returns true if user's job is Job.None or from-XML-loaded JobName is "NONE"
- /// </summary>
- /// <returns></returns>
- public bool HasJob() => PlayerJob != Job.NONE || JobName != "NONE";
- /// <summary>
- /// Adds licence to <paramref name="AllPlayerLicences"/> to be able to pick up some jobs. This should be called
- /// from ingame licence-providing service (i.e. driving school)
- /// </summary>
- /// <param name="licence"></param>
- public void AddLicence(Job.Requirements licence)
- {
- if (AllPlayerLicences.Contains(licence)) return;
- if (AllPlayerLicences.Contains(Job.Requirements.NONE))
- AllPlayerLicences.Remove(Job.Requirements.NONE);
- AllPlayerLicences.Add(licence);
- }
- /// <summary>
- /// Sets player job to <paramref name="job"/>
- /// </summary>
- /// <param name="job"></param>
- public void SetPlayerJob(Job job)
- {
- PlayerJob = job;
- }
- /// <summary>
- /// Gives a licence to player by its <paramref name="id"/>
- /// </summary>
- /// <param name="id"></param>
- public bool GiveLicence(int id)
- {
- Job.Requirements lic = (Job.Requirements) id;
- if (lic != Job.Requirements.NONE)
- {
- if (!AllPlayerLicences.Contains(lic))
- {
- AllPlayerLicences.Add((Job.Requirements) id);
- if (AllPlayerLicences.Contains(Job.Requirements.NONE)) AllPlayerLicences.Remove(Job.Requirements.NONE);
- return true;
- }
- return false;
- }
- return false;
- }
- /// <summary>
- /// Removes all licences of this user
- /// </summary>
- public void RemoveAllLicences()
- {
- AllPlayerLicences.RemoveAll(x => true);
- AllPlayerLicences.Add(Job.Requirements.NONE);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement