Jump to content

[Help] addEventHandler question


Gordon_G

Recommended Posts

Hello !

So maybe you will think I'm stupide but I have a basic question ...

I try to make something like this : server -> client -> server.

Show that :

  
-- first : Server 
function perceporte2(source) 
pos1,pos2,pos3 = getElementPosition(source) 
perceporteobject = createObject(3031,pos1,pos2,pos3) 
triggerClientEvent("perceporteson2",source, pos1,pos2,pos3) 
end 
addCommandHandler("perceporte2", perceporte2) 

  
-- second : Client 
addEvent("perceporteson2", true) 
function perceporteson2(a,b,c) 
local perceporteson = playSound3D("perce-porte.wav",a,b,c,true) 
setTimer( function(a) 
stopSound(perceporteson) 
triggerServerEvent("portelocked2",localPlayer) 
end, 1000,1,perceporteson) 
end  
addEventHandler("perceporteson2", getRootElement(),perceporteson2) 

  
-- third : Server 
function portelocked2() 
destroyElement(perceporteobject) 
end 
addEventHandler("portelocked2", getRootElement(), portelocked2) 
  

It's not exactly what I want to make but it's the idea so, don't say me : "Just make the commandHandler in client script." :D

Ok, the script work but ... When there is two players ...

786737error.jpg

So someone could explain me ? Please :roll:

Link to comment

Make a table for the object each player.

like

  
perceporteobject = {} -- place this on top of the script 
--Then instead of perceporteobject on line 5, it should be 
perceporteobject[source] = createObject(...) -- store createObject for said player to the table 
  
--and then to destroy it 
if isElement(perceporteobject[source]) then 
destroyElement(perceporteobject[source]) 
end 
  

Edited by Guest
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...