Jump to content

triggerClientEvent


Snow-Man

Recommended Posts

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

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

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