RedM Snippets

Simple change ped model snippet. in f8 console: setmodel model_name

-- Client

RegisterCommand("setmodel", function(source, args, rawCommand) -- Set player model
	if args[1] == nil then
		print("Please specify the model")
	else
		setModel(args[1])
		print("Success")
	end
end, false)
function setModel(hash)
	local characterModel = GetHashKey(hash)
	Citizen.CreateThread(function()
		RequestModel(characterModel)
		while not HasModelLoaded(characterModel) do
			Citizen.Wait(3000)
		end
		SetPlayerModel(PlayerId(), characterModel, false)
		Citizen.InvokeNative(0x283978A15512B2FE, PlayerPedId(), true)
		SetEntityVisible(PlayerPedId(),true)
		while not IsEntityVisible(PlayerPedId()) do
			Citizen.Wait(1000)
		end
		SetModelAsNoLongerNeeded(characterModel)
	end)
end

Do feel free to add your snippet of choice.

Sharing is caring.

4 Likes

Copy/paste ready array with the weapons.

WeaponList = {
"WEAPON_KIT_CAMERA",
"WEAPON_MOONSHINEJUG",
"WEAPON_MELEE_LANTERN_ELECTRIC",
"WEAPON_MELEE_TORCH",
"WEAPON_MELEE_BROKEN_SWORD",
"WEAPON_FISHINGROD",
"WEAPON_MELEE_HATCHET",
"WEAPON_MELEE_CLEAVER",
"WEAPON_MELEE_ANCIENT_HATCHET",
"WEAPON_MELEE_HATCHET_VIKING",
"WEAPON_MELEE_HATCHET_HEWING",
"WEAPON_MELEE_HATCHET_DOUBLE_BIT",
"WEAPON_MELEE_HATCHET_DOUBLE_BIT_RUSTED",
"WEAPON_MELEE_HATCHET_HUNTER",
"WEAPON_MELEE_HATCHET_HUNTER_RUSTED",
"WEAPON_MELEE_KNIFE_JOHN",
"WEAPON_MELEE_KNIFE",
"WEAPON_MELEE_KNIFE_JAWBONE",
"WEAPON_THROWN_THROWING_KNIVES",
"WEAPON_MELEE_KNIFE_MINER",
"WEAPON_MELEE_KNIFE_CIVIL_WAR",
"WEAPON_MELEE_KNIFE_BEAR",
"WEAPON_MELEE_KNIFE_VAMPIRE",
"WEAPON_LASSO",
"WEAPON_MELEE_MACHETE",
"WEAPON_THROWN_TOMAHAWK",
"WEAPON_THROWN_TOMAHAWK_ANCIENT",
"WEAPON_PISTOL_M1899",
"WEAPON_PISTOL_MAUSER",
"WEAPON_PISTOL_MAUSER_DRUNK",
"WEAPON_PISTOL_SEMIAUTO",
"WEAPON_PISTOL_VOLCANIC",
"WEAPON_REPEATER_CARBINE",
"WEAPON_REPEATER_EVANS",
"WEAPON_REPEATER_HENRY",
"WEAPON_RIFLE_VARMINT",
"WEAPON_REPEATER_WINCHESTER",
"WEAPON_REVOLVER_CATTLEMAN",
"WEAPON_REVOLVER_CATTLEMAN_JOHN",
"WEAPON_REVOLVER_CATTLEMAN_MEXICAN",
"WEAPON_REVOLVER_CATTLEMAN_PIG",
"WEAPON_REVOLVER_DOUBLEACTION",
"WEAPON_REVOLVER_DOUBLEACTION_EXOTIC",
"WEAPON_REVOLVER_DOUBLEACTION_GAMBLER",
"WEAPON_REVOLVER_DOUBLEACTION_MICAH",
"WEAPON_REVOLVER_LEMAT",
"WEAPON_REVOLVER_SCHOFIELD",
"WEAPON_REVOLVER_SCHOFIELD_GOLDEN",
"WEAPON_REVOLVER_SCHOFIELD_CALLOWAY",
"WEAPON_RIFLE_BOLTACTION",
"WEAPON_SNIPERRIFLE_CARCANO",
"WEAPON_SNIPERRIFLE_ROLLINGBLOCK",
"WEAPON_SNIPERRIFLE_ROLLINGBLOCK_EXOTIC",
"WEAPON_RIFLE_SPRINGFIELD",
"WEAPON_SHOTGUN_DOUBLEBARREL",
"WEAPON_SHOTGUN_DOUBLEBARREL_EXOTIC",
"WEAPON_SHOTGUN_PUMP",
"WEAPON_SHOTGUN_REPEATING",
"WEAPON_SHOTGUN_SAWEDOFF",
"WEAPON_SHOTGUN_SEMIAUTO",
"WEAPON_BOW",
"WEAPON_THROWN_DYNAMITE",
"WEAPON_THROWN_MOLOTOV"
}
7 Likes

