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.
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).
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.
local weapons = {
"WEAPON_PISTOL",
"WEAPON_AUTOSHOTGUN"
}
for i = 1,#weapons do
GiveWeaponToPed(playerPed, GetHashKey(weapons[i]), 100, false)
end
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