brocky Posted October 10, 2015 Share Posted October 10, 2015 I was trying to make a weapon shop gui. When you click the button1 it will give you weapon but the problem is i don't get weapon. if button1 == source then x = getPlayerMoney(source) if x >= 60000 then triggerServerEvent("shotgun", root ) giveWeapon( root, 27, 100 ) outputChatBox("You successfully bought a Combat Shotgun") else outputChatBox("You don't have enough cash") end end end addEventHandler( "onClientGUIClick", button1, shotGun, false ) Link to comment
HUNGRY:3 Posted October 10, 2015 Share Posted October 10, 2015 because giveWeapon is server side! you need to trigger Link to comment
Noki Posted October 11, 2015 Share Posted October 11, 2015 giveWeapon( root, 27, 100 ) Using root as the first argument will give it to every player on the server. You should use client on the server-side (assuming you will do what Hungry said and trigger events). Link to comment
brocky Posted October 12, 2015 Author Share Posted October 12, 2015 Can you give me a brief example? Because I didn't actually got what you said about the root function. I understood that it will give the weapon to all player, but how to prevent that? How so? Link to comment
AMARANT Posted October 12, 2015 Share Posted October 12, 2015 Can you give me a brief example? Because I didn't actually got what you said about the root function.I understood that it will give the weapon to all player, but how to prevent that? How so? Change the argument 'root' to your player. And your function giveWeapon is only server-side function. But you're trying to get it work on the client. Link to comment
brocky Posted October 14, 2015 Author Share Posted October 14, 2015 How do i change it to my player FFS? How do i change it to "When someone clicks the button "only" the clicker will get the weapon" not others. Can you state the argument of giveWeapon Link to comment
TAPL Posted October 14, 2015 Share Posted October 14, 2015 triggerServerEvent("shotgun", localPlayer) giveWeapon( source, 27, 100 ) or giveWeapon( client, 27, 100 ) Link to comment
Noki Posted October 14, 2015 Share Posted October 14, 2015 The first argument of giveWeapon is who you want to give the weapon to. By default, root means all elements, everywhere. However, in the case of this function (giveWeapon), if you use root, since it is every element, it will only trigger on the player elements (which can be visualized in the element tree). You can put any other player argument in there. I could put: giveWeapon(getPlayerFromName("Noki"), 27, 100) -- Gives it to a player with the name of 'Noki' -- or giveWeapon(getRandomPlayer(), 27, 100) -- Gives it to one randomly selected player -- or giveWeapon(root, 27, 100) -- Gives it to every player Link to comment
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