Jump to content

trigger giveWeapon


Kelly003

Recommended Posts

how to add a weapon via event onClientClick? I know it needs to be done with a server trigger but I don't know how to do it. I want to do so that when I click on a given point, she gives a deal with 60 ammo and if I click on the second point, she gives ak47

Link to comment

Server-side

-- Function for give weapon
function giveWeaponToPlayer()
	--The weapon is given to the player 
	giveWeapon(client,31,60);
end
-- A new event is created 
addEvent("giveMeWeapon");
-- Execute the `giveWeaponToPlayer` function when calling the event from the client side 
addEventHandler("giveMeWeapon",root,giveWeaponToPlayer);

Client-side

function onLocalPlayerClick(button,state)
	if button == "left" then
		if state == "up" then
			-- The `giveMeWeapon` event is executed 
			triggerServerEvent("giveMeWeapon",localPlayer);
		end
	end
end
addEventHandler("onClientClick",localPlayer,onLocalPlayerClick);

 

 

Link to comment

I want to do a gunshop and I have a few buttons done, but if I click on the first button, it gives me ak with 60 ammo and if I click on the second button, it gives me a m4 with 120 ammo

I want to do a gunshop and I have a few buttons done, but if I click on the first button, it gives me ak with 60 ammo and if I click on the second button, it gives me a m4 with 120 ammo

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...