serverside code for a resource that lets you start all resources for your server with one resource, and stops them all when this resource is stopped. also sets gamemode and map name

local server_name = "Missouri Missions";

local gamemode_name = "Gun Game";
local map_name = "St. Louis";

local seperator = "=================================";

local resources = {
	"MM_Gamemode",
	"MM_IPL",
	"MM_Map",
	"MM_Whitelist",
	
	"chat",
}

AddEventHandler("onResourceStart",
	function(resourceName)
		if (GetCurrentResourceName() ~= resourceName) then return end
		
		print("Starting Server: " .. server_name);
		print(seperator);
		
		for i = 1, #resources do
			resource_name = resources[i];
			print("Starting: " .. resource_name);
			StartResource(resource_name);
		end
		
		SetGameType(gamemode_name);
		SetMapName(map_name);
		
		print(seperator);
	end
)

AddEventHandler("onResourceStop",
	function(resourceName)
		if (GetCurrentResourceName() ~= resourceName) then return end
		
		print("Stopping Server: " .. server_name);
		print(seperator);
		
		for i = 1, #resources do
			resource_name = resources[i];
			print("Stopping: " .. resource_name);
			StopResource(resource_name);
		end
		print(seperator);
	end
)
2 Likes

Usable Enum of all blips: https://pastebin.com/TjiMPAYP

3 Likes

how to give yourself a weapon with a command
server.lua

RegisterCommand("asd",
    function(source, args, rawCommand)
        if (source > 0) then
            TriggerClientEvent("chat:addMessage", -1, {
                args = {
                    "[INFO]",
                    "Sending to client...."
                },
                color = { 5, 255, 255 }
            })
            
            TriggerClientEvent("core:test",source,source);
        end
    end, 
false)

client.lua

RegisterNetEvent("core:test");
AddEventHandler("core:test", 
    function(author,thePlayer)
        TriggerEvent('chat:addMessage', {args = { "[INFO] " .. "...client recieved" }});
        
        if (IsWeaponValid(0xDB21AC8C)) then
            TriggerEvent('chat:addMessage', {args = { "[INFO] " .. "VALID HASH" }});
        else
            TriggerEvent('chat:addMessage', {args = { "[INFO] " .. "INVALID HASH" }});
        end
        
        TriggerEvent('chat:addMessage', {args = { "[INFO] " .. "Player: " .. GetPlayerName(thePlayer) }});        
        
        GiveWeaponToPed_2(GetPlayerPed(thePlayer),0xDB21AC8C,1,true,true,GetWeapontypeGroup(0xDB21AC8C),true,0.5,1.0,0,true,0,0);
        --GiveWeaponToPed_2([[ped]],[[weaponHash]],[[ammoCount]],[[equipNow]],[[giveWeapon]],[[weaponGroup]],[[giveAmmo]],0.5,1.0,? int, ? bool,0,0);
    end
);
1 Like

