Jump to content

triggerClientEvent


Ivo1313

Recommended Posts

Hello guys, i'm doing a gunshop script but i dont know how to use triggerClientEvent properly for this situations, i have the client and server program here but they're not working for now:

Server

marcador = createMarker(296.60345458984,-38.278450012207,1000.515625, "cylinder", 1.1, 0,100,0)
setElementInterior(marcador, 1)

function showPanel(thePlayer)
    triggerClientEvent ("Start", thePlayer)
end
addEventHandler("onMarkerHit", marcador, showPanel)

Client

function painel (hitPlayer)
    if ( hitPlayer == localPlayer ) then
    outputChatBox("aloboizaumm")
    if painel == false then
        showCursor (true)
        addEventHandler ("onClientRender", root,abrir)
        painel = true
    end
end
addEvent("Start", true)
addEventHandler("Start", root, painel)

 

Link to comment

Imagine that server has ~100 players on it. You're telling the server to open panel on client-side. The server doesn't know which player you're talking about and it opens it on every single client. This is what happens when you use

triggerClientEvent("Start", ThePlayer)

To fix it tell the server to use specific client(player) by adding player variable as the first argument:

triggerClientEvent(ThePlayer, "Start", ThePlayer)

Same thing was shown above

BTW this is the single difference between triggerClientEvent and triggerServerEvent

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