Jump to content

trigger giveWeapon


Kelly003

Recommended Posts

Posted

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

Posted

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);

 

 

Posted

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

Posted

Then you probably need onClientGUIClick instead of onClientClick.

onClientClick is an event for general purpose clicking detection.

onClientGUIClick is an event for detection of clicking of GUI elements. You can bind different handler functions to different buttons.

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...