I got these client side to test stuff… basic stuff that “could” … “maybe” … help someone out there
I input these in F8 console obviously

–> Redm Weapons Hashes List

	RegisterCommand("give_knife",function(source) -- "WEAPON_MELEE_KNIFE"
		GiveWeaponToPed_2(PlayerPedId(),0xDB21AC8C,1,true,true,GetWeapontypeGroup(0xD49321D4),true,0.5,1.0,0,true,0,0) -- group melee = 0xD49321D4
	end)

	RegisterCommand("give_machete",function(source) -- "WEAPON_MELEE_MACHETE"
		GiveWeaponToPed_2(PlayerPedId(),0x28950C71,1,true,true,GetWeapontypeGroup(0xD49321D4),true,0.5,1.0,0,true,0,0) -- group melee = 0xD49321D4
	end)

	RegisterCommand("give_lasso",function(source, args) -- "WEAPON_LASSO"
		GiveWeaponToPed_2(PlayerPedId(),0x7A8A724A,1,true,true,GetWeapontypeGroup(0x126210C3),true,0.5,1.0,0,true,0,0)
	end)

	RegisterCommand("give_torch",function(source, args) -- "WEAPON_MELEE_TORCH"
		GiveWeaponToPed_2(PlayerPedId(),0x67DC3FDE,1,true,true,GetWeapontypeGroup(0xD49321D4),true,0.5,1.0,0,true,0,0) -- group melee = 0xD49321D4
	end)

	RegisterCommand("give_bow",function(source, args) -- "WEAPON_BOW"
		local AmmoToGive = 40 -- max 40
		GiveWeaponToPed_2(PlayerPedId(),0x88A8505C,AmmoToGive,true,true,GetWeapontypeGroup(0xB5FD67CD),true,0.5,1.0,0,true,0,0) -- bow = 0xB5FD67CD   .. ammo 0xB0B80B9A
	end)
	
	RegisterCommand("give_winch",function(source, args) -- "WEAPON_REPEATER_WINCHESTER"
		local AmmoToGive = 200 -- max 200
		GiveWeaponToPed_2(PlayerPedId(),0xA84762EC,AmmoToGive,true,true,GetWeapontypeGroup(0x39D5C192),true,0.5,1.0,0,true,0,0) -- rifle = 0x39D5C192  ..  ammo 0xB0B80B9A  
	end)
1 Like

Fill in the back of the Valentine Jail, the Valentine Saloon windows, and the bed in the Valentine Saloon as well as curtains and windows for the Valentine Bank and turn on general store night light:

AddEventHandler('playerSpawned', function(spawn)
    getValJail()
    getValBank()
    getValSaloon()
    getValSaloon2()
    getValGenstore()
end)

function getValBank()
    local interior = GetInteriorAtCoords(-308.88, 777.37, 118.77)
    local isValid = IsValidInterior(interior)
    if isValid then
        if IsInteriorReady(interior) then
            if IsInteriorEntitySetActive(interior, "val_bank_front_windows") then
                print("Valentine Bank Interior Already Active")
            else
                ActivateInteriorEntitySet(interior, "val_bank_int_curtainsopen") -- val_bank_int_curtainsclosed
                -- ActivateInteriorEntitySet(interior, "val_bank_mud5_windowblock")
                ActivateInteriorEntitySet(interior, "val_bank_front_windows")
                print("Valentine Bank Interior Activated")
            end
        end
    end
end
function getValSaloon()
    local interior = GetInteriorAtCoords(-310.0119, 802.9316, 117.9846)
    local isValid = IsValidInterior(interior)
    if isValid then
        if IsInteriorReady(interior) then
            if IsInteriorEntitySetActive(interior, "front_windows") then
                print("Valentine Saloon Interior Already Active")
            else
                ActivateInteriorEntitySet(interior, "front_windows")
                ActivateInteriorEntitySet(interior, "val_saloon_br03_bed")
                print("Valentine Saloon Interior Activated")
            end
        end
    end
