Jump to content

[help] triggerServerEvent


Chris!i!

Recommended Posts

Client Side

function deal () 
local localPlayer = getLocalPlayer() 
triggerServerEvent ( "iWantToBuyThis", localPlayer ) 
local money = getPlayerMoney ( localPlayer )   
if money > 200000 then 
takePlayerMoney ( localPlayer, 200000 ) 
  
end 
end 
addEventHandler ( "onClientGUIClick", GUIEditor.button[1], deal ) 

server side

function iWantToBuyThis ( source ) 
giveWeapon ( source, 35, 20 ) 
end 
addEvent( "iWantToBuyThis", true ) 
addEventHandler( "iWantToBuyThis", resourceRoot, iWantToBuyThis ) 

When i press the button[1] nothing happens, it doesnt even take money.

And nothing and yes i have enough money and i dont get the weapon..

Link to comment

Replace source with client in the server side script and remove source from ( ) in the server side. And yes I forgot about that detail. But it would probably be better to put take money server side as to not only take money client side but both client and server side. But you would need to remove the take money from client side.

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