[REQUEST] Making players spawn with a specific skin and all weapons

So far, all the loadout mods I’ve seen talk about a user typing a command in chat, but I was looking for something forced upon the player as they spawn in. I really hate how skins randomize and how I need to give myself all weapons everytime I die. I would code this but unfortunately my lua knowledge is limited to some ComputerCraft about 5 years ago.

So what I’m exactly looking for is a script that would make the player’s skin the blackops2 skin and automatically give all weapons at spawn. Unfortunately for the weapons, I can’t seem to find a way to give all weapons. All methods I’ve seen involve dropping each weapon one by one.

Anyways, thanks for your help!

Pretty simple, actually. This would be a client-side file.

AddEventHandler("playerSpawned", function()
	-- https://wiki.fivem.net/wiki/SetPlayerModel
	local model = GetHashKey("s_m_y_blackops_02")
	local playerPed = GetPlayerPed(-1)
	RequestModel(model)
	while not HasModelLoaded(model) do
		Citizen.Wait(0)
	end
	SetPlayerModel(PlayerId(), model)
	SetModelAsNoLongerNeeded(model)
	
	-- GiveWeaponToPed(ped, hashOfWeapon, AmmoAmount, false)
	-- https://wiki.fivem.net/wiki/GiveWeaponToPed
    -- Weapons: https://wiki.fivem.net/wiki/Weapons
    -- Either make a for loop iterate a table of weapons, or just put each weapon on a line, like so:
	GiveWeaponToPed(playerPed, GetHashKey("WEAPON_PISTOL"), 100, false)
    GiveWeaponToPed(playerPed, GetHashKey("WEAPON_AUTOSHOTGUN"), 100, false)
end)

In the resources folder is a list of spawnpoints you can edit (resources/fivem-map-skater/map.lua), these specify where the player will spawn and with which skin, modify those to your needs.

Ex:
spawnpoint "a_m_y_skater_01" { x = -802.311, y = 175.056, z = 72.8446 }
spawnpoint "[model_name]" { [position] }

For the weapon loadouts, you can use an existing resource:

(It might need some tweaking, it’s a rather old resource).

Thanks, I managed to change the spawnpoint but I was never smart enough to figure out that the first part was the player skin! This is great thanks!

Great thanks! Could you explain the comment about the for loop iterate? Punching in 100 lines of weapon names seems like a hassle that I’d like to avoid.

Something like this…

local weapons = {
    "WEAPON_PISTOL",
    "WEAPON_AUTOSHOTGUN"
}

for i = 1,#weapons do 
     GiveWeaponToPed(playerPed, GetHashKey(weapons[i]), 100, false)
end

:slight_smile:

You probably want it to be an associate array:

local weaponData = {
    pistol = { "WEAPON_PISTOL", 100}
    shotgun = {"WEAPON_AUTOSHOTGUN", 200}
}

for _, v in pairs(weaponData) do
   GiveWeaponToPed(playerPed, GetHashKey(v[0]), v[1], false)
end

This way you can also assign the ammo.

1 Like