Advertisement
Noneatme

Untitled

Dec 27th, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.48 KB | None | 0 0
  1. --[[
  2.     ##########################################################################
  3.     ##                                                                      ##
  4.     ## Project: 'MT-RPG' - Gamemode for MTA: San Andreas PROJECT X          ##
  5.     ##                      Developer: Noneatme                             ##
  6.     ##           License: See LICENSE in the top level directory            ##
  7.     ##                                                                      ##
  8.     ##########################################################################
  9. ]]
  10.  
  11.  
  12. local cFunc = {}
  13. local cSetting = {}
  14.  
  15. cSetting["enabled"] = false
  16. local sx, sy = guiGetScreenSize()
  17. local aesx, aesy = 1600, 900
  18.        
  19. cSetting["aviable_skins"] = {
  20.     [1] = {60, "Male char", 60},
  21.     [2] = {16, "Worker outfit", 45},
  22.     [3] = {22, "Male char", 55},
  23.     [4] = {23, "Male char", 66},
  24.     [5] = {46, "Male char", 47},
  25.     [6] = {41, "Female char", 66},
  26.     [7] = {41, "Female char 2", 66},
  27.     [8] = {41, "Female char 3", 66},
  28.     [9] = {41, "Female char 4", 66},
  29.     [10] = {41, "Female char 5", 66},
  30.     [11] = {41, "Female char 6", 66},
  31.     [12] = {41, "Female char 7", 66},
  32. }
  33.  
  34. cSetting["start_id"] = 1
  35. cSetting["end_id"] = 10
  36.  
  37. cSetting["oldskin"] = 0
  38.  
  39. cSetting["highlighted"] = 1
  40.  
  41.  
  42. -- FUNCTIONS --
  43.  
  44. cFunc["draw_skinlist"] = function()
  45.     if(cSetting["enabled"] == true) then
  46.     --  showCursor(true)
  47.         --  BACKGROUND AND TITLE --
  48.         dxDrawRectangle(sx/2+(500/aesx*sx), sy/2+(70/aesy*sy), 260/aesx*sx, 340/aesy*sy, tocolor(0, 0, 0, 100))
  49.        
  50.         dxDrawRectangle(sx/2+(500/aesx*sx), sy/2+(50/aesy*sy), 260/aesx*sx, 20/aesy*sy, tocolor(0, 255, 0, 100))
  51.        
  52.         dxDrawText("Skin Shop", sx/2+(600/aesx*sx), sy/2+(52/aesy*sy), 260/aesx*sx, 20/aesy*sy, tocolor(0, 0, 0, 200), 1/aesx*sx, "default-bold", "left")
  53.        
  54.         -- COLUMS --
  55.         dxDrawText("Skin Name", sx/2+(525/aesx*sx), sy/2+(75/aesy*sy), 260/aesx*sx, 20/aesy*sy, tocolor(255, 255, 255, 200), 1/aesx*sx, "default-bold", "left")
  56.        
  57.         dxDrawText("Price", sx/2+(690/aesx*sx), sy/2+(75/aesy*sy), 260/aesx*sx, 20/aesy*sy, tocolor(255, 255, 255, 200), 1/aesx*sx, "default-bold", "left")
  58.        
  59.         dxDrawRectangle(sx/2+(500/aesx*sx), sy/2+(95/aesy*sy), 260/aesx*sx, 2/aesy*sy, tocolor(0, 0, 0, 150))
  60.        
  61.         -- INFORMATION --
  62.         dxDrawText("Use the arrow keys to scroll up/down.\n'Enter' to accept, 'Backspace' to cancel.", sx/2+(525/aesx*sx), sy/2+(15/aesy*sy), 260/aesx*sx, 20/aesy*sy, tocolor(255, 255, 255, 200), 1/aesx*sx, "default-bold", "left")
  63.        
  64.         -- INHALT --
  65.  
  66.         local increment = 30/aesy*sy
  67.         local add = increment
  68.        
  69.         for index = cSetting["start_id"], cSetting["end_id"], 1 do
  70.             local tbl = (cSetting["aviable_skins"][index] or false)
  71.             if(tbl ~= false) then
  72.                 local r, g, b = 255, 255, 255
  73.                 if(cSetting["highlighted"] == index) then
  74.                     r, g, b= 0, 255, 0
  75.                 end
  76.                 dxDrawText(tbl[2], sx/2+(525/aesx*sx), (sy/2+(75/aesy*sy))+add, 260/aesx*sx, 20/aesy*sy, tocolor(r, g, b, 200), 1/aesx*sx, "default-bold", "left")
  77.                 dxDrawText("$"..tbl[3], sx/2+(690/aesx*sx), (sy/2+(75/aesy*sy))+add, 260/aesx*sx, 20/aesy*sy, tocolor(r, g, b, 200), 1/aesx*sx, "default-bold", "left")
  78.                 add = add+increment
  79.             end
  80.         end
  81.     end
  82. end
  83.  
  84. cFunc["move_list_down"] = function()
  85.     if(cSetting["enabled"] == true) then
  86.         if(cSetting["highlighted"] < #cSetting["aviable_skins"]) then
  87.             cSetting["highlighted"] = cSetting["highlighted"]+1
  88.         end
  89.         if(cSetting["highlighted"] > cSetting["end_id"]) then
  90.             cSetting["start_id"] = cSetting["start_id"]+1
  91.             cSetting["end_id"] = cSetting["end_id"]+1
  92.         end
  93.         if(cSetting["aviable_skins"][cSetting["highlighted"]]) then
  94.             setElementModel(localPlayer, cSetting["aviable_skins"][cSetting["highlighted"]][1])
  95.         end
  96.     end
  97. end
  98.  
  99. cFunc["move_list_up"] = function()
  100.     if(cSetting["enabled"] == true) then
  101.         if(cSetting["highlighted"] > 1) then
  102.             cSetting["highlighted"] = cSetting["highlighted"]-1
  103.         end
  104.         if(cSetting["start_id"] > cSetting["highlighted"]) then
  105.             cSetting["start_id"] = cSetting["start_id"]-1
  106.             cSetting["end_id"] = cSetting["end_id"]-1
  107.         end
  108.        
  109.         -- MODIFY CHAR --
  110.         if(cSetting["aviable_skins"][cSetting["highlighted"]]) then
  111.             setElementModel(localPlayer, cSetting["aviable_skins"][cSetting["highlighted"]][1])
  112.         end
  113.     end
  114. end
  115.  
  116. cFunc["toggle_skinshop"] = function(bool)
  117.     if(cSetting["enabled"] ~= bool) then
  118.         cSetting["enabled"] = (bool or false)
  119.         toggleAllControls((not bool or false))
  120.         if(cSetting["enabled"]) then
  121.             cSetting["oldskin"] = getElementModel(localPlayer)
  122.             cSetting["olddim"] = getElementDimension(localPlayer)
  123.             cFunc["move_list_up"]()
  124.            
  125.             setElementPosition(localPlayer, 199.71017456055, -126.89879608154, 1003.5151977539)
  126.             setElementDimension(localPlayer, (getElementData(localPlayer, "ID") or math.random(3, 6556)))
  127.            
  128.             setCameraMatrix(199.02137756348, -129.92440795898, 1002.9151977539, 199.71017456055, -126.89879608154, 1003.5151977539)
  129.             setPedRotation(localPlayer, 165)
  130.         else
  131.             setElementModel(localPlayer, cSetting["oldskin"])
  132.             cSetting["highlighted"] = 1
  133.             setElementDimension(localPlayer, cSetting["olddim"])
  134.             setCameraTarget(localPlayer)
  135.         end
  136.     end
  137. end
  138.  
  139. cFunc["buy_skin"] = function()
  140.     if(cSetting["enabled"] == true) then
  141.         local price = (cSetting["aviable_skins"][cSetting["highlighted"]][3] or 9999999)
  142.         if(tonumber(getElementData(localPlayer, "handgeld")) >= price) then
  143.             triggerServerEvent("onMTSkinshopSkinBuy", localPlayer, price, cSetting["aviable_skins"][cSetting["highlighted"]][1]) -- Take that, client coderunner!
  144.             cFunc["toggle_skinshop"](false)
  145.         else
  146.             outputInfobox("You don't have enought money to buy this skin!", 255, 0, 0)
  147.         end
  148.     end
  149. end
  150.  
  151. cFunc["cancel_skinshop"] = function()
  152.     if(cSetting["enabled"] == true) then
  153.         cFunc["toggle_skinshop"](false)
  154.         setCameraTarget(localPlayer)
  155.     end
  156. end
  157.  
  158.  
  159. -- MARKER --
  160.  
  161. for i = 1, 3, 1 do
  162.     local m = createMarker(207.0884552002, -129.51467895508, 1003.5078125, "corona", 1.0, 0, 255, 0, 200)
  163.     setElementInterior(m, 3)
  164.     setElementDimension(m, i)
  165.     addEventHandler("onClientMarkerHit", m, function(hi, t)
  166.         if(t == true) and (hi == localPlayer) then
  167.             cFunc["toggle_skinshop"](true)
  168.         end
  169.     end)
  170. end
  171.  
  172. -- EVENT HANDLERS --
  173. addEventHandler("onClientRender", getRootElement(), cFunc["draw_skinlist"])
  174.  
  175. bindKey("arrow_d", "down", cFunc["move_list_down"])
  176. bindKey("arrow_u", "down", cFunc["move_list_up"])
  177. bindKey("enter", "down", cFunc["buy_skin"])
  178. bindKey("space", "down", cFunc["cancel_skinshop"])
  179. bindKey("backspace", "down", cFunc["cancel_skinshop"])
  180.  
  181. addCommandHandler("skinshop", function()
  182.     cFunc["toggle_skinshop"](not cSetting["enabled"])
  183. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement