Kelly003 Posted August 5, 2021 Posted August 5, 2021 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
Moderators IIYAMA Posted August 5, 2021 Moderators Posted August 5, 2021 2 hours ago, Kelly003 said: how to add a weapon via event onClientClick? You can use https://wiki.multitheftauto.com/wiki/BindKey as replacement. You can bind it on specific keys like 'mouse1' (left click) or control names like 'fire', to achieve your goal.
_SAXI_ Posted August 5, 2021 Posted August 5, 2021 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);
Kelly003 Posted August 6, 2021 Author Posted August 6, 2021 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
DiSaMe Posted August 6, 2021 Posted August 6, 2021 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now