Giving players items on spawn?

I don’t know, I’m not at home now so I can’t test, but if the original code work, no reason this one doesn’t work and I never use playerSpawned in my script…

I probably do something like that:

Citizen.CreateThread(function ()
	while true do
	Citizen.Wait(0)
		if NetworkIsSessionStarted() then
			local player = GetPlayerPed(-1)
                        local gadget = GetHashKey("GADGET_PARACHUTE")
	                       SetPedGadget(player, gadget, 1, false)
			return
		end
	end
end) 

in resources[system]\spawnmanager\spawnmanager.lua

i put that code for test with snawball

AddEventHandler('playerSpawned', function(spawn)
    local player = GetPlayerPed(-1)
    local weapon = GetHashKey("weapon_snowball")

	GiveWeaponToPed(player, weapon, 10, false)

end)

And it’s work, i have 10 snowball :wink:

For parachute i tried this code

AddEventHandler('playerSpawned', function(spawn)
    local player = GetPlayerPed(-1)
    local gadget = GetHashKey("gadget_parachute")

	SetPedGadget(player, gadget, 1, false)

end)

But not work… i will try another time, thanks for help ! and if you find a solution tell me (it’s just a test)

“p2 is always true”

SetPedGadget(player, gadget, true)

this could probably explain why it doesn’t work? Didn’t try this myself.

also, where did the 1 come from? It’s not supposed to be there.

So if i want to spawn a car i should do this? Where do i need to add coordinates of the vehicle?
Or maybe to spawn the ped inside of the vehicle?

AddEventHandler('playerSpawned', function(spawn)
    local player = GetPlayerPed(-1)
    local vehicle = GetHashKey("vehicle_sabregt")

	SetPedVehicle(player, vehicle, 1, true)

end)
AddEventHandler('playerSpawned', function(spawn)
local player = GetPlayerPed(-1)
local vehicle = GetHashKey("sabregt")
local coords = GetOffsetFromEntityInWorldCoords(playerPed, 0, 5.0, 0)
local car = CreateVehicle(vehicle, coords, 0.0, true, false)

		SetPedIntoVehicle(player, car, -1)
end)

This SHOULD work, again, i didn’t test it.
where did you get SetPedVehicle from? It doesn’t exist.

also, vehicle_sabregt isn’t a thing either.

You should look up the natives in here: http://www.dev-c.com/nativedb/

Okay thanks! I needed that, i’m a big noob so dont mind :smiley: thanks on the link too!

Hi and thanks for help.

i tried this code:

AddEventHandler('playerSpawned', function(spawn)
    local player = GetPlayerPed(-1)
    local gadget = GetHashKey("gadget_parachute")

	SetPedGadget(player, gadget, true)

end)

not work (i put it in spawnmanager.lua like the code for the snowball) if you have idea ?

I wonder if there is a way to get this to work with thermal vision? The night vision in this game is shit, but the thermal is pretty cool.

Is there a way to give players more than 10 snowballs? If I try to give them 100 it still only gives the player 10.

The maximum is 10 on the game which means not possible (i believe)

I thought it’s possible to increae the limit somehow.

is there a way to give players multiple weapons?

i would like these:

  1. Combatpistol
  2. Stungun
    3.Carbinerifle
  3. Flashlight
  4. Nightstick
  5. Pump shotgun
AddEventHandler('playerSpawned', function(spawn)
 
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_COMBATPISTOL"), 1000, 0, 1)
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_STUNGUN"), 1000, 0, 1)
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_CARBINERIFLE"), 1000, 0, 1)
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_NIGHTSTICK"), 1000, 0, 1)
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_PUMPSHOTGUN"), 1000, 0, 1)
end)

should work.

@Mannot I think it should look like this on your server, using the example of @schneehaze

__resource.lua

resource_manifest_version '77731fab-63ca-442c-a67b-abc70f28dfa5'

client_script "client.lua"

client.lua

AddEventHandler('playerSpawned', function(spawn)
 
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_COMBATPISTOL"), 1000, 0, 1)
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_STUNGUN"), 1000, 0, 1)
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_CARBINERIFLE"), 1000, 0, 1)
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_NIGHTSTICK"), 1000, 0, 1)
                GiveWeaponToPed(playerPed, GetHashKey("WEAPON_PUMPSHOTGUN"), 1000, 0, 1)
end)

And add the script to your citmp-server.

@Pentine there is a thermal vision in the enhanced reborn trainer

Can anyone see why this may not be working?

TriggerEvent('es:addAdminCommand', 'cop', permission.kick, function(source, args, user)
	GiveWeaponToPed(playerPed, GetHashKey("WEAPON_PISTOL50"), 1000, 0, 1)
	GiveWeaponToPed(playerPed, GetHashKey("WEAPON_STUNGUN"), 1000, 0, 1)
	GiveWeaponToPed(playerPed, GetHashKey("WEAPON_NIGHTSTICK"), 1000, 0, 1)
	GiveWeaponToPed(playerPed, GetHashKey("WEAPON_PUMPSHOTGUN"), 1000, 0, 1)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Welcome Officer, Firearms have been supplied.")
end, function(source, args, user)

end)

It’s in my sv_admin.lua file which is part of Essential

EDIT - I’ve found a way to do it, will release it later :wink:

I tried this but it doesn’t seem to work… Did you try this yourself?

I got it working, I’ll put a post up soon. Got it on spawn, and commands that have loadouts aswell.

EDIT - Will make a post today (Tuesday) just have to fix a few things.

2 Likes

I tested it now, and it doesn’t work indeed. Don’t ask me why, it should work. At least that’s what i thought, lol.

Will wait for @Leah_UK’s post.

This is what i’ve got, i’ve made sure to give you credit :slight_smile: [Release] Loadout System

1 Like