Very headache problem

Daily limit won't update with vip. Players have to wait for the reset time to change daily limit from normal limit to vips limit. Can you fix this? Thanks!

        private void OnGroupPermissionGranted(string group, string permName)
        {
            if (permName != VIPPerm)
            {
                return;
            }
            
            foreach (string id in permission.GetUsersInGroup(group))
            {
                OnUserPermissionGranted(id, permName);
            }
        }

try this.

it is already doing this when permission is granted to a single user. if its not working then the hook isn't being called

nivex
        private void OnGroupPermissionGranted(string group, string permName)
        {
            if (permName != VIPPerm)
            {
                return;
            }
            
            foreach (string id in permission.GetUsersInGroup(group))
            {
                OnUserPermissionGranted(id, permName);
            }
        }

try this.

it is already doing this when permission is granted to a single user. if its not working then the hook isn't being called

Called when a player is added to a group instead of adding permissions to the group. It should be OnUserGroupAdded

try this

        private void OnUserPermissionGranted(string id, string permName)
        {
            if (permName != VIPPerm)
            {
                return;
            }

            if (!storedData.teleportsRemaining.ContainsKey(id))
            {
                storedData.teleportsRemaining[id] = config.viptpAmount;
            }
            else storedData.teleportsRemaining[id] += config.viptpAmount - config.tpAmount;
        }

        private void OnUserGroupAdded(string id, string groupName)
        {
            foreach (var permName in permission.GetGroupPermissions(groupName))
            {
                if (permName == VIPPerm)
                {
                    OnUserPermissionGranted(id, permName);
                }
            }
        }​
nivex

try this

        private void OnUserPermissionGranted(string id, string permName)
        {
            if (permName != VIPPerm)
            {
                return;
            }

            if (!storedData.teleportsRemaining.ContainsKey(id))
            {
                storedData.teleportsRemaining[id] = config.viptpAmount;
            }
            else storedData.teleportsRemaining[id] += config.viptpAmount - config.tpAmount;
        }

        private void OnUserGroupAdded(string id, string groupName)
        {
            foreach (var permName in permission.GetGroupPermissions(groupName))
            {
                if (permName == VIPPerm)
                {
                    OnUserPermissionGranted(id, permName);
                }
            }
        }​

PermName will never be equal to groupName, one is the group name and the other is the permission name



Merged post

You should determine whether a player has been added to a group, and if it is the desired group name, the number of times the player has been refreshed

for example
		void OnUserGroupAdded(string userId, string groupName)
		{
			if (groupName == "vip")
			{
				if (permission.UserHasGroup(userId, groupName))
				{
					OnUserPermissionGranted(userId, groupName);
				}
			}
			else
			{
				return;
			}
		}​
dream

PermName will never be equal to groupName, one is the group name and the other is the permission name

this is not what the code is doing. it checks when a player has been added to a group, and if that group has the vip perm.

dream
You should determine whether a player has been added to a group, and if it is the desired group name, the number of times the player has been refreshed

i will not change this to check the group name instead. you must add corpselocation.vip to your vip group in order to use it the intended way

use the provided code. i've fixed the original issue and have confirmed it works as intended now. i am closing this. good day.

Locked