Snow-Man Posted February 7, 2017 Share Posted February 7, 2017 everytime, when i use triggerClientEvent, it's doesn't work but sometimes do it's said client event isn't added here my script server : function onMarkerBankHit(player, matchingDimension) if getElementData(source, "USC.Bank") and not isGuestAccount(hitPlayer) then if (getElementType(player) ~= "player" or not matchingDimension) then return end if (isPedInVehicle(player) or not isPedOnGround(player)) then return end local account = getAccountName(getPlayerAccount(player)) triggerClientEvent(player,"USCbank:showBankGUI",player,account) end end addEventHandler("onMarkerHit", root, onMarkerBankHit) client : addEvent("USCbank:showBankGUI", true) addEventHandler("USCbank:showBankGUI", root, function (account) guiSetVisible(USC.window[1], true) showCursor(true) guiSetText(USC.label[1], "Account Name : "..account) end) Link to comment
nikitafloy Posted February 7, 2017 Share Posted February 7, 2017 variable in function - player in body function - hitPlayer Link to comment
3aGl3 Posted February 8, 2017 Share Posted February 8, 2017 You need to trigger the client event onto the same element. For example on the server side: triggerClientEvent( client, "onClientNeedsThingsDone", resourceRoot, some_variable ) and on the client side you will in turn need: addEvent( "onClientNeedsThingsDone", true ) -- true makes sure you can trigger it from the server side addEventHandler( "onClientNeedsThingsDone", resourceRoot, getThingsDone ) Note that I attached the handler to the resourceRoot and triggered the event on the resourceRoot. To make sure only the right player gets the event there is the first variable in the triggerClientEvent, which can either be an element or a table. Link to comment
pa3ck Posted February 8, 2017 Share Posted February 8, 2017 As nikitafloy said, he has an undefined variable in the function isGuestAccount(hitPlayer) -- hitPlayer is undefined, use player instead Link to comment
Snow-Man Posted February 8, 2017 Author Share Posted February 8, 2017 23 hours ago, nikitafloy said: variable in function - player in body function - hitPlayer i know that, i forget to change it, i have changed that when i tried to make this topic idk why it's works sometimes, anyways it's works now and i didn't change anything on my code Link to comment
nikitafloy Posted February 9, 2017 Share Posted February 9, 2017 8 hours ago, Snow-Man said: i know that, i forget to change it, i have changed that when i tried to make this topic idk why it's works sometimes, anyways it's works now and i didn't change anything on my code u need give us full code with all define variables, may b ur mistake there and if it work sometimes then u need check ur variables with outputChatBox or outputDebug 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