Giving players items on spawn?

any idea why SetPedGadget(GetPlayerPed(-1), 0xFBAB5776, true) isn’t working?

even

local player = GetPlayerPed(-1)
local gadget = GetHashKey("gadget_parachute")

	SetPedGadget(player, gadget, true)

is not working

You aren’t loading the model anywhere, that could be the cause, just a guess.

 local player = GetPlayerPed(-1)
            local gadget = GetHashKey("gadget_parachute")
            RequestModel(gadget)
            while not HasModelLoaded(gadget) do
                Wait(1)
           end
            SetPedGadget(player, gadget, true)

same…

Are you sure it’s “gadget_parachute” and not just “parachute”?

el stupido :thinking:

`GiveWeaponToPed(player, gadget, 1, 0, 1)`

Any way to do this without the use of essential mode base? All I’m looking for is all players be given a specified set of weapons on spawn.

1 Like

As previously mentioned on here (somewhere) you could add:

-- Default Loadout
AddEventHandler('playerSpawned', function(spawn)
	GiveWeaponToPed(playerPed, GetHashKey("WEAPON_KNIFE"), 1000, 0, 1)
	GiveWeaponToPed(playerPed, GetHashKey("WEAPON_PISTOL"), 1000, 0, 1)
end)

To a client.lua file. Hopefully that helps :wink: Weapons can be found here: https://www.se7ensins.com/forums/threads/weapon-and-explosion-hashes-list.1045035/

EDIT: Actually, I believe that may utilize EssentialMode.

I’ve made a script for a vehicle spawn that is being triggered on command /t20
But sadly it doesn’t work… :confused:

AddEventHandler("chatMessage", function(p, color, msg)
    if msg:sub(1, 1) == "/" then
        fullcmd = stringSplit(msg, " ")
        cmd = fullcmd[1]
        args = makeArgs(fullcmd)
                 
     if cmd == "/t20" then
                TriggerClientEvent("chatMessage", p, "INFO", {255, 0, 0}, vehicle .. "has been spawned" )
                local player = GetPlayerPed(-1)
                local vehicle = GetHashKey("t20")
                local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 5.0, 0.0)
                local car = CreateVehicle(vehicle, coords, 0.0, true, false)
        
    end
        
end)

You could just modify the admin command “/car” that is given with Essentials Mode?

Hmmmm. I didnt checkout the essentials mode. Gotta do that then

Someone got giving parachite to player work?

I try this:

parachute = GetHashKey("gadget_parachute")
RequestModel(parachute)
while not HasModelLoaded(parachute) do
    Wait(1)
end
SetPedGadget(GetPlayerPed(-1), parachute,  true)

Not working…

EDIT: After some test, the script do pass this step:

while not HasModelLoaded(parachute) do
    Wait(1)
end

Well, if I comment it, the script is executed, but the parachute is not given to the player…

1 Like

this feature is a secret think maybe cz no support help :smiley: or maybe no one can make it work

Hello,

I would like to add a body armor to the cop, I already try something :

						GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("WEAPON_NIGHTSTICK"), true, true)
						GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("WEAPON_PISTOL50"), 150, true, true)
						GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("WEAPON_STUNGUN"), true, true)
						GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("WEAPON_PUMPSHOTGUN"), 150, true, true)
						GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("WEAPON_BULLPUPRIFLE"), 150, true, true) --TEST BULLPUP
						GiveWeaponToPed(GetPlayerPed(-1), GetHashKey("WEAPON_BODYARMOR"), true, true)

For those that do not use a database, this works perfectly. I use it myself and have duplicated it, changing the commands to allow multiple loadouts. It doesn’t give the player weapons on spawn, but does after you enter a chat command.

https://github.com/Dolware/Loadouts/tree/master/loadouts

do you know how to attach accessory ? Like tactil light ?

1 Like

Is there an updated link? I don’t use EssentialBase and I’m looking for pretty much this.

What is the name of the ammunition for me to spawn in fivem?

for the weapon and WEAPON_ [name of the weapon] and the ammunition

Sorry im new here too and trying to develop a script that adds a lockpick to a custom inventory when a person spawns in, heres the code I have developed so far any help would be appreciated:

AddEventHandler(‘playerSpawned’, function(spawn)
local player = GetPlayerPed(-1)
local item = GetItemName(“lockpick”)

if item < 1 then
	GiveItemtoPed(player, item, 1, false)
else 
	Esx.ShowNotification("You already have a lockpick in your inventory!")

end)

GiveItemToPed doesn’t exist.

what can we use for items?

3 Likes