JUNIORCEDE1

Cambio ropa cj

Nov 4th, 2017
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 12.43 KB | None | 0 0
  1. -----------------------
  2. -- Autor: TheCrazy17 --
  3. -- Fecha: 18/04/2015 --
  4. -----------------------
  5.  
  6. Lobby = {
  7.     ["Mostrando"] = false
  8. }
  9.  
  10. local screenW,screenH = guiGetScreenSize()
  11. local resW, resH = 1024,768
  12. local Size = ( 1.3 / resW ) * screenW -- Fix para que las letras se vean bien en todas las resoluciones
  13.  
  14. local T1 = tocolor(255, 255, 255, 255)
  15. local T2 = tocolor(255, 255, 255, 255)
  16. local T3 = tocolor(255, 255, 255, 255)
  17. local T4 = tocolor(255, 255, 255, 255)
  18. local T5 = tocolor(0, 255, 255, 255)
  19. local T6 = tocolor(255, 0, 0, 255)
  20.  
  21.  
  22. function Lobby.Dibujar()           
  23.     dxDrawText("JUGAR", 102*sW, 410*sH, 250*sW, 448*sH, T1, Size, "default-bold")
  24.     dxDrawText("PERSONAJE", 102*sW, 448*sH, 250*sW, 486*sH, T2, Size, "default-bold")
  25.     dxDrawText("CONFIGURACIÓN", 102*sW, 486*sH, 250*sW, 524*sH, T3, Size, "default-bold")
  26.     dxDrawText("CREDITOS", 102*sW, 524*sH, 250*sW, 562*sH, T4, Size, "default-bold")
  27.     dxDrawText("*Prohibido hacer flood \n*Prohibido hacer spam \n (Nombrar otros servidores \n ajenos a gta.la)\n*Prohibido los insultos \n*Prohibido los hacks,cheats,etc. \n*Prohibido el re-logeo \n (evade-kill)\n*Prohibido dupear balas \n armas o cualquier otra cosa. \n *Prohibido hacer spawk-kill. \n *Prohibido usar nick como \n xd; .. ; u otro tipo de nick que lleve \n menos de 2 caracteres.\n", 760*sW, 90*sH, 580*sW, 448*sH, T5, Size, "default-bold")
  28.     dxDrawText("\n mapa modificado\n Islas Agregadas\n Nueva Area 51\n Sistema de Bases y VIP\n",760*sW, 370*sH, 580*sW, 448*sH, T5, Size, "default-bold")
  29.     dxDrawText("                  Stark\n         TheCrazy\n Gta.la/foro \n ",850*sW, 500*sH, 580*sW, 448*sH, T5, Size, "default-bold")
  30.     dxDrawText("\n Servidor con:",760*sW, 350*sH, 580*sW, 448*sH, T6, Size, "default-bold")
  31.     dxDrawText("\nReglas:", 760*sW, 50*sH, 580*sW, 448*sH, T6, Size, "default-bold")
  32.     dxDrawText("\n Servidor creado por:\n Scripter/Owner:\n Comunidad:",760*sW, 480*sH, 580*sW, 448*sH, T6, Size, "default-bold")
  33.  
  34.     --Obtener la posición del cursor
  35.     local CursorX, CursorY = getCursorPosition()
  36.    
  37.     --Realizar ciertas funciones si el cursor está en cierta posición
  38.     if CursorX >= 0.09375 and CursorX <= 0.155 and CursorY >= 0.53 and CursorY <= 0.56 then
  39.         T1 = tocolor(120, 120, 120, 255)
  40.         T2 = tocolor(255, 255, 255, 255)
  41.         T3 = tocolor(255, 255, 255, 255)
  42.         T4 = tocolor(255, 255, 255, 255)
  43.     elseif CursorX >= 0.09375 and CursorX <= 0.20 and CursorY >= 0.585 and CursorY <= 0.61 then
  44.         T1 = tocolor(255, 255, 255, 255)
  45.         T2 = tocolor(120, 120, 120, 255)
  46.         T3 = tocolor(255, 255, 255, 255)
  47.         T4 = tocolor(255, 255, 255, 255)
  48.     elseif CursorX >= 0.09375 and CursorX <= 0.24 and CursorY >= 0.632 and CursorY <= 0.652 then
  49.         T1 = tocolor(255, 255, 255, 255)
  50.         T2 = tocolor(255, 255, 255, 255)
  51.         T3 = tocolor(120, 120, 120, 255)
  52.         T4 = tocolor(255, 255, 255, 255)
  53.     elseif CursorX >= 0.09375 and CursorX <= 0.185 and CursorY >= 0.68 and CursorY <= 0.71 then
  54.         T1 = tocolor(255, 255, 255, 255)
  55.         T2 = tocolor(255, 255, 255, 255)
  56.         T3 = tocolor(255, 255, 255, 255)
  57.         T4 = tocolor(120, 120, 120, 255)
  58.     else
  59.         T1 = tocolor(255, 255, 255, 255)
  60.         T2 = tocolor(255, 255, 255, 255)
  61.         T3 = tocolor(255, 255, 255, 255)
  62.         T4 = tocolor(255, 255, 255, 255)
  63.     end
  64. end
  65.  
  66. -- Crear el lobby cuando el recurso inicie en el cliente
  67. function Lobby.Inicio()
  68.     Lobby.Mostrando = true
  69.     addEventHandler("onClientRender", root, Lobby.Dibujar)
  70.     showCursor(true)
  71.     fadeCamera(true)
  72.     setCameraMatrix(1901.9, -1222.35, 17.3, 2000, 0, 300)
  73.     Jugador = createPed(0, 1902.8, -1219, 18.5)
  74.     setPedRotation(Jugador, 140)
  75. end
  76. addEventHandler("onClientResourceStart", resourceRoot, Lobby.Inicio)
  77.  
  78. function Lobby.Ocultar()
  79.     removeEventHandler("onClientRender", root, Lobby.Dibujar)
  80.     showCursor(false)
  81. end
  82.  
  83. -- Funcion para simular los botones
  84. function Lobby.Click(Boton, Estado)
  85.     if Estado == "up" then
  86.         return
  87.     end
  88.     local CursorX, CursorY = getCursorPosition()
  89.     if Lobby.Mostrando then
  90.         if CursorX >= 0.09375 and CursorX <= 0.155 and CursorY >= 0.53 and CursorY <= 0.56 then
  91.             triggerServerEvent("DayZ.SpawnJugador", localPlayer, getLocalPlayer())
  92.             destroyElement ( Jugador )
  93.             Lobby.Ocultar()
  94.         elseif CursorX >= 0.09375 and CursorX <= 0.20 and CursorY >= 0.585 and CursorY <= 0.61 then
  95.             Lobby.Ocultar()
  96.             showClothWindow()
  97.         elseif CursorX >= 0.09375 and CursorX <= 0.24 and CursorY >= 0.632 and CursorY <= 0.652 then
  98.             outputChatBox("CONFIGURACIÓN")
  99.             Lobby.Ocultar()
  100.             showConfig()
  101.         elseif CursorX >= 0.09375 and CursorX <= 0.185 and CursorY >= 0.68 and CursorY <= 0.71 then
  102.             outputChatBox("CREDITOS")
  103.         end
  104.     end
  105. end
  106. addEventHandler("onClientClick", getRootElement(), Lobby.Click)
  107.  
  108.  
  109. ----cloth-----
  110. screenWidth, screenHeight = guiGetScreenSize( )
  111.  
  112. Jugador = nil
  113.  
  114. itemsPacks = {
  115.    
  116.     {"Caras", 1, 0, 32 },
  117.     {"Camisetas", 0, 0, 67 },
  118.     {"Pantalones", 2, 0, 44 },
  119.     {"Zapatos", 3, 0, 37 },
  120.     {"Gorros", 16, -1, 56 },
  121.     {"Gafas", 15, -1, 16 },
  122.  
  123. }
  124.  
  125. selectedClothes = {}
  126.  
  127. function showConfig()
  128. if not isElement ( showconfig ) then
  129.         showCursor (true)
  130.         showconfig = guiCreateWindow((sW - 350) / 2, (sH - 199) / 2, 350, 199, "Configuraciones", false)
  131.         guiWindowSetSizable(showconfig, false)
  132.         guiSetVisible(showconfig, false)
  133.         info = guiCreateLabel(10, 10, 310, 15, "Informacion: "..getPlayerName(localPlayer), false, info)
  134.         guiLabelSetHorizontalAlign(info, "center", false)
  135.         guiWindowSetSizable(clothWindow, false)
  136.         setCameraMatrix(1901.9, -1222.35, 17.3, 2000, 0, 300)
  137.         removeEventHandler("onClientClick", getRootElement(), Lobby.Click)
  138.         bindKey ( "mouse1", "down", setPrevX )
  139.         addEventHandler('onClientRender', root, showConfig )
  140.     end
  141. end
  142.  
  143.  
  144. function showClothWindow()
  145.     if not isElement ( clothWindow ) then
  146.         showCursor (true)
  147.         clothWindow = guiCreateWindow(0.07*screenWidth, 0.41*screenHeight, 268, 120+#itemsPacks*25, "PERSONAJE", false)
  148.         guiWindowSetSizable(clothWindow, false)
  149.         setCameraMatrix(1901.9, -1222.35, 17.3, 2000, 0, 300)
  150.         removeEventHandler("onClientClick", getRootElement(), Lobby.Click)
  151.         addEventHandler('onClientRender', root, rotateTestPed )
  152.         addEventHandler('onClientRender', root, renderRotateText )
  153.         bindKey ( "mouse1", "down", setPrevX )
  154.         x_prev = nil
  155.         hombre = guiCreateRadioButton(98, 27, 71, 13, "Hombre", false, clothWindow)
  156.         guiRadioButtonSetSelected(hombre,true)
  157.         mujer = guiCreateRadioButton(181, 27, 71, 13, "Mujer", false, clothWindow)  
  158.         for i, v in ipairs ( itemsPacks ) do
  159.             local rub_label = guiCreateLabel(21, 55+25*(i-1), 53, 20, v[1], false, clothWindow)
  160.             local run_back_b = guiCreateButton(93, 55+25*(i-1), 30, 18, "<<", false, clothWindow)
  161.             guiSetProperty(run_back_b, "NormalTextColour", "FFAAAAAA")
  162.             local rub_back = guiCreateButton(134, 55+25*(i-1), 30, 18, "<", false, clothWindow)
  163.             guiSetProperty(rub_back, "NormalTextColour", "FFAAAAAA")
  164.             local rub_forw = guiCreateButton(198, 55+25*(i-1), 30, 18, ">", false, clothWindow)
  165.             guiSetProperty(rub_forw, "NormalTextColour", "FFAAAAAA")
  166.             local rub_forw_b = guiCreateButton(239, 55+25*(i-1), 30, 18, ">>", false, clothWindow)
  167.             guiSetProperty(rub_forw_b, "NormalTextColour", "FFAAAAAA")
  168.             local cur_cloth = getElementData ( localPlayer, "cloth"..v[2]) or v[3]
  169.             local rub_num = guiCreateLabel(169, 55+25*(i-1), 22, 18, cur_cloth, false, clothWindow)
  170.             guiLabelSetHorizontalAlign(rub_num, "center", false)    
  171.             setElementData ( run_back_b, "clothButBackB", true )
  172.             setElementData ( rub_forw_b, "clothButForwB", true )
  173.             setElementData ( rub_back, "clothButBack", true )
  174.             setElementData ( rub_forw, "clothButForw", true )
  175.             setElementData ( run_back_b, "clothButID", i )
  176.             setElementData ( rub_forw_b, "clothButID", i )
  177.             setElementData ( rub_back, "clothButID", i )
  178.             setElementData ( rub_forw, "clothButID", i )
  179.             table.insert ( selectedClothes, { rub_num, cur_cloth, v[2], v[3], v[4] } )
  180.             setPedClothes ( Jugador, v[2], cur_cloth )
  181.         end
  182.         button_save = guiCreateButton(13, 55+#itemsPacks*25, 242, 23,"Guardar Vestimenta!",false,clothWindow)
  183.         button_back = guiCreateButton(13, 85+#itemsPacks*25, 242, 23,"Seguir",false,clothWindow)
  184.        
  185.         addEventHandler("onClientGUIClick", button_save, allowCloth )
  186.         addEventHandler("onClientGUIClick", button_back, disallowCloth )
  187.     end
  188. end
  189.  
  190. function renderRotateText()
  191.     dxDrawText ( "Mantenga pulsado el botón del ratón y arrastre para girar a CJ", 0, screenHeight/2+screenHeight/3,screenWidth,screenHeight, tocolor(255,255,255), 1.3, "sans","center")
  192. end
  193.  
  194.  
  195. function allowCloth ()
  196.     if source ~= button_save then return true end
  197.     for i, v in ipairs ( itemsPacks ) do
  198.         setElementData ( localPlayer, "cloth"..v[2], selectedClothes[i][2] )
  199.     end
  200.     outputChatBox ( "Vestimenta Guardada!", 30, 250, 30 )
  201.     --closeClothWindow()
  202. end
  203.  
  204. function disallowCloth ()
  205.     if source ~= button_back then return true end
  206.     closeClothWindow()
  207. end
  208.  
  209. function closeClothWindow ()
  210.     destroyElement ( clothWindow )
  211.     selectedClothes = {}
  212.     unbindKey ( "mouse1", "down", setPrevX )
  213.     removeEventHandler('onClientRender', root, rotateTestPed )
  214.     removeEventHandler('onClientRender', root, renderRotateText )
  215.     addEventHandler("onClientClick", getRootElement(), Lobby.Click)
  216.     setCameraMatrix(1901.9, -1222.35, 17.3, 2000, 0, 300)
  217.     addEventHandler("onClientRender", root, Lobby.Dibujar)
  218.     showCursor ( true )
  219. end
  220.  
  221. x_prev = nil
  222.  
  223. function setPrevX()
  224.     x, _ = getCursorPosition ()
  225.     x_prev = x*screenWidth
  226. end
  227.  
  228. function rotateTestPed()
  229.     if getKeyState ("mouse1") then
  230.         x, _ = getCursorPosition ()
  231.         x=x*screenWidth
  232.         change_rot = (x-x_prev)
  233.         local _, _, ped_rot = getElementRotation ( Jugador )
  234.         local rot_to = ped_rot+change_rot
  235.         if rot_to < 0 then
  236.             rot_to = ped_rot+change_rot+360
  237.         end
  238.         setElementRotation ( Jugador, 0, 0, rot_to )
  239.         x_prev = x
  240.     end
  241. end
  242.  
  243. function clickOntoCloth ()
  244.     local id = getElementData ( source, "clothButID" ) or 0
  245.     if id > 0 then
  246.         local setCloth = selectedClothes[id][4]
  247.         if getElementData ( source, "clothButBackB" ) then
  248.             setCloth = selectedClothes[id][4]
  249.         elseif getElementData ( source, "clothButForwB" ) then
  250.             setCloth = selectedClothes[id][5]
  251.         elseif getElementData ( source, "clothButBack" ) then
  252.             if selectedClothes[id][2] > selectedClothes[id][4] then
  253.                 setCloth = selectedClothes[id][2]-1
  254.             else
  255.                 setCloth = selectedClothes[id][5]
  256.             end
  257.         elseif getElementData ( source, "clothButForw" ) then
  258.             if selectedClothes[id][2] < selectedClothes[id][5] then
  259.                 setCloth = selectedClothes[id][2]+1
  260.             end
  261.         end
  262.         selectedClothes[id][2] = setCloth
  263.         guiSetText (selectedClothes[id][1],setCloth)
  264.         setPedClothes ( Jugador, selectedClothes[id][3], setCloth )
  265.     end
  266. end
  267.  
  268. addEventHandler("onClientGUIClick", root, clickOntoCloth )
  269.  
  270. function setPedClothes(thePed, clothingSlot, clothingID)
  271.     if not isElement(thePed) or type(clothingSlot) ~= "number" then
  272.         error("Invalid arguments to setPedClothes()!", 2)
  273.     end
  274.  
  275.     if not clothingID or clothingID == -1 then
  276.         return removePedClothes(thePed, clothingSlot)
  277.     end
  278.  
  279.     local hasClothes = getPedClothes(thePed, clothingSlot)
  280.     if hasClothes then
  281.         removePedClothes(thePed, clothingSlot)
  282.     end
  283.    
  284.     local texture, model = getClothesByTypeIndex(clothingSlot, clothingID)
  285.     return addPedClothes(thePed, texture, model, clothingSlot)
  286. end
  287.  
  288. addEventHandler( "onClientElementStreamIn", getRootElement( ),
  289.     function ( )
  290.         if getElementType( source ) == "player" or ( getElementType( source ) == "ped" and getElementData ( source, "deadman" ) ) and getElementModel ( source ) == 0 then
  291.             for i, v in ipairs ( itemsPacks ) do
  292.                 setPedClothes (source,v[2],getElementData ( source, "cloth"..v[2] ) or 0)
  293.             end
  294.         end
  295.     end
  296. );
  297.  
  298. function updatePlayerClothesC (skin)
  299.     if isElement ( source ) then
  300.         if skin == 0 then
  301.             for i, v in ipairs ( itemsPacks ) do
  302.                 setPedClothes (source,v[2],getElementData ( source, "cloth"..v[2] ) or 0)
  303.             end
  304.         else
  305.             for i, v in ipairs ( itemsPacks ) do
  306.                 removePedClothes(source, v[2])
  307.             end
  308.         end
  309.     end
  310. end
  311.  
  312. addEvent("updatePlayerClothes", true)
  313. addEventHandler("updatePlayerClothes", getRootElement(), updatePlayerClothesC)
  314.  
  315. function putPlayerClothesOnSpawn ()
  316.     if getElementModel ( localPlayer ) == 0 then
  317.         for i, v in ipairs ( itemsPacks ) do
  318.             setPedClothes (localPlayer,v[2],getElementData ( localPlayer, "cloth"..v[2] ) or 0)
  319.         end
  320.     end
  321. end
  322.  
  323. addEvent("onClientPlayerDayZSpawn", true)
  324. addEventHandler("onClientPlayerDayZSpawn", getRootElement(), putPlayerClothesOnSpawn)
  325.  
  326. addEvent("onClientPlayerDayZLogin", true)
  327. addEventHandler("onClientPlayerDayZLogin", getRootElement(), putPlayerClothesOnSpawn)
Advertisement
Add Comment
Please, Sign In to add comment