end
function getValSaloon2()
    local interior = GetInteriorAtCoords(-306.48, 803.07, 118.97)
    local isValid = IsValidInterior(interior)
    if isValid then
        if IsInteriorReady(interior) then
            if IsInteriorEntitySetActive(interior, "6_chair_poker_set") then
                print("Valentine Saloon Interior Already Active")
            else
                ActivateInteriorEntitySet(interior, "6_chair_poker_set")
                print("Valentine Saloon Interior Activated")
            end
        end
    end
end
function getValJail()
    local interior = GetInteriorAtCoords(-273.4513, 811.3408, 118.38)
    local isValid = IsValidInterior(interior)
    if isValid then
        if IsInteriorReady(interior) then
            if IsInteriorEntitySetActive(interior, "val_jail_int_walla") then
                print("Valentine Jail Interior Already Active")
            else
                ActivateInteriorEntitySet(interior, "val_jail_int_walla")
                ActivateInteriorEntitySet(interior, "val_jail_int_wallb")
                print("Valentine Jail Interior Activated")
            end
        end
    end
end
function getValGenstore()
    local interior = GetInteriorAtCoords(323.0087, 801.0296, 116.8817)
    local isValid = IsValidInterior(interior)
    if isValid then
        if IsInteriorReady(interior) then
            if IsInteriorEntitySetActive(interior, "val_genstore_night_light") then
                print("Valentine Jail Interior Already Active")
            else
                ActivateInteriorEntitySet(interior, "val_genstore_night_light")
                print("Valentine General Store Nightlight Activated")
            end
        end
    end
end
2 Likes

Little system for blips, removes all blips from map when resource is stopped. This can easily be expanded on to suit your needs.
Using {‘Sargasm’, 1247852480, 5487.8, 2939.21, 0.38, 306.84}, as an example, the entries are ‘Blip name’, x pos, y pos, z pos, rotation
(Note: blip name and rotation are unused)

client.lua

--Blips Setup------------
-------------------------
	server_blips = {}

--Blips Table------------
-------------------------	
	blip_table = {
		["Tumbleweed"] = {
			{'Slappys Cavern',	1247852480,		5487.8, 2939.21, 0.38, 306.84},
			{'Butte Gorge',		1247852480,		5487.8, 2939.21, 0.38, 306.84},
			{'Noodie Boodie',	1247852480,		5487.8, 2939.21, 0.38, 306.84},
		},
		["Valentine"] = {
			{'Sargasm',			1247852480,		5487.8, 2939.21, 0.38, 306.84},
		},
		["Strawberry"] = {
			{'Lisp',			1247852480,		5487.8, 2939.21, 0.38, 306.84},
			{'Shadow Logs',		1247852480,		5487.8, 2939.21, 0.38, 306.84},
		},
	}


--Events-----------------
-------------------------
AddEventHandler("onResourceStart",
	function(resourceName)
		if (GetCurrentResourceName() ~= resourceName) then return end
		
		for i,row in pairs(blip_table) do
			server_blips[#row] = {}
			for j,v in ipairs(blip_table[i]) do
				server_blips[#row][j] = Citizen.InvokeNative(0x554D9D53F696D002, v[2],v[3],v[4],v[6])
			end
		end
	end
)

AddEventHandler("onResourceStop",
	function(resourceName)
		if (GetCurrentResourceName() ~= resourceName) then return end
		
		for i,v in pairs(server_blips) do
			for i,row in pairs(blip_table) do
				for j,v in ipairs(blip_table[i]) do
					RemoveBlip(server_blips[#row][j])
					server_blips[#row][j] = nil
				end
				server_blips[#row] = nil
			end
			server_blips = nil
		end
	end
)
1 Like

thank you for the code but say that I wanted to make a script to display blips certain places how would I do that

1 Like
1 Like

Is there a way to equip(/make usable) the special guns from base game on a redM server?