Genius Posted June 1, 2012 Posted June 1, 2012 I made Arms Delar and when player hit my marker then he buy colt45 and his money is tanke but i didnt get money Server side: function give45 ( seller ) giveWeapon ( source, 22, 15, true) takePlayerMoney ( source, 100 ) if ( getElementModel( seller ) == 103 ) then givePlayerMoney ( seller, 200 ) end end addEvent("give45",true) addEventHandler("give45",getRootElement(),give45) Client side: addEventHandler ( "onClientGUIClick", getRootElement(), function give45 () if ( source == GUIEditor_Button[1] ) then triggerServerEvent ("give45",getLocalPlayer(),give45) end end addEventHandler ( "onClientGUIClick", getRootElement(),give45)
Castillo Posted June 1, 2012 Posted June 1, 2012 That's because "seller" argument is nil, you're not triggering a player element.
Jaysds1 Posted June 1, 2012 Posted June 1, 2012 try this, Client: addEventHandler ( "onClientGUIClick",guiRoot,function() --if your attaching a function to an event, don't name it if ( source == GUIEditor_Button[1] ) then triggerServerEvent ("give45",localPlayer) --don't add the title again end end) -- forgot this Server: function give45 () --the player that's selling is the client/source of this, so there's no need for seller giveWeapon ( client, 22, 15, true) takePlayerMoney ( client, 100 ) if ( getElementModel( client ) == 103 ) then givePlayerMoney ( client, 200 ) end end addEvent("give45",true) addEventHandler("give45",root,give45) and please read the comments
Castillo Posted June 2, 2012 Posted June 2, 2012 Jaysd, no offense but that's not right I think, if is an Arms Dealer, then there must be a Dealer and the player who buys the weapons.
Genius Posted June 2, 2012 Author Posted June 2, 2012 Bad argument @ "getElementModel" addEventHandler ( "onClientGUIClick",guiRoot,function(theSeller) local theSkin = getElementModel ( theSeller ) if ( theSkin == 103 ) and getElementType(theSeller) == "player" then if ( source == GUIEditor_Button[1] ) then triggerServerEvent ("give45",localPlayer) end end end)
top sniper Posted June 2, 2012 Posted June 2, 2012 addEventHandler ( "onClientGUIClick",guiRoot,function(theSeller) if getElementType(theSeller) == "player" then local theSkin = getElementModel ( theSeller ) if ( theSkin == 103 ) and ( source == GUIEditor_Button[1] ) then triggerServerEvent ("give45",localPlayer) end end end)
Guest Guest4401 Posted June 2, 2012 Posted June 2, 2012 addEventHandler("onClientGUIClick",root, function() if source == GUIEditor_Button[1] then if getElementModel(localPlayer) == 103 then triggerServerEvent("give45",localPlayer) end end end )
Genius Posted June 2, 2012 Author Posted June 2, 2012 Bad argument @ "getElementModel" Whats the problem? function give45 (firstPlayer, seller) if (getElementModel(seller)==103) then givePlayerMoney (seller, 400 ) giveWeapon ( firstPlayer, 22, 15, true) takePlayerMoney ( firstPlayer, 100 ) end end addEvent("give45",true) addEventHandler("give45",root,give45)
Al3grab Posted June 2, 2012 Posted June 2, 2012 is the dealer player or ped ? , if he is a ped you can't give him money !
Al3grab Posted June 2, 2012 Posted June 2, 2012 use that and you have to define the seller in 'theSeller' variable. addEventHandler ( "onClientGUIClick", getRootElement(), function () local theSeller = theseller -- define the seller here if ( source == GUIEditor_Button[1] and theSeller) then triggerServerEvent ("give45",getLocalPlayer(),theSeller) end end ) function give45 (theSeller) if theSeller then takePlayerMoney(source,100) givePlayerMoney(theSeller,400) giveWeapon(source,22,15,true) end end addEvent("give45",true) addEventHandler("give45",root,give45)
Genius Posted June 2, 2012 Author Posted June 2, 2012 use that and you have to define the seller in 'theSeller' variable. addEventHandler ( "onClientGUIClick", getRootElement(), function () local theSeller = theseller -- define the seller here if ( source == GUIEditor_Button[1] and theSeller) then triggerServerEvent ("give45",getLocalPlayer(),theSeller) end end ) function give45 (theSeller) if theSeller then takePlayerMoney(source,100) givePlayerMoney(theSeller,400) giveWeapon(source,22,15,true) end end addEvent("give45",true) addEventHandler("give45",root,give45) Doesnt work No debug errors
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