Lormateve Posted January 18, 2018 Share Posted January 18, 2018 I tried several ways to make the communication between client and server, but I can not get to the shop that I am armed, my idea is to make different curtains for groups, and each has a color, I can not get that when the person chooses the object who wants to buy, everyone can see the curtain that I would buy in a different color ... The other problem is how to keep it, it has me really disconnected, thank you for your attention. -- Client Side addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Turquesas function (player) local getGui = guiGetVisible(Ventana2) if source == Boton9a then triggerServerEvent("PonerCortina", localPlayer, localPlayer) PrecioCortinasCompletas = 3500 PrecioTotal = PrecioCortinasCompletas guiSetText(BotonTOTAL2, PrecioCortinasCompletas) local paintjobID = 1 end end) function addPaintjob2(paintjobID,player) if paintjobID == 1 then myTexture = dxCreateTexture( "cortinasRojas.png" ) elseif paintjobID == 2 then myTexture = dxCreateTexture( "cortinasAzules.png" ) else if player == getLocalPlayer() then outputChatBox ("There is no such paintjob ID!") return end end engineRemoveShaderFromWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) shader_cars, tec = dxCreateShader ( "shader.fx" ) engineApplyShaderToWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) dxSetShaderValue ( shader_cars, "TX0", myTexture ) end addEvent( "setShader", true ) addEventHandler( "setShader", getLocalPlayer(), addPaintjob2 ) Server-Side function Cortina1() local vehicle = getPedOccupiedVehicle( source ) if ( vehicle ) then local pos = {getElementPosition( vehicle )} Cortinapuesta = createObject( 1000, pos[1], pos[2], pos[3] ) attachElements( Cortinapuesta, vehicle, 0, 0, 0, 0, 0, 0 ) triggerClientEvent (players,"setShader",players,cortina) end end addEvent("PonerCortina", true) addEventHandler("PonerCortina", root, Cortina1) Link to comment
Moderators IIYAMA Posted January 18, 2018 Moderators Share Posted January 18, 2018 triggerServerEvent("PonerCortina", resourceRoot, paintjobID) function Cortina1(paintjobID) local player = client -- ... triggerClientEvent (root, "setShader", resourceRoot, paintjobID) end addEvent("PonerCortina", true) addEventHandler("PonerCortina", resourceRoot, Cortina1) function addPaintjob2(paintjobID) end addEvent( "setShader", true ) addEventHandler( "setShader", resourceRoot, addPaintjob2 ) Link to comment
Lormateve Posted January 19, 2018 Author Share Posted January 19, 2018 16 hours ago, IIYAMA said: triggerServerEvent("PonerCortina", resourceRoot, paintjobID) function Cortina1(paintjobID) local player = client -- ... triggerClientEvent (root, "setShader", resourceRoot, paintjobID) end addEvent("PonerCortina", true) addEventHandler("PonerCortina", resourceRoot, Cortina1) function addPaintjob2(paintjobID) end addEvent( "setShader", true ) addEventHandler( "setShader", resourceRoot, addPaintjob2 ) It still does not work. The curtains do not appear in the vehicle. Semi Full client addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Turquesas function (paintjobID) local getGui = guiGetVisible(Ventana2) if source == Boton9a then triggerServerEvent("PonerCortina", resourceRoot, paintjobID) outputChatBox ("Llego a trigger") PrecioCortinasCompletas = 3500 PrecioTotal = PrecioCortinasCompletas guiSetText(BotonTOTAL2, PrecioCortinasCompletas) local paintjobID = 1 end end) function addPaintjob2(paintjobID) if paintjobID == 1 then myTexture = dxCreateTexture( "cortinasRojas.png" ) elseif paintjobID == 2 then myTexture = dxCreateTexture( "cortinasAzules.png" ) else if player == getLocalPlayer() then outputChatBox ("There is no such paintjob ID!") return end end engineRemoveShaderFromWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) shader_cars, tec = dxCreateShader ( "shader.fx" ) engineApplyShaderToWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) dxSetShaderValue ( shader_cars, "TX0", myTexture ) end addEvent( "setShader", true ) addEventHandler( "setShader", resourceRoot, addPaintjob2 ) Server side function Cortina1(paintjobID) outputChatBox ("..") local vehicle = getPedOccupiedVehicle( source ) local player = client if ( vehicle ) then local pos = {getElementPosition( vehicle )} Cortinapuesta = createObject( 1000, pos[1], pos[2], pos[3] ) attachElements( Cortinapuesta, vehicle, 0, 0, 0, 0, 0, 0 ) triggerClientEvent (root, "setShader", resourceRoot, paintjobID) end end addEvent("PonerCortina", true) addEventHandler("PonerCortina", resourceRoot, Cortina1) function CancelarCortina() local vehicle = getPedOccupiedVehicle( source ) if ( vehicle ) then destroyElement(Cortinapuesta) end end addEvent("SacarCortina", true) addEventHandler("SacarCortina", root, CancelarCortina) ----------------------------------------------------------------------------------------------------- function addPJfction (PaintjobID,player) triggerClientEvent (getRootElement(),"addPJ2", getRootElement(),PaintjobID, player ) end addEvent( "addPJ", true ) addEventHandler( "addPJ", resourceRoot, addPJfction ) function removePJfction (player) triggerClientEvent (getRootElement(),"removePJ2", getRootElement(),player ) end addEvent( "removePJ", true ) addEventHandler( "removePJ", resourceRoot, removePJfction ) Link to comment
Moderators IIYAMA Posted January 19, 2018 Moderators Share Posted January 19, 2018 Where does the code stops working? Link to comment
Lormateve Posted January 19, 2018 Author Share Posted January 19, 2018 11 hours ago, IIYAMA said: Where does the code stops working? When the object must be created, it does not in server side Server side function Cortina1(paintjobID) outputChatBox ("..") local vehicle = getPedOccupiedVehicle( source ) local player = client if ( vehicle ) then local pos = {getElementPosition( vehicle )} Cortinapuesta = createObject( 1000, pos[1], pos[2], pos[3] ) attachElements( Cortinapuesta, vehicle, 0, 0, 0, 0, 0, 0 ) triggerClientEvent (root, "setShader", resourceRoot, paintjobID) end end addEvent("PonerCortina", true) addEventHandler("PonerCortina", resourceRoot, Cortina1) Link to comment
Moderators IIYAMA Posted January 19, 2018 Moderators Share Posted January 19, 2018 Use client instead of source. (Line 5) Source is in this case the resourceRoot and not a player. And NO screaming TO ME! Or you get it 10x back. 1 Link to comment
Lormateve Posted January 19, 2018 Author Share Posted January 19, 2018 30 minutes ago, IIYAMA said: Use client instead of source. (Line 5) Source is in this case the resourceRoot and not a player. And NO screaming TO ME! Or you get it 10x back. sorry, I can not understand what I should correct Link to comment
Moderators IIYAMA Posted January 19, 2018 Moderators Share Posted January 19, 2018 local vehicle = getPedOccupiedVehicle( source ) local vehicle = getPedOccupiedVehicle( client ) Link to comment
Lormateve Posted January 20, 2018 Author Share Posted January 20, 2018 23 minutes ago, IIYAMA said: local vehicle = getPedOccupiedVehicle( source ) local vehicle = getPedOccupiedVehicle( client ) Now I understood what he was referring to, but things have not changed, it still does not work Look, in this code if it works, but the only problem is that other people can not see the color that I chose, but they see the same, the root color Server Side function Cortina1() local vehicle = getPedOccupiedVehicle( source ) if ( vehicle ) then local pos = {getElementPosition( vehicle )} Cortinapuesta = createObject( 1000, pos[1], pos[2], pos[3] ) attachElements( Cortinapuesta, vehicle, 0, 0, 0, 0, 0, 0 ) end end addEvent("PonerCortina", true) addEventHandler("PonerCortina", root, Cortina1) function CancelarCortina() local vehicle = getPedOccupiedVehicle( source ) if ( vehicle ) then destroyElement(Cortinapuesta) end end addEvent("SacarCortina", true) addEventHandler("SacarCortina", root, CancelarCortina) ----------------------------------------------------------------------------------------------------- function addPJfction (player) triggerClientEvent (getRootElement(),"addPJ2", getRootElement(), player ) end addEvent( "addPJ", true ) addEventHandler( "addPJ", resourceRoot, addPJfction ) function removePJfction (player) triggerClientEvent (getRootElement(),"removePJ2", getRootElement(),player ) end addEvent( "removePJ", true ) addEventHandler( "removePJ", resourceRoot, removePJfction ) Client Side addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Turquesas function () local getGui = guiGetVisible(Ventana2) if source == Boton9a then triggerServerEvent("PonerCortina", localPlayer, localPlayer) PrecioCortinasCompletas = 3500 PrecioTotal = PrecioCortinasCompletas guiSetText(BotonTOTAL2, PrecioCortinasCompletas) else if source == Boton10a then --ROJAS triggerServerEvent("PonerCortina", localPlayer, localPlayer) PrecioCortinasCompletas = 3500 PrecioTotal = PrecioCortinasCompletas guiSetText(BotonTOTAL2, PrecioCortinasCompletas) Cortinas = dxCreateTexture( "cortinas.png" ) me = getLocalPlayer() if isPedInVehicle ( me ) then triggerServerEvent ( "addPJ", resourceRoot, Boton10a, me ) Cortinas = dxCreateTexture( "cortinasRojas.png" ) engineRemoveShaderFromWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) shader_cars, tec = dxCreateShader ( "shader.fx" ) engineApplyShaderToWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) dxSetShaderValue ( shader_cars, "TX0", CortinasRojas ) end end end end ) addEvent( "addPJ2", true ) addEventHandler( "addPJ2", getLocalPlayer(), CortinasCompletas ) addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Turquesas function () local getGui = guiGetVisible(Ventana2) if source == Boton11a then --AZULES triggerServerEvent("PonerCortina", localPlayer, localPlayer) PrecioCortinasCompletas = 3500 PrecioTotal = PrecioCortinasCompletas guiSetText(BotonTOTAL2, PrecioCortinasCompletas) Cortinas = dxCreateTexture( "cortinasAzules.png" ) me = getLocalPlayer() if isPedInVehicle ( me ) then triggerServerEvent ( "addPJ", resourceRoot, Boton11a, me ) Cortinas = dxCreateTexture( "cortinasAzules.png" ) engineRemoveShaderFromWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) shader_cars, tec = dxCreateShader ( "shader.fx" ) engineApplyShaderToWorldTexture ( shader_cars, "cortinas", getPedOccupiedVehicle(player) ) dxSetShaderValue ( shader_cars, "TX0", Cortinas ) end end end ) addEvent( "addPJ2", true ) addEventHandler( "addPJ2", getLocalPlayer(), CortinasCompletas2 ) Link to comment
Moderators IIYAMA Posted January 20, 2018 Moderators Share Posted January 20, 2018 (edited) That is because you are not doing anything related to passing colours. Neither it is clear to me where those colours are. Edited January 20, 2018 by IIYAMA 1 Link to comment
Lormateve Posted January 23, 2018 Author Share Posted January 23, 2018 On 19/1/2018 at 22:39, IIYAMA said: Eso es porque no estás haciendo nada relacionado con pasar los colores. Tampoco está claro para mí dónde están esos colores. Cortinas = dxCreateTexture ( "cortinasRojas.png" ) engineRemoveShaderFromWorldTexture (shader_cars,"cortinas", getPedOccupiedVehicle ( player )) shader_cars , tec = dxCreateShader ( "shader.fx" ) engineApplyShaderToWorldTexture (shader_cars,"cortinas", getPedOccupiedVehicle ( player )) dxSetShaderValue (shader_cars,"TX0",CortinasRojas) this is the color red for example, you are right, because there is no connection with the server so that all users can see it, it does not work out, try many ways, but no way it went well Link to comment
Moderators IIYAMA Posted January 23, 2018 Moderators Share Posted January 23, 2018 local color = "red" triggerServerEvent("PonerCortina", resourceRoot, paintjobID, color) function Cortina1(paintjobID, color) local player = client -- ... triggerClientEvent (root, "setShader", resourceRoot, paintjobID, color) end addEvent("PonerCortina", true) addEventHandler("PonerCortina", resourceRoot, Cortina1) ? function addPaintjob2(paintjobID, color) outputChatBox("the color is:" .. color) if color == "red" then -- set the red shader elseif color == "blue" then -- set the blue shader ETC. end end addEvent( "setShader", true ) addEventHandler( "setShader", resourceRoot, addPaintjob2 ) I just send the string "red" from clientside to serverside. And from serverside back to clientside for all players. If the string is "red" then set your red shader. Same goes for the color blue. (But you can't pass textures) 1 Link to comment
Lormateve Posted January 23, 2018 Author Share Posted January 23, 2018 1 hour ago, IIYAMA said: local color = "red" triggerServerEvent("PonerCortina", resourceRoot, paintjobID, color) function Cortina1(paintjobID, color) local player = client -- ... triggerClientEvent (root, "setShader", resourceRoot, paintjobID, color) end addEvent("PonerCortina", true) addEventHandler("PonerCortina", resourceRoot, Cortina1) ? function addPaintjob2(paintjobID, color) outputChatBox("the color is:" .. color) if color == "red" then -- set the red shader elseif color == "blue" then -- set the blue shader ETC. end end addEvent( "setShader", true ) addEventHandler( "setShader", resourceRoot, addPaintjob2 ) I just send the string "red" from clientside to serverside. And from serverside back to clientside for all players. If the string is "red" then set your red shader. Same goes for the color blue. (But you can't pass textures) In case of passing text "red" it would no longer be to use the paintjobID, since it is an empty value. Anyway when passing the TriggerClientEvent, it does not work, and I can not understand why. Client and Server addEventHandler("onClientGUIClick", guiRoot, --VENTANA2 = CORTINAS > Completas > Turquesas function () local getGui = guiGetVisible(Ventana2) if source == Boton9a then triggerServerEvent("PonerCortina", resourceRoot, paintjobID, color) --This does not work local color = "nada" PrecioCortinasCompletas = 3500 PrecioTotal = PrecioCortinasCompletas guiSetText(BotonTOTAL2, PrecioCortinasCompletas) else if source == Boton10a then --ROJAS local color = "red" triggerServerEvent("PonerCortina", resourceRoot, paintjobID, color) --This does not work PrecioCortinasCompletas = 3500 PrecioTotal = PrecioCortinasCompletas guiSetText(BotonTOTAL2, PrecioCortinasCompletas) end end end ) addEvent( "addPJ2", true ) addEventHandler( "addPJ2", getLocalPlayer(), CortinasCompletas ) function Cortina1(paintjobID, color) local player = client - local vehicle = getPedOccupiedVehicle( source ) if ( vehicle ) then local pos = {getElementPosition( vehicle )} Cortinapuesta = createObject( 1000, pos[1], pos[2], pos[3] ) attachElements( Cortinapuesta, vehicle, 0, 0, 0, 0, 0, 0 ) triggerClientEvent (root, "setShader", resourceRoot, paintjobID, color) end end addEvent("PonerCortina", true) addEventHandler("PonerCortina", resourceRoot, Cortina1) ----------------------------------------------------------------------------------------------------- function addPJfction (player) triggerClientEvent (getRootElement(),"addPJ2", getRootElement(), player ) end addEvent( "addPJ", true ) addEventHandler( "addPJ", resourceRoot, addPJfction ) function removePJfction (player) triggerClientEvent (getRootElement(),"removePJ2", getRootElement(),player ) end addEvent( "removePJ", true ) addEventHandler( "removePJ", resourceRoot, removePJfction ) Link to comment
Moderators IIYAMA Posted January 23, 2018 Moderators Share Posted January 23, 2018 (edited) Order matters: (the computer reads from top to bottom) triggerServerEvent("PonerCortina", resourceRoot, paintjobID, color) --This does not work local color = "nada" local color = "nada" triggerServerEvent("PonerCortina", resourceRoot, paintjobID, color) You still didn't fix this: - local vehicle = getPedOccupiedVehicle( source ) local vehicle = getPedOccupiedVehicle( client ) It is client, not source. If it doesn't work, then manually debug it...(tutorial) Because I do not know where I have to look for issues. Edited January 23, 2018 by IIYAMA 1 Link to comment
Lormateve Posted January 23, 2018 Author Share Posted January 23, 2018 3 hours ago, IIYAMA said: Order matters: (the computer reads from top to bottom) triggerServerEvent("PonerCortina", resourceRoot, paintjobID, color) --This does not work local color = "nada" local color = "nada" triggerServerEvent("PonerCortina", resourceRoot, paintjobID, color) You still didn't fix this: - local vehicle = getPedOccupiedVehicle( source ) local vehicle = getPedOccupiedVehicle( client ) It is client, not source. If it doesn't work, then manually debug it...(tutorial) Because I do not know where I have to look for issues. It worked, It's a lot of help, you mean, thank you. Now what I have left is to create a database so that when they enter or leave is stored in the car, THANK YOU !! 1 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