Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- ##########################################################################
- ## ##
- ## Project: 'MT-RPG' - Gamemode for MTA: San Andreas PROJECT X ##
- ## Developer: Noneatme ##
- ## License: See LICENSE in the top level directory ##
- ## ##
- ##########################################################################
- ]]
- local cFunc = {}
- local cSetting = {}
- cSetting["enabled"] = false
- local sx, sy = guiGetScreenSize()
- local aesx, aesy = 1600, 900
- cSetting["aviable_skins"] = {
- [1] = {60, "Male char", 60},
- [2] = {16, "Worker outfit", 45},
- [3] = {22, "Male char", 55},
- [4] = {23, "Male char", 66},
- [5] = {46, "Male char", 47},
- [6] = {41, "Female char", 66},
- [7] = {41, "Female char 2", 66},
- [8] = {41, "Female char 3", 66},
- [9] = {41, "Female char 4", 66},
- [10] = {41, "Female char 5", 66},
- [11] = {41, "Female char 6", 66},
- [12] = {41, "Female char 7", 66},
- }
- cSetting["start_id"] = 1
- cSetting["end_id"] = 10
- cSetting["oldskin"] = 0
- cSetting["highlighted"] = 1
- -- FUNCTIONS --
- cFunc["draw_skinlist"] = function()
- if(cSetting["enabled"] == true) then
- -- showCursor(true)
- -- BACKGROUND AND TITLE --
- dxDrawRectangle(sx/2+(500/aesx*sx), sy/2+(70/aesy*sy), 260/aesx*sx, 340/aesy*sy, tocolor(0, 0, 0, 100))
- dxDrawRectangle(sx/2+(500/aesx*sx), sy/2+(50/aesy*sy), 260/aesx*sx, 20/aesy*sy, tocolor(0, 255, 0, 100))
- 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")
- -- COLUMS --
- 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")
- 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")
- dxDrawRectangle(sx/2+(500/aesx*sx), sy/2+(95/aesy*sy), 260/aesx*sx, 2/aesy*sy, tocolor(0, 0, 0, 150))
- -- INFORMATION --
- 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")
- -- INHALT --
- local increment = 30/aesy*sy
- local add = increment
- for index = cSetting["start_id"], cSetting["end_id"], 1 do
- local tbl = (cSetting["aviable_skins"][index] or false)
- if(tbl ~= false) then
- local r, g, b = 255, 255, 255
- if(cSetting["highlighted"] == index) then
- r, g, b= 0, 255, 0
- end
- 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")
- 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")
- add = add+increment
- end
- end
- end
- end
- cFunc["move_list_down"] = function()
- if(cSetting["enabled"] == true) then
- if(cSetting["highlighted"] < #cSetting["aviable_skins"]) then
- cSetting["highlighted"] = cSetting["highlighted"]+1
- end
- if(cSetting["highlighted"] > cSetting["end_id"]) then
- cSetting["start_id"] = cSetting["start_id"]+1
- cSetting["end_id"] = cSetting["end_id"]+1
- end
- if(cSetting["aviable_skins"][cSetting["highlighted"]]) then
- setElementModel(localPlayer, cSetting["aviable_skins"][cSetting["highlighted"]][1])
- end
- end
- end
- cFunc["move_list_up"] = function()
- if(cSetting["enabled"] == true) then
- if(cSetting["highlighted"] > 1) then
- cSetting["highlighted"] = cSetting["highlighted"]-1
- end
- if(cSetting["start_id"] > cSetting["highlighted"]) then
- cSetting["start_id"] = cSetting["start_id"]-1
- cSetting["end_id"] = cSetting["end_id"]-1
- end
- -- MODIFY CHAR --
- if(cSetting["aviable_skins"][cSetting["highlighted"]]) then
- setElementModel(localPlayer, cSetting["aviable_skins"][cSetting["highlighted"]][1])
- end
- end
- end
- cFunc["toggle_skinshop"] = function(bool)
- if(cSetting["enabled"] ~= bool) then
- cSetting["enabled"] = (bool or false)
- toggleAllControls((not bool or false))
- if(cSetting["enabled"]) then
- cSetting["oldskin"] = getElementModel(localPlayer)
- cSetting["olddim"] = getElementDimension(localPlayer)
- cFunc["move_list_up"]()
- setElementPosition(localPlayer, 199.71017456055, -126.89879608154, 1003.5151977539)
- setElementDimension(localPlayer, (getElementData(localPlayer, "ID") or math.random(3, 6556)))
- setCameraMatrix(199.02137756348, -129.92440795898, 1002.9151977539, 199.71017456055, -126.89879608154, 1003.5151977539)
- setPedRotation(localPlayer, 165)
- else
- setElementModel(localPlayer, cSetting["oldskin"])
- cSetting["highlighted"] = 1
- setElementDimension(localPlayer, cSetting["olddim"])
- setCameraTarget(localPlayer)
- end
- end
- end
- cFunc["buy_skin"] = function()
- if(cSetting["enabled"] == true) then
- local price = (cSetting["aviable_skins"][cSetting["highlighted"]][3] or 9999999)
- if(tonumber(getElementData(localPlayer, "handgeld")) >= price) then
- triggerServerEvent("onMTSkinshopSkinBuy", localPlayer, price, cSetting["aviable_skins"][cSetting["highlighted"]][1]) -- Take that, client coderunner!
- cFunc["toggle_skinshop"](false)
- else
- outputInfobox("You don't have enought money to buy this skin!", 255, 0, 0)
- end
- end
- end
- cFunc["cancel_skinshop"] = function()
- if(cSetting["enabled"] == true) then
- cFunc["toggle_skinshop"](false)
- setCameraTarget(localPlayer)
- end
- end
- -- MARKER --
- for i = 1, 3, 1 do
- local m = createMarker(207.0884552002, -129.51467895508, 1003.5078125, "corona", 1.0, 0, 255, 0, 200)
- setElementInterior(m, 3)
- setElementDimension(m, i)
- addEventHandler("onClientMarkerHit", m, function(hi, t)
- if(t == true) and (hi == localPlayer) then
- cFunc["toggle_skinshop"](true)
- end
- end)
- end
- -- EVENT HANDLERS --
- addEventHandler("onClientRender", getRootElement(), cFunc["draw_skinlist"])
- bindKey("arrow_d", "down", cFunc["move_list_down"])
- bindKey("arrow_u", "down", cFunc["move_list_up"])
- bindKey("enter", "down", cFunc["buy_skin"])
- bindKey("space", "down", cFunc["cancel_skinshop"])
- bindKey("backspace", "down", cFunc["cancel_skinshop"])
- addCommandHandler("skinshop", function()
- cFunc["toggle_skinshop"](not cSetting["enabled"])
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement