I need a freeze/unfreeze player mod

police
helpme
fxserver
player
freeze

#1

I need some help finding a freeze/unfreeze player mod. I just can’t find one.

Has to work for FXserver.


#2

I am on my chromebook rightnow but I can try to create one:

__resource.lua

client_script 'client.lua'
server_script 'server.lua'

server.lua

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))

            else

            TriggerClientEvent('chatMessage', id, 'Player Freeze', { 0, 0, 0 }, 'You need to enter a second argument!')

        end
    end
end)

function stringsplit(inputstr, sep)
    if sep == nil then
        sep = "%s"
    end
    local t={} ; i=1
    for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
        t[i] = str
        i = i + 1
    end
    return t
end

client.lua

local isFrozen;

RegisterNetEvent('freeze:freezePlayer')
AddEventHandler('freeze:freezePlayer', function()
    isFrozen = not isFrozen
end)

Citizen.CreateThread(function()
    while true do
        FreezeEntityPosition(GetPlayerPed(-1), isFrozen)

        Citizen.Wait(0)
    end
end)

The above should work, just copy and paste into the files that are listed. If any errors come up while trying to use it just go ahead and reply to me.


#3

Also the default resource “spawnmanager” should have a example of freezing the player.


#4

in the server starter I made when I start the server it comes up like this

Error parsing script server.lua in resource Freeze: server.lua:1: unexpected symbol near '<\239>'
Failed to load script server.lua.
Started resource Freeze

And I have copied and pasted the code straight from this and made a new resource called Freeze. Could you please help me?


#5

Make your own topic if you have issues.