lLinux Posted March 22, 2014 Posted March 22, 2014 necesito hacer que un panel en dxDraw solo sea visible para el usuario que lleve acabo la funcion, el panel de abre cuando pongo L pero se les aparece a todos tambien
lLinux Posted March 22, 2014 Author Posted March 22, 2014 Crea todo el script client side. Mi script que cree es de para bloquear autos cuando precionen la L: SERVER-SIDE: function BloquearCarros(thePlayer, player) playervehicle=getPlayerOccupiedVehicle(thePlayer) if(playervehicle) then if playervehicle and getVehicleController ( playervehicle ) == thePlayer then if(isVehicleLocked(playervehicle)) then setVehicleLocked(playervehicle,false) --outputChatBox("#AFAFAF[VEHICULO] #FFFFFFDESBLOQUEADO",thePlayer,255,0,0, true) triggerClientEvent( getRootElement(), "unBlq", thePlayer) else setVehicleLocked(playervehicle,true) --outputChatBox("#AFAFAF[VEHICULO] #FFFFFFBLOQUEADO",thePlayer,255,0,0, true) triggerClientEvent( getRootElement(), "Blq", thePlayer) end end end end function exit(player,seat,jacked) if(isVehicleLocked(source)) then setVehicleLocked(source,false) --outputChatBox("#AFAFAF[VEHICULO] #FFFFFFDESBLOQUEADO",player,255,0,0, true) triggerClientEvent( getRootElement(), "unBlq", player) end end addEventHandler("onVehicleExit",getRootElement(),exit) addEventHandler("onPlayerSpawn", getRootElement(), function () bindKey( source, "L", "down", BloquearCarros) end) CLIENT-SIDE: IMGURL = "images/lock.png" dxText = "Vehiculo bloqueado" sx, sy = guiGetScreenSize() Rec1_x = 561/sx Rec1_y = 726/sy Rec2_x = 562/sx Rec2_y = 727/sy Text_x = 570/sx Text_y = 742/sy IMG_x = 585/sx IMG_y = 731/sy function Bloqueado() addEventHandler("onClientRender", root, gui1) dxText = "Vehiculo bloqueado" IMGURL = "images/lock.png" t1 = setTimer(removeGui, 5000, 1) killTimer(t2) sonido() end addEvent("Blq", true) addEventHandler("Blq", getRootElement(), Bloqueado) function DesBloqueado() addEventHandler("onClientRender", root, gui1) dxText = "Vehiculo desbloqueado" IMGURL = "images/unlock.png" t2 = setTimer(removeGui, 5000, 1) killTimer(t1) sonido() end addEvent("unBlq", true) addEventHandler("unBlq", getRootElement(), DesBloqueado) function removeGui() removeEventHandler("onClientRender", root, gui1) end function sonido() if getLocalPlayer() == source then local sound = playSound("sounds/sonido.mp3") --Play wasted.mp3 from the sounds folder setSoundVolume(sound, 0.5) end end --addEventHandler("onClientRender", getRootElement(), gui1) function gui1() dxDrawRectangle(sx*Rec1_x, sy*Rec1_y, 234, 43, tocolor(0, 0, 0, 50), true) --561, 726, 234, 43 dxDrawRectangle(sx*Rec2_x, sy*Rec2_y, 232, 41, tocolor(0, 0, 0, 160), true) --562, 727, 232, 41 dxDrawText(dxText, sx*Text_x, sy*Text_y, 814, 758, tocolor(255, 69, 59, 255), 1.00, "default-bold", "center", "top", false, false, true, false, false) --570, 742, 814, 758 dxDrawImage(sx*IMG_x, sy*IMG_y, 37, 34, IMGURL, 0, 0, 0, tocolor(255, 255, 255, 255), true) --585, 731, 37, 34 end Los errores son que cuando precionan L el sonido se escucha para todos y el panel se abre para todos.
Castillo Posted March 22, 2014 Posted March 22, 2014 triggerClientEvent( getRootElement(), "unBlq", thePlayer) Ahi esta el problema, ponelo asi: triggerClientEvent ( thePlayer, "unBlq", thePlayer ) Y lo mismo en las otras lineas.
lLinux Posted March 23, 2014 Author Posted March 23, 2014 triggerClientEvent( getRootElement(), "unBlq", thePlayer) Ahi esta el problema, ponelo asi: triggerClientEvent ( thePlayer, "unBlq", thePlayer ) Y lo mismo en las otras lineas. Si me funciono, gracias... en otra publicacion que hice pusistes que templazara el onPlayerSpawn por onPlayerJoin y onResourceStart, pero lo hago y no me funciona function tecla() bindKey( source, "L", "down", BloquearCarros) end addEventHandler("onPlayerJoin", getRootElement(), tecla) addEventHandler("onResourceStart", getRootElement(), tecla) me dice que mal player en el argumento 1 de bindKey, le intente con player y thePlayer y nada
Castillo Posted March 23, 2014 Posted March 23, 2014 Eso es porque onResourceStart no tiene argumento de jugador, tenes que hacer un loop ( como te dije en el otro tema ).
Recommended Posts