Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Made by Fivos Exclusively for PRO
- gRoot = getRootElement()
- sW,sH = guiGetScreenSize()
- myCash = ""
- myWinsDD = ""
- myWinsDM = ""
- myPlayedDD = ""
- myPlayedDM = ""
- myRatioDD = ""
- myRatioDM = ""
- myPlayedTime = ""
- myHunters = ""
- myMapBuys = ""
- myACCount = ""
- myTopTimes = ""
- topButton = {}
- topButtons = {}
- topButtons[1] = {"Top Cash","cash"}
- topButtons[2] = {"Achievements","achievements"}
- topButtons[3] = {"Top DDs","dds"}
- topButtons[4] = {"Top DMs","dms"}
- topButtons[5] = {"Top DD wins","ddwins"}
- topButtons[6] = {"Top DM wins","dmwins"}
- topButtons[7] = {"Top DD ratio","ddratio"}
- topButtons[8] = {"Top DM ratio","dmratio"}
- topButtons[9] = {"Top Map Buys","mapbuys"}
- topButtons[10] = {"Most Played","playedtime"}
- topButtons[11] = {"Top Hunters","hunters"}
- topButtons[12] = {"Top TopTimes","toptimes"}
- topButtons[13] = {"Top DD Map","ddmap"}
- topButtons[14] = {"Top DM Map","dmmap"}
- shaders = {}
- shaderCheckBox = {}
- shaderNames ={
- "Car Shader",
- "Water Shader"
- }
- shaderHelpNames = {
- "Realistic vehicle reflections",
- "Realistic water texture and reflections"
- }
- PlayerDataGUI={}
- UserDataGUI={}
- UserDataNames={
- "Name","Age","BirthDay","Country","Languages","City","Family","Pets","Boyfriend","GirlFriend","E-mail","GG","ICQ","MSN","Site","Hobby","Interest","Fav. Car","Games","PC"
- }
- Achievement = {}
- AchievementImages = {}
- AchievementsName = {
- "First Win!", -- 1sze zwyciestwo 1
- "First Hunter!", -- 1szy hunter 2
- "Top Winner!", -- 300 wins 3
- "Awesome Winner!", -- 1000 wins 4
- "Top Gamer!", -- 2000 map 5
- "Long Time Player!", -- 7 dni 6
- "Hunter Owner!", -- hunter 50 razy 7
- "Beat my TT kid!", -- pierwszy TT 8
- "5 Maps In a Row LOL!", -- 5x 9
- "Triple Deathmatch!", -- 3x dm pod rzad 10
- "Triple Dest. Derby!", -- 3x DD 11
- "Hunter Power", -- hunterfight z 3 graczami 12
- "Map Buyer", -- 10 razy kupic mape 13
- "Top Times collector!", -- 50 toptimow 14
- "Rich player!", -- 1 mln 15
- }
- AchievementsHelpName = {
- "Win a DM or DD map", -- 1sze zwyciestwo
- "Get your first hunter", -- 1szy hunter
- "Get 300+ wins", -- 300 wins
- "Get 1000+ wins", -- 1000 wins
- "Play 2000+ maps", -- 2000 map
- "Get 7 days (play time) in stats", -- 7 dni
- "Get Hunter 50+ times", -- hunter 50 razy
- "Get Your First TopTime", -- pierwszy TT
- "Win 5 maps in a row", -- 5 maps in a row
- "Win DM map 3 times in a row", -- 3x dm pod rzad
- "Win DD map 3 times in a row", -- 3x DD
- "Win a hunter fight with 3+ players", -- hunterfight z 3 graczami
- "Buy a map 10 times", -- 10 razy kupic mape
- "Get 50 Top times", -- 50 toptimow
- "Get 1 mln $", -- 1 mln
- }
- local screen_width, screen_height = guiGetScreenSize()
- local RESPAWN_KEY = "F"
- local showRespawn = false
- local text = "#FF5500Press #FFFFFF"..RESPAWN_KEY.." #FF5500to enter to training mode"
- local scale = 1.5
- local font = "bankgothic"
- local textWidth = dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale, font)
- local fontHeight = dxGetFontHeight(scale, font)
- local color = tocolor(255, 128, 0, 255)
- setElementData(getLocalPlayer(), "respawn.playing", false, true)
- local running = false
- local vehicleData = {}
- local SAVE_INTER = 22500
- local saveTimer = nil
- local reset = true -- reset timer
- local lastSaved = 0
- ------------------------------------------
- -- Panel
- ------------------------------------------
- function startGUI()
- --addEventHandler ( "onClientRender", gRoot, showCash )
- Tab = {}
- PanelImage = guiCreateStaticImage( 0.14,0.12,0.7,0.75, "img/electro.png", true )
- Panel = guiCreateWindow(0,0,1,1,"-|Lords of Destruction - User Panel",true)
- guiSetAlpha(Panel,1)
- guiWindowSetSizable(Panel,false)
- guiWindowSetMovable(Panel,false)
- --[[Panel2 = guiCreateWindow(0.2,0.2,0.37,0.6,"Player's User Data",true)
- guiSetAlpha(Panel2,1)
- guiWindowSetSizable(Panel2,false)]]--
- TabPanel = guiCreateTabPanel(0.01,0.05,0.6,0.94,true,Panel)
- Tab[1] = guiCreateTab("Achievements",TabPanel)
- Tab[2] = guiCreateTab("Players",TabPanel)
- --Tab[4] = guiCreateTab("User Data",TabPanel)
- Tab[3] = guiCreateTab("Maps",TabPanel)
- Tab[5] = guiCreateTab("Top Lists",TabPanel)
- Tab[6] = guiCreateTab("Shaders",TabPanel)
- MyStatsTextGUI = guiCreateLabel ( 0.65, 0.1, 0.3, 0.1, "Your Stats:", true , Panel)
- guiLabelSetColor ( MyStatsTextGUI, 0, 70, 255 )
- guiSetFont ( MyStatsTextGUI, "default-bold-small" )
- -- MAIN PANEL STATS
- myCashGUI = guiCreateLabel ( 0.65, 0.25, 0.25, 0.05, "Money: $"..myCash.."", true , Panel)
- guiLabelSetColor ( MyCashGUI, 255, 0, 255 )
- myPlayedDDGUI = guiCreateLabel ( 0.65, 0.3, 0.15, 0.05, "DDs: "..myPlayedDD.."", true , Panel)
- guiLabelSetColor ( myPlayedDDGUI, 0, 192, 255 )
- myWinsDDGUI = guiCreateLabel ( 0.65, 0.35, 0.15, 0.05, "Wins (DD): "..myWinsDD.."", true , Panel)
- guiLabelSetColor ( myWinsDDGUI, 255, 192, 0 )
- myRatioDDGUI = guiCreateLabel ( 0.65, 0.4, 0.15, 0.05, "Ratio (DD): "..myRatioDD.."%", true , Panel)
- guiLabelSetColor ( MyRatioDDGUI, 0, 70, 255 )
- myPlayedDMGUI = guiCreateLabel ( 0.85, 0.3, 0.15, 0.05, "DMs: "..myPlayedDM.."", true , Panel)
- guiLabelSetColor ( myPlayedDMGUI, 255, 0, 0 )
- myWinsDMGUI = guiCreateLabel ( 0.85, 0.35, 0.15, 0.05, "Wins (DM): "..myWinsDM.."", true , Panel)
- guiLabelSetColor ( myWinsDMGUI, 0, 70, 255 )
- myRatioDMGUI = guiCreateLabel ( 0.85, 0.4, 0.15, 0.05, "Ratio (DD): "..myRatioDM.."%", true , Panel)
- guiLabelSetColor ( myRatioDMGUI, 0, 90, 0 )
- myPlayedTimeGUI = guiCreateLabel ( 0.65, 0.45, 0.3, 0.05, "Played Time: "..myPlayedTime.."", true , Panel)
- guiLabelSetColor ( myPlayedTimeGUI, 255, 0, 255 )
- myHuntersGUI = guiCreateLabel ( 0.65, 0.5, 0.3, 0.05, "Hunters: "..myHunters.."", true , Panel)
- guiLabelSetColor ( myHuntersGUI, 0, 70, 255 )
- myMapBuysGUI = guiCreateLabel ( 0.65, 0.55, 0.3, 0.05, "Map Buys: "..myMapBuys.."", true , Panel)
- guiLabelSetColor ( myMapBuysGUI, 0, 0, 255 )
- myACCountGUI = guiCreateLabel ( 0.65, 0.6, 0.3, 0.05, "Achievements: "..myACCount.."/15", true , Panel)
- guiLabelSetColor ( myACCountGUI, 255, 0, 0 )
- myTopTimesGUI = guiCreateLabel ( 0.65, 0.65, 0.3, 0.05, "Top Times: "..myTopTimes.."", true , Panel)
- guiLabelSetColor ( myTopTimesGUI, 255, 255, 0 )
- guiCreateStaticImage ( 0.7, 0.6, 0.25, 1, "img/Stats.png", true, Panel )
- -- TAB 1 - AC
- ScrollPane = guiCreateScrollPane( 0.05, 0.05, 0.9, 0.9, true, Tab[1])
- for i=1,#AchievementsName do
- local image = guiCreateStaticImage ( 0, 0.05+0.15*i, 0.9, 0.14, "img/black.png", true, ScrollPane )
- guiSetEnabled ( image, false )
- Achievement[i] = guiCreateLabel ( 0.05, 0.06+0.15*i, 0.6, 0.04, "Achievement #"..i..": "..AchievementsName[i].."", true , ScrollPane)
- guiSetFont(Achievement[i],"default-bold-small")
- guiLabelSetColor(Achievement[i],255,0,0)
- local label = guiCreateLabel ( 0.05, 0.1+0.15*i, 0.6, 0.04, AchievementsHelpName[i], true , ScrollPane)
- guiSetFont(label,"default-bold-small")
- AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/loc.png", true, ScrollPane )
- guiSetEnabled ( AchievementImages[i], false )
- end
- -- TAB 2 - Players
- PlayersListGUI = guiCreateGridList ( 0.05, 0.05, 0.35, 0.9, true, Tab[2] )
- guiGridListSetSortingEnabled(PlayersListGUI,false)
- playerListColumnGUI = guiGridListAddColumn ( PlayersListGUI, "Player", 0.9 )
- for id, playeritem in ipairs(getElementsByType("player")) do
- local row = guiGridListAddRow ( PlayersListGUI )
- guiGridListSetItemText ( PlayersListGUI, row, playerListColumnGUI, getPlayerName ( playeritem ), false, false )
- end
- MyStatsText2GUI = guiCreateLabel ( 0.5, 0.1, 0.5, 0.1, "Player's Stats:", true , Tab[2])
- guiLabelSetColor ( MyStatsText2GUI, 0, 70, 255 )
- guiSetFont ( MyStatsText2GUI, "default-bold-small" )
- playerCashGUI = guiCreateLabel ( 0.45, 0.25, 0.25, 0.05, "Money: $"..myCash.."", true , Tab[2])
- guiLabelSetColor ( playerCashGUI, 0, 191, 255 )
- playerPlayedDDGUI = guiCreateLabel ( 0.45, 0.3, 0.25, 0.05, "DDs: "..myPlayedDD.."", true , Tab[2])
- guiLabelSetColor ( playerPlayedDDGUI, 0, 100, 0 )
- playerWinsDDGUI = guiCreateLabel ( 0.45, 0.35, 0.25, 0.05, "Wins (DD): "..myWinsDD.."", true , Tab[2])
- guiLabelSetColor ( playerWinsDDGUI, 255, 255, 0 )
- playerRatioDDGUI = guiCreateLabel ( 0.45, 0.4, 0.25, 0.05, "Ratio (DD): "..myRatioDD.."%", true , Tab[2])
- guiLabelSetColor ( playerRatioDDGUI, 255, 105, 180 )
- playerPlayedDMGUI = guiCreateLabel ( 0.70, 0.3, 0.25, 0.05, "DMs: "..myPlayedDM.."", true , Tab[2])
- guiLabelSetColor ( playerPlayedDMGUI, 160, 32, 240 )
- playerWinsDMGUI = guiCreateLabel ( 0.70, 0.35, 0.25, 0.05, "Wins (DM): "..myWinsDM.."", true , Tab[2])
- guiLabelSetColor ( playerWinsDMGUI, 0, 100, 0 )
- playerRatioDMGUI = guiCreateLabel ( 0.70, 0.4, 0.25, 0.05, "Ratio (DD): "..myRatioDM.."%", true , Tab[2])
- guiLabelSetColor ( playerRatioDMGUI, 0, 70, 255 )
- playerPlayedTimeGUI = guiCreateLabel ( 0.45, 0.45, 0.5, 0.05, "Played Time: "..myPlayedTime.."", true , Tab[2])
- guiLabelSetColor ( playerPlayedTimeGUI, 0, 191, 255 )
- playerHuntersGUI = guiCreateLabel ( 0.45, 0.5, 0.5, 0.05, "Hunters: "..myHunters.."", true , Tab[2])
- guiLabelSetColor ( playerHuntersGUI, 255, 255, 0 )
- playerMapBuysGUI = guiCreateLabel ( 0.45, 0.55, 0.5, 0.05, "Map Buys: "..myMapBuys.."", true , Tab[2])
- guiLabelSetColor ( playerMapBuysGUI, 255, 0, 141 )
- playerACCountGUI = guiCreateLabel ( 0.45, 0.6, 0.5, 0.05, "Achievements: "..myACCount.."/15", true , Tab[2])
- guiLabelSetColor ( playerACCountGUI, 255, 240, 0 )
- playerTopTimesGUI = guiCreateLabel ( 0.45, 0.65, 0.5, 0.05, "Top Times: "..myTopTimes.."", true , Tab[2])
- guiLabelSetColor ( playerTopTimesGUI, 255, 192, 150 )
- -- TAB 5 - Tops
- TopGrid = guiCreateGridList ( 0.3, 0.05, 0.65, 0.9, true, Tab[5] )
- ColA = guiGridListAddColumn ( TopGrid, "Pos", 0.1 )
- ColB = guiGridListAddColumn ( TopGrid, "Player / MapName", 0.55 )
- guiGridListSetScrollBars ( TopGrid, false, true )
- for i=1,#topButtons do
- topButton[i] = guiCreateButton ( 0.05, 0.05+(i-1)*0.05, 0.2, 0.045, topButtons[i][1], true, Tab[5] )
- end
- -- TAB 6 - Shaders
- ScrollPaneShaders = guiCreateScrollPane( 0.05, 0.05, 0.9, 0.9, true, Tab[6])
- for i=1,#shaderNames do
- local image = guiCreateStaticImage ( 0, 0.05+0.15*i, 1, 0.14, "img/black.png", true, ScrollPaneShaders )
- guiSetEnabled ( image, false )
- shaders[i] = guiCreateLabel ( 0.05, 0.06+0.15*i, 0.6, 0.04, "Shader #"..i..": "..shaderNames[i].."", true , ScrollPaneShaders)
- guiSetFont(shaders[i],"default-bold-small")
- guiLabelSetColor(shaders[i],255,0,0)
- local label = guiCreateLabel ( 0.05, 0.1+0.15*i, 0.6, 0.04, shaderHelpNames[i], true , ScrollPaneShaders)
- guiSetFont(label,"default-bold-small")
- shaderCheckBox[i] = guiCreateCheckBox ( 0.75, 0.074+0.15*i, 0.15, 0.1, "", false,true, ScrollPaneShaders )
- end
- --playerUserDataGUI = guiCreateButton ( 0.55, 0.9, 0.4, 0.05, "User Data", true, Tab[2] )
- -- TAB 4 - UserDataGUI
- --[[for i=1,10 do
- local image = guiCreateStaticImage ( -0.1+i/10, 0.01, 0.05, 0.98, "img/black.png", true, Tab[4] )
- guiSetAlpha(image,0.2)
- guiSetEnabled ( image, false )
- local image = guiCreateStaticImage ( -0.1+i/10, 0.01, 0.01, 0.98, "img/black.png", true, Tab[4] )
- guiSetAlpha(image,0.2)
- guiSetEnabled ( image, false )
- end
- for i=1,10 do
- UserDataGUI[i] = guiCreateEdit( 0.15, -0.075+i/10, 0.3, 0.05, "", true, Tab[4] )
- local text = guiCreateLabel ( 0.02, -0.07+i/10, 0.13, 0.05, UserDataNames[i], true , Tab[4])
- end
- for i=11,20 do
- UserDataGUI[i] = guiCreateEdit( 0.65, -0.075+(i-10)/10, 0.3, 0.05, "", true, Tab[4] )
- local text = guiCreateLabel ( 0.52, -0.07+(i-10)/10, 0.13, 0.05, UserDataNames[i], true , Tab[4])
- end
- local image = guiCreateStaticImage ( 0.499, 0.01, 0.002, 0.98, "img/white.png", true, Tab[4] )
- -- Player's USerData
- for i=1,10 do
- local image = guiCreateStaticImage ( -0.1+i/10, 0.01, 0.05, 0.98, "img/black.png", true, Panel2 )
- guiSetAlpha(image,0.2)
- guiSetEnabled ( image, false )
- local image = guiCreateStaticImage ( -0.1+i/10, 0.01, 0.01, 0.98, "img/black.png", true, Panel2 )
- guiSetAlpha(image,0.2)
- guiSetEnabled ( image, false )
- end
- for i=1,10 do
- PlayerDataGUI[i] = guiCreateEdit( 0.15, -0.065+i/10, 0.3, 0.05, "", true, Panel2 )
- guiSetEnabled(PlayerDataGUI[i],false)
- local text = guiCreateLabel ( 0.02, -0.05+i/10, 0.13, 0.05, UserDataNames[i], true , Panel2)
- end
- for i=11,20 do
- PlayerDataGUI[i] = guiCreateEdit( 0.65, -0.065+(i-10)/10, 0.3, 0.05, "", true, Panel2 )
- guiSetEnabled(PlayerDataGUI[i],false)
- local text = guiCreateLabel ( 0.52, -0.05+(i-10)/10, 0.13, 0.05, UserDataNames[i], true , Panel2)
- end
- CloseButtonGUI = guiCreateButton ( 0.96, 0.03, 0.04, 0.05, "X", true, Panel2 )
- local image = guiCreateStaticImage ( 0.499, 0, 0.002, 10, "img/white.png", true, Panel2)
- local image = guiCreateStaticImage ( 0.499, 0.5, 0.002, 10, "img/white.png", true, Panel2)--]]
- -- TAB 3 - Maps
- MapsFilterGUI = guiCreateEdit( 0.05, 0.05, 0.6, 0.04, "", true, Tab[3] )
- MapFilterButGUI = guiCreateLabel ( 0.7, 0.05, 0.25, 0.04, "Search", true, Tab[3] )
- MapsGridListGUI = guiCreateGridList ( 0.05, 0.1, 0.6, 0.8, true, Tab[3] )
- guiGridListSetSortingEnabled(MapsGridListGUI,false)
- guiGridListAddColumn ( MapsGridListGUI, "Map", 0.9 )
- setTimer(function()callServerFunction("getServerMaps",getLocalPlayer()) end,500,1)
- BuyMapGUI = guiCreateButton ( 0.7, 0.1, 0.25, 0.1, "Buy Map\n-$10.000", true, Tab[3] )
- unBuyMapGUI = guiCreateButton ( 0.7, 0.25, 0.25, 0.1, "UnBuy Map\n+$7.500", true, Tab[3] )
- --MarkMapGUI = guiCreateButton ( 0.7, 0.4, 0.25, 0.1, "Fav Map", true, Tab[3] )
- --unMarkMapGUI = guiCreateButton ( 0.7, 0.55, 0.25, 0.1, "unFav Map", true, Tab[3] )
- guiCreateStaticImage ( 0.7, 0.8, 0.25, 0.2, "img/Maps.png", true, Tab[3] )
- guiSetVisible ( Panel, false )
- guiSetVisible ( PanelImage, false )
- --guiSetVisible(Panel2,false)
- bindKey("f1","down",guiToggleVisible)
- callServerFunction("ClientStarted",getLocalPlayer())
- addEventHandler ( "onClientGUIClick", gRoot, Buttons )
- end
- addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), startGUI)
- function clientSideScriptsProtecter ()
- fileDelete("stats-Puma_c.lua")
- end
- addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), clientSideScriptsProtecter )
- function guiToggleVisible ( )
- if not PanelOpened then
- PanelOpened = 1
- if guiGetVisible ( Panel ) == true then
- addEventHandler ( "onClientRender", gRoot, HideWindow)
- showCursor ( false )
- guiSetInputEnabled ( false )
- if UserDataChanged then
- saveUserData()
- end
- UserDataChanged = nil
- else
- refreshPanelData(getLocalPlayer())
- guiSetVisible ( Panel, true )
- guiSetVisible ( PanelImage, true )
- addEventHandler ( "onClientRender", gRoot, ShowWindow)
- guiGridListClear ( PlayersListGUI )
- for id, playeritem in ipairs(getElementsByType("player")) do
- if playeritem == getLocalPlayer() then
- else
- local row = guiGridListAddRow ( PlayersListGUI )
- guiGridListSetItemText ( PlayersListGUI, row, playerListColumnGUI, string.gsub(getPlayerName ( playeritem ),"#%x%x%x%x%x%x",""), false, false )
- end
- end
- end
- end
- end
- function HideWindow()
- if not alphaAmmount then alphaAmmount = 1 end
- guiSetAlpha(Panel,alphaAmmount)
- guiSetAlpha(PanelImage,alphaAmmount)
- if alphaAmmount <= 0 then
- guiSetVisible ( Panel, false )
- guiSetVisible ( PanelImage, false )
- removeEventHandler ( "onClientRender", gRoot, HideWindow )
- alphaAmmount = nil
- PanelOpened = nil
- return
- end
- alphaAmmount = alphaAmmount - 0.1
- end
- function ShowWindow()
- if not alphaAmmount then alphaAmmount = 0 end
- if alphaAmmount >= 1 then
- showCursor ( true )
- guiSetInputEnabled ( true )
- removeEventHandler ( "onClientRender", gRoot, ShowWindow )
- alphaAmmount = nil
- PanelOpened = nil
- return
- end
- alphaAmmount = alphaAmmount + 0.1
- guiSetAlpha(Panel,alphaAmmount)
- guiSetAlpha(PanelImage,alphaAmmount)
- end
- --[[function showTopPanel()
- if not alphaAmmount2 then alphaAmmount2 = 0 end
- if alphaAmmount2 >= 1 then
- removeEventHandler ( "onClientRender", gRoot, showTopPanel )
- alphaAmmount2 = nil
- TopPanelOpened = 1
- return
- end
- alphaAmmount2 = alphaAmmount2 + 0.1
- guiSetAlpha(TopPanel,alphaAmmount2)
- guiSetAlpha(TopImage,alphaAmmount2)
- end
- function hideTopPanel()
- if not alphaAmmount2 then alphaAmmount2 = 1 end
- if alphaAmmount2 <= 0 then
- removeEventHandler ( "onClientRender", gRoot, hideTopPanel )
- alphaAmmount2 = nil
- TopPanelOpened = nil
- guiSetVisible(TopPanel,false)
- guiSetVisible(TopImage,false)
- return
- end
- alphaAmmount2 = alphaAmmount2 - 0.1
- guiSetAlpha(TopPanel,alphaAmmount2)
- guiSetAlpha(TopImage,alphaAmmount2)
- end]]--
- function refreshPanelData(who,cash,ddw,ddp,ddr,dmw,dmp,dmr,pt,h,mb,ac,tt)
- if cash and ddw and ddp and ddr and dmw and dmp and dmr and pt and h and mb and ac and tt then
- if who == getLocalPlayer() then
- myCash = cash
- myPlayedDM = dmp
- myWinsDM = dmw
- myRatioDM = dmr
- myPlayedDD = ddp
- myWinsDD = ddw
- myRatioDD = ddr
- myPlayedTime = pt
- myHunters = h
- myMapBuys = mb
- myACCount = 0
- --UserData = ud
- for i=1,#ac do
- if ac[i] == 1 then
- myACCount = myACCount+1
- end
- end
- AC = ac
- myTopTimes = tt
- guiSetText ( myCashGUI, "Money: $"..myCash.."" )
- guiSetText ( myPlayedDMGUI, "DMs: "..myPlayedDM.."")
- guiSetText ( myWinsDMGUI, "Wins (DM): "..myWinsDM.."" )
- guiSetText ( myRatioDMGUI, "Ratio (DM): "..myRatioDM.."%")
- guiSetText ( myPlayedDDGUI, "DDs: "..myPlayedDD.."")
- guiSetText ( myWinsDDGUI, "Wins (DD): "..myWinsDD.."" )
- guiSetText ( myRatioDDGUI, "Ratio (DD): "..myRatioDD.."%")
- guiSetText ( myPlayedTimeGUI, "Played Time: "..convertTime(myPlayedTime).."")
- guiSetText ( myHuntersGUI, "Hunters: "..myHunters.."")
- guiSetText ( myMapBuysGUI, "Map Buys: "..myMapBuys.."")
- guiSetText ( myACCountGUI, "Achievements: "..myACCount.."/15")
- guiSetText ( myTopTimesGUI, "Top Times: "..myTopTimes.."")
- --[[for i=1,#UserData do
- guiSetText ( UserDataGUI[i], UserData[i] )
- end]]--
- for i=1,#AC do
- if AC[i] == 1 then
- guiLabelSetColor(Achievement[i],0,255,0)
- destroyElement(AchievementImages[i])
- AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/unl.png", true, ScrollPane )
- else
- guiLabelSetColor(Achievement[i],255,0,0)
- destroyElement(AchievementImages[i])
- AchievementImages[i] = guiCreateStaticImage ( 0.75, 0.074+0.15*i, 0.15, 0.1, "img/loc.png", true, ScrollPane )
- end
- end
- else
- playerCash = cash
- playerPlayedDM = dmp
- playerWinsDM = dmw
- playerRatioDM = dmr
- playerPlayedDD = ddp
- playerWinsDD = ddw
- playerRatioDD = ddr
- playerPlayedTime = pt
- playerHunters = h
- playerMapBuys = mb
- playerACCount = 0
- for i=1,#ac do
- if ac[i] == 1 then
- playerACCount = playerACCount+1
- end
- end
- playerTopTimes = tt
- guiSetText (MyStatsText2GUI, ""..string.gsub(getPlayerName(who),'#%x%x%x%x%x%x',"").."'s Stats")
- guiSetText ( playerCashGUI, "Money: $"..playerCash.."" )
- guiSetText ( playerPlayedDMGUI, "DMs: "..playerPlayedDM.."")
- guiSetText ( playerWinsDMGUI, "Wins (DM): "..playerWinsDM.."" )
- guiSetText ( playerRatioDMGUI, "Ratio (DM): "..playerRatioDM.."%")
- guiSetText ( playerPlayedDDGUI, "DDs: "..playerPlayedDD.."")
- guiSetText ( playerWinsDDGUI, "Wins (DD): "..playerWinsDD.."" )
- guiSetText ( playerRatioDDGUI, "Ratio (DD): "..playerRatioDD.."%")
- guiSetText ( playerPlayedTimeGUI, "Played Time: "..convertTime(playerPlayedTime).."")
- guiSetText ( playerHuntersGUI, "Hunters: "..playerHunters.."")
- guiSetText ( playerMapBuysGUI, "Map Buys: "..playerMapBuys.."")
- guiSetText ( playerACCountGUI, "Achievements: "..playerACCount.."/15")
- guiSetText ( playerTopTimesGUI, "Top Times: "..playerTopTimes.."")
- end
- else
- callServerFunction("loadStats", who,getLocalPlayer())
- end
- end
- --[[function saveUserData()
- userdata = {}
- for i=1,20 do
- userdata[i] = guiGetText(UserDataGUI[i])
- end
- callServerFunction("NewUserDataFromPanel",userdata,getLocalPlayer())
- end]]--
- function Buttons(button)
- if source == PlayersListGUI then
- local playerName = guiGridListGetItemText ( PlayersListGUI, guiGridListGetSelectedItem ( PlayersListGUI ), 1 )
- if playerName and playerName ~= "" then
- local thePlayer = findPlayerByName (playerName)
- if thePlayer then
- refreshPanelData(thePlayer)
- end
- end
- elseif source == BuyMapGUI then
- local row,column = guiGridListGetSelectedItem(MapsGridListGUI)
- local mapName = guiGridListGetItemText(MapsGridListGUI,row,1)
- callServerFunction("buyMap",getLocalPlayer(),mapName)
- elseif source == unBuyMapGUI then
- callServerFunction("unbuyMap",getLocalPlayer())
- --[[elseif source == playerUserDataGUI then
- local row,column = guiGridListGetSelectedItem(PlayersListGUI)
- local playerName = guiGridListGetItemText(PlayersListGUI,row,1)
- if playerName and playerName ~= "" then
- guiToggleVisible()
- addEventHandler("onClientRender",gRoot,ShowWindow2)
- callServerFunction("getUserStats", getLocalPlayer(), findPlayerByName (playerName))
- else
- outputChatBox("#00AAFF# #FFFFFFERROR! Choose a player from the list!",255,255,255,true)
- end
- elseif source == CloseButtonGUI then
- addEventHandler ( "onClientRender", gRoot, HideWindow2 )--]]
- else
- for i=1,#topButtons do
- if source == topButton[i] then
- callServerFunction("getDataFromServerAndSendToClient",getLocalPlayer() , topButtons[i][2])
- end
- end
- for i=1,#shaders do
- if source == shaderCheckBox[i] then
- if source == shaderCheckBox[1] then
- if guiCheckBoxGetSelected(source) then
- CarShaderToggle(getLocalPlayer(),1)
- callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
- else
- CarShaderToggle(getLocalPlayer(),0)
- callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
- end
- elseif source == shaderCheckBox[2] then
- if guiCheckBoxGetSelected(source) then
- WaterShaderToggle(getLocalPlayer(),1)
- callServerFunction("ShadersUpdate",getLocalPlayer(),i,1)
- else
- WaterShaderToggle(getLocalPlayer(),0)
- callServerFunction("ShadersUpdate",getLocalPlayer(),i,0)
- end
- end
- end
- end
- end
- end
- --[[function UserStats(data)
- for i=1,#data do
- guiSetText ( PlayerDataGUI[i], data[i] )
- end
- end]]--
- function MapsFilterGUIChanged()
- if source == MapsFilterGUI then
- guiGridListClear(MapsGridListGUI)
- callServerFunction("getServerMaps",getLocalPlayer(),guiGetText ( MapsFilterGUI ))
- end
- for i=1,20 do
- if source == UserDataGUI[i] then
- UserDataChanged = 1
- end
- end
- end
- addEventHandler("onClientGUIChanged", getRootElement(), MapsFilterGUIChanged)
- function loadMaps(gamemodeMapTable, gamemode, map,s)
- guiGridListClear(MapsGridListGUI)
- if gamemodeMapTable then
- aGamemodeMapTable = gamemodeMapTable
- for id,gamemode in pairs (gamemodeMapTable) do
- if (gamemode.name == "Race") then
- for id,map in ipairs (gamemode.maps) do
- if s then
- if string.find(string.lower(map.name),string.lower(s)) then
- local row = guiGridListAddRow ( MapsGridListGUI )
- guiGridListSetItemText ( MapsGridListGUI, row, 1, map.name, false, false )
- guiGridListSetItemData ( MapsGridListGUI, row, 1, map.resname)
- end
- else
- local row = guiGridListAddRow ( MapsGridListGUI )
- guiGridListSetItemText ( MapsGridListGUI, row, 1, map.name, false, false )
- guiGridListSetItemData ( MapsGridListGUI, row, 1, map.resname)
- end
- end
- end
- end
- end
- end
- ------------------------------------------
- -- Achievements
- ------------------------------------------
- function unlockAChievement(Achievement)
- LastACName = AchievementsName[Achievement]
- Move = -400
- Alpha = 255
- Rotation = 0
- addEventHandler ( "onClientRender", gRoot, AchievementUnlockedRender)
- playSound ( "img/ACUnlocked.wav")
- end
- function AchievementUnlockedRender()
- Rotation = Rotation + 2
- if Move <= 5 then
- dxDrawImage ( Move, (sH/2), 400, 100, "img/AchievementUnlocked.png" , 0, 0, 0,tocolor(255,255,255,Alpha),true)
- dxDrawImage ( Move, (sH/2), 100, 100, "img/AchievementUnlocked2.png" , Rotation, 0, 0,tocolor(255,255,255,Alpha),true)
- dxDrawText ( "Achievement Unlocked: \n\n"..LastACName.."", Move+80, (sH/2)+10, 400,100,tocolor(0,170,255,Alpha), 0.7,"bankgothic", "left", "top",false,false,true )
- else
- dxDrawImage ( 20, (sH/2), 400, 100, "img/AchievementUnlocked.png" , 0, 0, 0,tocolor(255,255,255,Alpha),true)
- dxDrawImage ( 20, (sH/2), 100, 100, "img/AchievementUnlocked2.png" , Rotation, 0, 0,tocolor(255,255,255,Alpha),true)
- dxDrawText ( "Achievement Unlocked: \n\n"..LastACName.."", 110, (sH/2)+10, 400,100,tocolor(0,170,255,Alpha), 0.7,"bankgothic", "left", "top",false,false,true )
- end
- if Move <= 5000 then
- Move = Move + 20
- else
- Alpha = Alpha - 5
- end
- if Alpha <= 0 then
- removeEventHandler ( "onClientRender", gRoot, AchievementUnlockedRender)
- end
- end
- function convertTime(timeinseconds)
- Days = math.floor(timeinseconds/86400)
- timeinseconds = timeinseconds - Days*86400
- Hours = math.floor(timeinseconds/3600)
- timeinseconds = timeinseconds - Hours*3600
- Minutes = math.floor(timeinseconds/60)
- timeinseconds = timeinseconds - Minutes*60
- Seconds = timeinseconds
- if Days > 0 then
- Time = Days.." days "..Hours.."h "..Minutes.."m "..Seconds.."s"
- elseif Hours > 0 then
- Time = Hours.."h "..Minutes.."m "..Seconds.."s"
- elseif Minutes > 0 then
- Time = Minutes.."m "..Seconds.."s"
- else
- Time = Seconds.."s"
- end
- return Time
- end
- ------------------------------------------
- -- Tops
- ------------------------------------------
- function SortTops(datatype,playerData,thePlayer,beforer,afterer)
- guiGridListClear(TopGrid)
- if ColC then guiGridListRemoveColumn ( TopGrid, ColC ) end
- ColC = guiGridListAddColumn ( TopGrid, string.sub(datatype,5,-2), 0.2 )
- table.sort(playerData, function(x,y) return x.dType > y.dType end)
- for k, v in ipairs(playerData) do
- if afterer ~= " " then
- local row = guiGridListAddRow ( TopGrid )
- guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
- guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
- guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, tostring(math.round(playerData[k].dType,2)),afterer), false, true )
- if k == 1 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
- elseif k == 2 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
- elseif k == 3 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
- elseif k > 3 and k < 131 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
- else
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
- end
- if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
- guiGridListSetSelectedItem ( TopGrid,row, 1)
- guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
- end
- else
- local row = guiGridListAddRow ( TopGrid )
- guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
- guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
- guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, convertTime(playerData[k].dType),afterer), false, true )
- if k == 1 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
- elseif k == 2 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
- elseif k == 3 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
- elseif k > 3 and k < 131 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
- else
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
- end
- if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
- guiGridListSetSelectedItem ( TopGrid,row, 1)
- guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
- end
- end
- end
- end
- function SortTopsMaps(datatype,playerData,thePlayer,beforer,afterer)
- guiGridListClear(TopGrid)
- if ColC then guiGridListRemoveColumn ( TopGrid, ColC ) end
- ColC = guiGridListAddColumn ( TopGrid, "Played", 0.2 )
- table.sort(playerData, function(x,y) return x.dType > y.dType end)
- for k, v in ipairs(playerData) do
- if afterer ~= " " then
- local row = guiGridListAddRow ( TopGrid )
- guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
- guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
- guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, tostring(math.round(playerData[k].dType,2)),afterer), false, true )
- if k == 1 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
- elseif k == 2 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
- elseif k == 3 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
- elseif k > 3 and k < 131 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
- else
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
- end
- if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
- guiGridListSetSelectedItem ( TopGrid,row, 1)
- guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
- end
- else
- local row = guiGridListAddRow ( TopGrid )
- guiGridListSetItemText ( TopGrid, row, 1, k, false, true )
- guiGridListSetItemText ( TopGrid, row, 2, playerData[k].pName, false, false )
- guiGridListSetItemText ( TopGrid, row, 3, string.format("%s%s%s",beforer, convertTime(playerData[k].dType),afterer), false, true )
- if k == 1 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,0,255 )
- elseif k == 2 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
- elseif k == 3 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 150,100,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 150,100,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 150,100,0,255 )
- elseif k > 3 and k < 131 then
- guiGridListSetItemColor ( TopGrid, row , 1 , 125+k,125+k,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 125+k,125+k,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 125+k,125+k,255,255 )
- else
- guiGridListSetItemColor ( TopGrid, row , 1 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 255,255,255,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 255,255,255,255 )
- end
- if getPlayerName(thePlayer) == tostring(playerData[k].pName) then
- guiGridListSetSelectedItem ( TopGrid,row, 1)
- guiGridListSetItemColor ( TopGrid, row , 1 , 0,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 2 , 0,255,0,255 )
- guiGridListSetItemColor ( TopGrid, row , 3 , 0,255,0,255 )
- end
- end
- end
- end
- CashSize = 0.6
- function refreshCash(cash)
- MyCash = cash
- end
- --[[function showCash()
- if MyCash then
- dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5-1, sW-14, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5, sW-14, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $"..MyCash, 16, sH/5.5+1, sW-14, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $"..MyCash, 15, sH/5.5+1, sW-15, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5+1, sW-16, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5, sW-16, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $"..MyCash, 14, sH/5.5-1, sW-16, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $"..MyCash, 15, sH/5.5-1, sW-15, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#00AAFFCash #FFFFFF$"..MyCash, 15, sH/5.5, sW-15, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- else
- dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5-1, sW-14, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5, sW-14, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $0", 16, sH/5.5+1, sW-14, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $0", 15, sH/5.5+1, sW-15, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5+1, sW-16, sH+1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5, sW-16, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $0", 14, sH/5.5-1, sW-16, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#000000Cash $0", 15, sH/5.5-1, sW-15, sH-1, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- dxDrawColorTextPuma("#00AAFFCash #FFFFFF$0", 15, sH/5.5, sW-15, sH, tocolor(255,255,255,255), CashSize, "bankgothic", "right", "top")
- end
- end]]--
- ------------------------------------------
- -- Triggering
- ------------------------------------------
- ------------------------------------------
- -- Calling function from the client's side
- ------------------------------------------
- function callClientFunction(funcname, ...)
- local arg = { ... }
- if (arg[1]) then
- for key, value in next, arg do arg[key] = tonumber(value) or value end
- end
- loadstring("return "..funcname)()(unpack(arg))
- end
- addEvent("onServerCallsClientFunction", true)
- addEventHandler("onServerCallsClientFunction", resourceRoot, callClientFunction)
- -----------------------
- -- Call server function
- -----------------------
- function callServerFunction(funcname, ...)
- local arg = { ... }
- if (arg[1]) then
- for key, value in next, arg do
- if (type(value) == "number") then arg[key] = tostring(value) end
- end
- end
- triggerServerEvent("onClientCallsServerFunction", resourceRoot , funcname, unpack(arg))
- end
- function math.round(number, decimals, method)
- decimals = decimals or 0
- local factor = 10 ^ decimals
- if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
- else return tonumber(("%."..decimals.."f"):format(number)) end
- end
- ------------------------------------------
- -- PlayerNameFunctions
- ------------------------------------------
- function getPlayerNameWithoutColorCode (who)
- local name = getPlayerName(who)
- local name = string.gsub(name,'#%x%x%x%x%x%x',"")
- return name
- end
- function getPlayerFromNameWithoutColorCode (name)
- for i,pla in ipairs(getElementsByType("player")) do
- if getPlayerNameWithoutColorCode (pla) == name then
- return pla
- end
- end
- end
- function findPlayerByName (name)
- local player = getPlayerFromName(name)
- if player then return player end
- for i, player in ipairs(getElementsByType("player")) do
- if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then
- return player
- end
- end
- return false
- end
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- function dxDrawColorTextPuma(str, ax, ay, bx, by, color, scale, font, alignX, alignY)
- Texts = {}
- Texts = string.explode(str,"/newline/")
- for i=1,#Texts do
- dxDrawColorTextNext(Texts[i], ax, ay+(dxGetFontHeight ( scale, font ))*(i-1), bx, by, color, scale, font, alignX, alignY)
- end
- end
- function dxDrawColorTextNext(str, ax, ay, bx, by, color, scale, font, alignX, alignY)
- if alignX then
- if alignX == "center" then
- local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
- ax = ax + (bx-ax)/2 - w/2
- elseif alignX == "right" then
- local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font)
- ax = bx - w
- end
- end
- if alignY then
- if alignY == "center" then
- local h = dxGetFontHeight(scale, font)
- ay = ay + (by-ay)/2 - h/2
- elseif alignY == "bottom" then
- local h = dxGetFontHeight(scale, font)
- ay = by - h
- end
- end
- local pat = "(.-)#(%x%x%x%x%x%x)"
- local s, e, cap, col = str:find(pat, 1)
- local last = 1
- while s do
- if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end
- if s ~= 1 or cap ~= "" then
- local w = dxGetTextWidth(cap, scale, font)
- dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
- ax = ax + w
- color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255)
- end
- last = e + 1
- s, e, cap, col = str:find(pat, last)
- end
- if last <= #str then
- cap = str:sub(last)
- local w = dxGetTextWidth(cap, scale, font)
- dxDrawText(cap, ax, ay, ax + w, by, color, scale, font)
- end
- end
- function string.explode(self, separator)
- Check("string.explode", "string", self, "ensemble", "string", separator, "separator")
- if (#self == 0) then return {} end
- if (#separator == 0) then return { self } end
- return loadstring("return {\""..self:gsub(separator, "\",\"").."\"}")()
- end
- function Check(funcname, ...)
- local arg = {...}
- if (type(funcname) ~= "string") then
- error("Argument type mismatch at 'Check' ('funcname'). Expected 'string', got '"..type(funcname).."'.", 2)
- end
- if (#arg % 3 > 0) then
- error("Argument number mismatch at 'Check'. Expected #arg % 3 to be 0, but it is "..(#arg % 3)..".", 2)
- end
- for i=1, #arg-2, 3 do
- if (type(arg[i]) ~= "string" and type(arg[i]) ~= "table") then
- error("Argument type mismatch at 'Check' (arg #"..i.."). Expected 'string' or 'table', got '"..type(arg[i]).."'.", 2)
- elseif (type(arg[i+2]) ~= "string") then
- error("Argument type mismatch at 'Check' (arg #"..(i+2).."). Expected 'string', got '"..type(arg[i+2]).."'.", 2)
- end
- if (type(arg[i]) == "table") then
- local aType = type(arg[i+1])
- for _, pType in next, arg[i] do
- if (aType == pType) then
- aType = nil
- break
- end
- end
- if (aType) then
- error("Argument type mismatch at '"..funcname.."' ('"..arg[i+2].."'). Expected '"..table.concat(arg[i], "' or '").."', got '"..aType.."'.", 3)
- end
- elseif (type(arg[i+1]) ~= arg[i]) then
- error("Argument type mismatch at '"..funcname.."' ('"..arg[i+2].."'). Expected '"..arg[i].."', got '"..type(arg[i+1]).."'.", 3)
- end
- end
- end
- -- When element data for the player changes, bind or unbind key.
- addEventHandler("onClientElementDataChange", getLocalPlayer(),
- function(dataName, oldValue)
- if(getElementType(source) ~= "player" or dataName ~= "state")then return end
- local newValue = getElementData(source, dataName)
- if(newValue == "dead")then
- reset =true
- setTimer(function()
- if(#vehicleData > 0 and running)then
- showRespawn = true
- setElementData(getLocalPlayer(), "respawn.playing", false, true)
- bindKey(RESPAWN_KEY, "up", respawn)
- end
- end,
- 3000, 1)
- else
- unbindKey(RESPAWN_KEY, "up", respawn)
- showRespawn = false
- setElementData(getLocalPlayer(), "respawn.playing", false, true)
- end
- if(newValue == "alive" and oldValue ~= "alive")then
- reset = false
- end
- end)
- -- respawn player, later add "checkpoints"
- function respawn()
- reset = false
- unbindKey(RESPAWN_KEY, "up", respawn)
- showRespawn = false
- setElementData(getLocalPlayer(), "respawn.playing", true, true)
- local index = #vehicleData
- local index2 = #vehicleData
- -- Save memory and go back to later saved positions if dying too fast.
- local timeWasted = math.floor((getTickCount() - lastSaved)/1000)
- if(timeWasted <= 7 and index > 1)then
- table.remove(vehicleData, index)
- index = #vehicleData
- outputDebugString("Vehicle data num: "..index.." removed respawn.")
- end
- outputDebugString("Respawning with vehicle data index: "..index)
- triggerServerEvent("onClientRequestRespawn", getLocalPlayer(), vehicleData[index])
- if(index2 > 1 and index == index2)then
- table.remove(vehicleData, index)
- outputDebugString("Vehicle data num: "..index.." removed.")
- end
- end
- addEventHandler("onClientRender", getRootElement(),
- function()
- if(reset)then
- resetTimer(saveTimer)
- end
- -- Dont show text if player is not allowed to respawn.
- if not showRespawn then return end
- local x, y = screen_width/2 - textWidth/2, screen_height * 0.75 - fontHeight/2
- dxDrawColoredText(text, x, y, screen_width, screen_height, color, scale, font)
- end)
- -- Save vehicle data, to later spawn with that data.
- function saveVehicleData()
- local vehicle = getPedOccupiedVehicle(getLocalPlayer())
- if(not running or showRespawn or (not vehicle) or reset)then return end
- local mode = getElementModel(vehicle)
- if(mode == 425)then return end
- local lastSaved = getTickCount()
- local index = #vehicleData + 1
- vehicleData[index] = {}
- local posX, posY, posZ = getElementPosition(vehicle)
- local rotX, rotY, rotZ = getElementRotation(vehicle)
- local velX, velY, velZ = getElementVelocity(vehicle)
- local turnVelX, turnVelY, turnVelZ = getVehicleTurnVelocity(vehicle)
- local health = getElementHealth(vehicle)
- local model = getElementModel(vehicle)
- -- Later add worldSpecialProperty too.
- vehicleData[index].posX = posX
- vehicleData[index].posY = posY
- vehicleData[index].posZ = posZ
- vehicleData[index].rotX = rotX
- vehicleData[index].rotY = rotY
- vehicleData[index].rotZ = rotZ
- vehicleData[index].velX = velX
- vehicleData[index].velY = velY
- vehicleData[index].velZ = velZ
- vehicleData[index].turnVelX = turnVelX
- vehicleData[index].turnVelY = turnVelY
- vehicleData[index].turnVelZ = turnVelZ
- vehicleData[index].health = health
- vehicleData[index].model = model
- vehicleData[index].dimension = getElementDimension(vehicle)
- vehicleData[index].nitro = nil
- local upgrades = getVehicleUpgrades(vehicle)
- for upgradeKey, upgradeValue in ipairs(upgrades) do
- if(tonumber(upgradeValue) >= 1008 and tonumber(upgradeValue) <= 1010)then
- vehicleData[index].nitro = tonumber(upgradeValue)
- end
- end
- outputDebugString("Vehicle data num: "..index.." saved.")
- end
- saveTimer = setTimer(saveVehicleData, SAVE_INTER, 0)
- function saveRespawnToSpawnpoint(player)
- local vehicle = getPedOccupiedVehicle(player)
- local index = #vehicleData + 1
- vehicleData[index] = {}
- local spawn = getElementsByType("spawnpoint")
- local posX, posY, posZ = getElementData(spawn[1], "posX"), getElementData(spawn[1], "posY"), getElementData(spawn[1], "posZ")
- local rotX, rotY, rotZ = getElementData(spawn[1], "rotX"), getElementData(spawn[1], "rotY"), getElementData(spawn[1], "rotZ")
- local velX, velY, velZ = 0, 0, 0
- local turnVelX, turnVelY, turnVelZ = 0, 0, 0
- local health = getElementHealth(vehicle)
- local model = getElementData(spawn[1], "vehicle")
- -- Later add worldSpecialProperty too.
- vehicleData[index].posX = posX
- vehicleData[index].posY = posY
- vehicleData[index].posZ = posZ
- vehicleData[index].rotX = rotX
- vehicleData[index].rotY = rotY
- vehicleData[index].rotZ = rotZ
- vehicleData[index].velX = velX
- vehicleData[index].velY = velY
- vehicleData[index].velZ = velZ
- vehicleData[index].turnVelX = turnVelX
- vehicleData[index].turnVelY = turnVelY
- vehicleData[index].turnVelZ = turnVelZ
- vehicleData[index].health = health
- vehicleData[index].model = model
- vehicleData[index].dimension = getElementDimension(vehicle)
- end
- addEvent("onClientRaceStateChanging", true)
- addEventHandler("onClientRaceStateChanging", getRootElement(),
- function(newState, oldState)
- if(newState == "Running")then
- local state = tostring(getElementData(getLocalPlayer(), "state"))
- if(state == "waiting")then
- --[[
- reset = false
- running = true
- vehicleData = {}
- saveRespawnToSpawnpoint(getLocalPlayer())
- showRespawn = true
- setElementData(getLocalPlayer(), "respawn.playing", false, true)
- bindKey(RESPAWN_KEY, "up", respawn)
- --]]
- elseif(state == "alive" or state == "not ready")then
- reset = false
- running = true
- for i = 1, #vehicleData do
- table.remove(vehicleData, i)
- end
- vehicleData = {}
- saveVehicleData()
- end
- end
- if(newState == "PostFinish" or newState == "NoMap")then
- reset = true
- running = false
- unbindKey(RESPAWN_KEY, "up", respawn)
- showRespawn = false
- setElementData(getLocalPlayer(), "respawn.playing", false, true)
- end
- end)
- addEventHandler("onClientPlayerWasted", getLocalPlayer(),
- function()
- if(source ~= getLocalPlayer())then return end
- reset = true
- setElementData(getLocalPlayer(), "respawn.playing", false, true)
- setTimer(function()
- --local state = getElementData(getLocalPlayer(), "respawn.playing") or true
- if(#vehicleData > 0 and running)then
- showRespawn = true
- setElementData(getLocalPlayer(), "respawn.playing", false, true)
- bindKey(RESPAWN_KEY, "up", respawn)
- end
- end,
- 3000, 1)
- end)
- local unfreeze = {}
- addEvent("clientUnfreezeOnReady", true)
- addEventHandler("clientUnfreezeOnReady", getRootElement(),
- function(vehicle, vehData)
- -- source is the vehicle to unfreeze
- unfreeze.vehicle = vehicle
- unfreeze.health = vehData.health
- unfreeze.dim = vehData.dimension
- unfreeze.x, unfreeze.y, unfreeze.z = vehData.posX, vehData.posY, vehData.posZ
- unfreeze.vx, unfreeze.vy, unfreeze.vz = vehData.velX, vehData.velY, vehData.velZ
- unfreeze.tx, unfreeze.ty, unfreeze.tz = vehData.turnVelX, vehData.turnVelY, vehData.turnVelZ
- setElementFrozen(vehicle, false)
- addEventHandler("onClientRender", getRootElement(), unfreezeOnReady)
- end)
- function unfreezeOnReady()
- setElementHealth(unfreeze.vehicle, unfreeze.health)
- setElementPosition(unfreeze.vehicle, unfreeze.x, unfreeze.y, unfreeze.z)
- if(not isElementFrozen(unfreeze.vehicle))then
- setElementDimension(unfreeze.vehicle, unfreeze.dim)
- setElementVelocity(unfreeze.vehicle, unfreeze.vx, unfreeze.vy, unfreeze.vz)
- setVehicleTurnVelocity(unfreeze.vehicle, unfreeze.tx, unfreeze.ty, unfreeze.tz)
- removeEventHandler("onClientRender", getRootElement(), unfreezeOnReady)
- end
- end
- function dxDrawColoredText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI)
- -- Making them optional.
- right = right or screen_width
- bottom = bottom or screen_height
- while(left < 0) do
- left = screen_width - math.abs(left)
- end
- while(top < 0) do
- top = screen_height - math.abs(top)
- end
- while(right < 0) do
- right = screen_width - math.abs(right)
- end
- while(bottom < 0) do
- bottom = screen_height - math.abs(bottom)
- end
- if(right > screen_width)then right = screen_width end
- if(bottom > screen_height)then bottom = screen_height end
- color = color or tocolor(255, 255, 255, 200)
- scale = scale or 1
- font = font or "default"
- alignX = alignX or "left"
- alignY = alignY or "top"
- clip = clip or false
- wordBreak = wordBreak or false
- postGUI = postGUI or true
- local alpha = intToAlpha(color)
- local text_width = 0
- local offset = 0
- local text_height = dxGetFontHeight(scale, font)
- local TEXT_WIDTH = dxGetTextWidth(text:gsub("#%x%x%x%x%x%x", ""), scale, font)
- local off = -TEXT_WIDTH
- local width = 0
- local height = 0
- if(alignX == "center")then
- left = left + width/2 - TEXT_WIDTH/2
- end
- if(alignX == "right")then
- left = left + width - TEXT_WIDTH
- end
- if(alignY == "center")then
- top = top + height/2 - text_height/2
- end
- if(alignY == "bottom")then
- top = top + height - text_height
- end
- alignX = "left"
- alignY = "top"
- -- 0 index ?
- local col1, col2 = string.find(text, "#%x%x%x%x%x%x")
- if col1 ~= nil then col1 = col1-1 end
- -- draw text with the color we sent until we find hexadecimal code.
- for i = 1, col1 or string.len(text) do
- text_width = dxGetTextWidth(string.sub(text, i, i), scale, font)
- dxDrawText(string.sub(text, i, i), left + offset, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI)
- offset = offset + text_width
- end
- while(string.find(text, "#%x%x%x%x%x%x", i))do
- local hex1, hex2 = string.find(text, "#%x%x%x%x%x%x")
- local r, g, b, a = getColorFromString(string.sub(text, hex1, hex2))
- text = string.sub(text, hex2 + 1)
- hex1, hex2 = string.find(text, "#%x%x%x%x%x%x")
- if hex1 ~= nil then hex1 = hex1-1 end
- for i = 1, hex1 or string.len(text) do
- text_width = dxGetTextWidth(string.sub(text, i, i), scale, font)
- dxDrawText(string.sub(text, i, i), left + offset, top, right, bottom, tocolor(r, g, b, alpha), scale, font, alignX, alignY, clip, wordBreak, postGUI)
- offset = offset + text_width
- end
- end
- end
- function intToAlpha(color)
- local a = 16777216
- local red, green, blue, alpha = 0, 0, 0, 0
- local ap = 1
- if(color < 0)then
- color = 2147483648 + (-color)
- alpha = 383
- ap = -ap
- end
- while(color >= a)do
- alpha = alpha + ap
- color = color - a
- end
- return alpha
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement