gokalpfirat Posted August 11, 2016 Share Posted August 11, 2016 for j,l in ipairs(getElementsByType("player")) do triggerEvent("disableClientPickup",l,v.colshape,v.pickup,getElementData(source,"respawn")) setElementData(source,"respawnTimer",true,true) end I try to trigger an event for all players. I know I must do it with server-side code but I cant. I need to find a solution for client and I dont know how? I try lastly code below but not works. Link to comment
KariiiM Posted August 12, 2016 Share Posted August 12, 2016 Can I know what are you trying to do? and post a full code instead of this less detailed code. Link to comment
gokalpfirat Posted August 12, 2016 Author Share Posted August 12, 2016 event is this function disableClientPickup(colshape,pickup,timer) setElementAlpha(pickup,0) setTimer(loadPickup,timer,1,pickup,colshape) end addEvent("disableClientPickup",true) addEventHandler("disableClientPickup",getRootElement(),disableClientPickup) function loadPickup(pickup,colshape) setElementAlpha(pickup,255) setElementData(colshape,"respawnTimer",false,true) end I want to set Alpha of pickup object but if I try to do this at server side with triggerServerEvent I cant send pickup object via argument. Link to comment
KariiiM Posted August 12, 2016 Share Posted August 12, 2016 Show the other side's code. Link to comment
gokalpfirat Posted August 12, 2016 Author Share Posted August 12, 2016 If I try to show every part there thousand lines of code. These are simply show. If you cant understand from my code. To sum up I create pickups client side. But I need to change their alpha to all players. How can I trigger an event for all players but I need to do this in client side code. Link to comment
KariiiM Posted August 12, 2016 Share Posted August 12, 2016 If I try to show every part there thousand lines of code. These are simply show. If you cant understand from my code. To sum up I create pickups client side. But I need to change their alpha to all players. How can I trigger an event for all players but I need to do this in client side code. If you created the pickup object client sided only the localplayer who can see it, so the other players will not see your pickup's alpha. Link to comment
gokalpfirat Posted August 12, 2016 Author Share Posted August 12, 2016 Ok I want to change every players pickup object's alpha and need to do this at client side Because I created this object at client side Link to comment
Bonus Posted August 12, 2016 Share Posted August 12, 2016 Then trigger (from server to client) the alpha and change the alpha of the pickup to this triggered alpha. You can't trigger directly from client to client. Link to comment
kashtesov Posted August 12, 2016 Share Posted August 12, 2016 lol, maybe it will works --client function triggerClientEventFromClient(sendto,event,baseelement,...) triggerServerEvent("triggerClientEventFromClient",resourceRoot,baseelement,sendto,event,...) end --server addEvent("triggerClientEventFromClient",true) function triggerClientEventFromClient(baseelement,sendto,event,...) triggerClientEvent(sendto,event,baseelement,...) end addEventHandler("triggerClientEventFromClient",getRootElement(),triggerClientEventFromClient) Link to comment
gokalpfirat Posted August 12, 2016 Author Share Posted August 12, 2016 Nope I think the problem is when trying to trigger with server. Client cant send pickup and colshape to server. lol, maybe it will works --client function triggerClientEventFromClient(sendto,event,baseelement,...) triggerServerEvent("triggerClientEventFromClient",resourceRoot,baseelement,sendto,event,...) end --server addEvent("triggerClientEventFromClient",true) function triggerClientEventFromClient(baseelement,sendto,event,...) triggerClientEvent(sendto,event,baseelement,...) end addEventHandler("triggerClientEventFromClient",getRootElement(),triggerClientEventFromClient) Link to comment
kashtesov Posted August 13, 2016 Share Posted August 13, 2016 Nope I think the problem is when trying to trigger with server. Client cant send pickup and colshape to server. if you create pickup on client, ye, you can't it. try create unique ID for pickup and colshape, and send ID to another players Link to comment
Bonus Posted August 13, 2016 Share Posted August 13, 2016 What are you trying to do? If you create a pickup clientsided the other players won't see it. So you don't need to trigger the pickup or the alpha, cause only the creator-client will see it. But if you want to create a pickup for all clients and then want to change the alpha at all clients you have to trigger the alpha from the server to all clients. Don't know why you guys trying to trigger the clientsided pickup. Why should player y know about the pickup created by player x clientsided. Player y will never see that pickup. -- server -- addCommandHandler ( "changepickupalpha", function ( player, _, alpha ) triggerClientEvent ( "changePickupAlpha", player, tonumber ( alpha ) or 255 ) end ) -- client -- local pickup = createPickup ( ... ) addEvent ( "changePickupAlpha", true ) addEventHandler ( "changePickupAlpha", root, function ( alpha ) setElementAlpha ( pickup, alpha ) end ) 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