I found a guide for a Freeze command so my staff can freeze players rather than kill them via vMenu (mainly because anytime we do that, people start demanding to know why they were killed and with the freeze, I added a message to display to the subject explaining they were frozen by a staff member and that someone will be with them shortly).
I want to add Ace perms to it so only my staff can use this and I found the Ace guide where it talked about using the “if IsPlayerAceAllowed” but was not sure where it needs to be placed in this server.lua to allow it to work?
Here is the server.lua code to freeze/unfreeze the player if someone could please tell me how to get this to look for the needed perms (I have the ace added to my permissions file for command.freeze already, I just need this resource to look and see if the player using the command has that perm)
AddEventHandler('chatMessage', function(id, name, msg)
local args = stringsplit(msg, ' ')
local cmd = table.remove(args, 1)
if (cmd == "/freeze") then
local pid = table.remove(args, 1)
if (pid ~= nil) then
TriggerClientEvent('freeze:freezePlayer', tonumber(pid))
TriggerClientEvent('chatMessage', tonumber(pid), '^1You have been frozen by a staff member. Please wait and someone will be with you shortly and explain why. Please do not ask in chat as you will not be answered.')
else
TriggerClientEvent('chatMessage', id, 'Player Freeze', { 0, 0, 0 }, 'You need to enter the target ID!')
end
end
end)
“chatMessage” event is deprecated, migrate to RegisterCommand which also have a argument which you can set to true to require ace permissions for the command
Yea, I have done Ace’s with the RegisterCommand just fine. Unfortunately for me, I am not familiar enough with scripting to realize that things are deprecated as most of the time, I find scripts that kind of do what I want, then mix/match the code together until I have it doing what I want but do not really have the skill to just write one from scratch and my issue with just changing over to RegisterCommand was I don’t really know how to get it to look for the target players ID and pass that into the rest of the function so it will freeze the target and show only the target the message about them getting frozen and also showing the user a message saying they froze the target. I can see how the deprecated method they use does it, but not sure how to rewrite that to the RegisterCommand
It should look like this
RegisterCommand('freeze', function(source, args, message)
if args[1] then
if GetPlayerPing(tonumber(args[1])) > 0 then -- Checks if the ID is in-game
TriggerClientEvent('freeze:freezePlayer', tonumber(args[1]))
TriggerClientEvent('chatMessage', tonumber(args[1]),'Player Freeze',{255,255,255},'^1You have been frozen by a staff member. Please wait and someone will be with you shortly and explain why. Please do not ask in chat as you will not be answered.')
else
TriggerClientEvent('chatMessage',source, 'Player Freeze',{255,255,255}, 'That player is not in-game!')
end
else
TriggerClientEvent('chatMessage',source, 'Player Freeze',{255,255,255}, 'You need to enter the target ID!')
end
end)
Example: “/freeze 34” would freeze ID 34
Then you would have to add this to your server.cfg/permissions.cfg
add_ace group.NAMEHERE command.freeze allow
(Replace NAMEHERE with the group name)
1 Like
chatMessage is also deprecated please use chat:addMessage
So
TriggerClientEvent(‘chat:addMessage’, source, etc-----
?
Awesome!! Thank you for your help!!
Or… you can click the link which explains it… 
1 Like
Non-Deprecated Version, Here you go:
RegisterCommand('freeze', function(source, args, message)
if args[1] then
if GetPlayerPing(tonumber(args[1])) > 0 then -- Checks if the ID is in-game
TriggerClientEvent('freeze:freezePlayer', tonumber(args[1]))
TriggerEvent('chat:addMessage',{color={255,255,255},multiline=true,args={"Player Freeze", "^1You have been frozen by a staff member. Please wait and someone will be with you shortly and explain why. Please do not ask in chat as you will not be answered."}})
else
TriggerClientEvent('chatMessage',source, 'Player Freeze',{255,255,255}, 'That player is not in-game!')
TriggerEvent('chat:addMessage',{color={255,255,255},multiline=true,args={"Player Freeze", "That player is not in-game!"}})
end
else
TriggerEvent('chat:addMessage',{color={255,255,255},multiline=true,args={"Player Freeze", "You need to enter the target ID!"}})
end
end)
1 Like