/lspd Uniform command, is this right?

I’m just making a simple little command to set the players model to the police skin.

By doing /lspd, here is what I have so far. Is this correct?

Client.lua

RegisterNetEvent("lspdUniform")
AddEventHandler("lspdUniform", function()
RequestModel("s_m_y_cop_01")
        while not HasModelLoaded("s_m_y_cop_01") do
            Citizen.Wait(0)
        end
        SetPlayerModel(PlayerId(), GetHashKey("s_m_y_cop_01"))
end)

Server.lua

AddEventHandler('chatMessage', function(from,name,message)
	if(message:sub(1,1) == "/") then

		local args = stringsplit(message, " ")
		local cmd = args[1]


		if (cmd == "/lspd") then
			CancelEvent()
			TriggerClientEvent('lspdUniform', from)
		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

I suggest using RegisterCommand.

Cheers I’ll do that now, still won’t set the new player model for some reason.

I’ll take a look when I’m home if I remember. Do you wanna PM me anything so there’s a notification on my account.

Not done much with models and I’m looking to use this as a command and function on Wolf Knights action menu.

@BabbaTundaee
Not sure if you still need help but here is one that i made for someone on the forums a little while back;

Gives player gun + ammo + attachements
simpleloadout-noped.rar (959 Bytes)
Gives player gun + ammo + attachments + ped
simpleloadout.rar (1.0 KB)

Commands:

/leo
/fd
/ems

(which of course you can change)

1 Like

Nice I figured out the ped, but thanks for the weapons, I couldn’t figure that out. Do you know how to do clothing attachments, such as fire helmet, medic gloves etc?

From memory, I got most of the ped attachments working except for the fireman rebreather, I’ll send you them when I get home from school

Thanks, mate.

(20 Chars)

Screw20Char