Guest User

panel_client

a guest
Dec 4th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 109.21 KB | None | 0 0
  1. ------------------------------------------
  2. ------------------------------------------
  3. --          Script by NeXTreme          --
  4. --                                      --
  5. --                                      --
  6. --        Made for the ASG clan         --
  7. --                                      --
  8. ------------------------------------------
  9.  
  10.  
  11.  
  12.  
  13.  
  14. --------------------
  15. -- Set all variables
  16. --------------------
  17.  
  18. screenWidth, screenHeight = guiGetScreenSize()
  19. function setVariables()
  20.     killedByAfk = 0
  21.     betPlayer = "none"
  22.     betAmount = 0
  23.     oldAmount = 0
  24.     achievementActive = 0
  25. end
  26. addEventHandler("onClientResourceStart",getRootElement(),setVariables)
  27.  
  28. function vars2()
  29.     colorPickMode = false
  30.     afkCounter = 1
  31.     tCount = 11
  32.     playerIsChatting = false
  33.     chatRequestMode = false
  34.     chatNotificationMode = false
  35.     chatRequestedBy = "none"
  36.     playerIsBusy = false
  37.     newMessageArrived = false
  38.     setElementData(getLocalPlayer(),"chattingWith","none")
  39.     allowPersonalDetails = true
  40.     allowStats = true
  41.     soundMessage = true
  42.     soundRequest = true
  43.     showOnDeath = false
  44.     useHunterSkin = false
  45.     recentlySavedSettings = false
  46.     customHorn = {}
  47.     hornNum = 0
  48.     setHornSound = 0
  49.     acceptMode = 1
  50.     totalServerMaps = 0
  51.     totalDmMaps = 0
  52.     totalDdMaps = 0
  53.     screenWidth,screenHeight = guiGetScreenSize()
  54.     mainWindowWidth = 619
  55.     mainWindowHeight = 365
  56.     PDWindowWidth = 369
  57.     PDWindowHeight = 370
  58.     CNWindowWidth = 340
  59.     CNWindowHeight = 123
  60.     SWindowWidth = 541
  61.     SWindowHeight = 274
  62.     chatImageSize = 135
  63.     SkinWindowWidth = 604
  64.     SkinWindowHeight = 429
  65.     colorWindowWidth = 405
  66.     colorWindowHeight = 195
  67. end
  68. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),vars2)
  69.  
  70.  
  71.  
  72.  
  73. ------------
  74. -- Userpanel
  75. ------------
  76.  
  77.  
  78. -- Create achievements
  79. achievements = {
  80. "New kid in town",
  81. "Easy as",
  82. "Dominating",
  83. "Unstoppable",
  84. "FTW!",
  85. "Deathstalker",
  86. "Leveller - Rank I",
  87. "Leveller - Rank II",
  88. "Leveller - Rank III",
  89. "Leveller - Rank IV",
  90. "Levelling Champion",
  91. "Elite Leveller - Rank I",
  92. "Elite Leveller - Rank II",
  93. "Elite Leveller - Rank III",
  94. "Elite Levelling Champion",
  95. "Hunter magnet",
  96. "Master of disaster",
  97. "King of the sky",
  98. "My very own toptime",
  99. "Toptime expert",
  100. "Gaming spree",
  101. "All-time player",
  102. "Connect frenzy",
  103. "Climbing the ladder",
  104. "Money saver",
  105. "Blue-collar millionaire",
  106. "Colors are fun",
  107. "Pimp my ride",
  108. "Communicative gamer award",
  109. "Charity",
  110. "Glimpse of the future",
  111. "Centurion",
  112. "Milestone",
  113. "Millennium",
  114. "Socializer",
  115. "Speed writer",
  116. "Quick reflexes",
  117. "I care how I look",
  118. "Horn lover",
  119. "Achievement Hunter"}
  120.  
  121.  
  122. details = {
  123. "Join the server for the first time.",
  124. "Win on 10 maps.",
  125. "Win on 50 maps.",
  126. "Win on 100 maps.",
  127. "Win on 200 maps.",
  128. "Die 300 times.",
  129. "Reach level 5.",
  130. "Reach level 10.",
  131. "Reach level 15.",
  132. "Reach level 20.",
  133. "Reach level 25.",
  134. "Reach level 10 ELITE.",
  135. "Reach level 15 ELITE.",
  136. "Reach level 20 ELITE.",
  137. "Reach level 25 ELITE.",
  138. "Get 10 hunters.",
  139. "Get 50 hunters.",
  140. "Get 100 hunters.",
  141. "Set a top hunter time.",
  142. "Set 10 top hunter times.",
  143. "Play for 20 hours.",
  144. "Play for 50 hours.",
  145. "Join the server 40 times.",
  146. "Get a total of $10,000.",
  147. "Get a total of $100,000.",
  148. "Get a total of $1,000,000.",
  149. "Change your headlights color.",
  150. "Change your vehicle color.",
  151. "Start a chat with someone.",
  152. "Send some money to a player.",
  153. "Buy a next map.",
  154. "Play a total of 100 maps.",
  155. "Play a total of 500 maps.",
  156. "Play a total of 1000 maps.",
  157. "Update your personal details.",
  158. "Win 15 reaction tests.",
  159. "Win a reaction test in 5 seconds or less.",
  160. "Buy any skin from the shop.",
  161. "Buy any horn from the shop.",
  162. "Unlock all other achievements."}
  163.  
  164.  
  165. -- Create horns
  166. hornName={
  167. "Default GTA horn",
  168. "Airhorn",
  169. "Clown",
  170. "Train",
  171. "Fog horn",
  172. "Submarine",
  173. "Military trumpet",
  174. "Mr. Whoopie"}
  175.  
  176. hornPrice={
  177. "  N/A",
  178. "  2000",
  179. "  4000",
  180. "  6000",
  181. "  8000",
  182. "  10000",
  183. "  15000",
  184. "  20000"}
  185.  
  186. hornSound={
  187. "sounds/airhorn.wav",
  188. "sounds/clownhorn.mp3",
  189. "sounds/trainhorn.mp3",
  190. "sounds/cargoshiphorn.mp3",
  191. "sounds/submarinehorn.wav",
  192. "sounds/generalleehorn.mp3",
  193. "sounds/whoopiehorn.mp3"}
  194.  
  195.  
  196.  
  197. function onPlayerResourceStart()
  198.  
  199.     -- Create all the tabs
  200.     tabs = {
  201.         guiCreateWindow(screenWidth/2-mainWindowWidth/2,screenHeight/2-mainWindowHeight/2,mainWindowWidth,mainWindowHeight,"WARNING! The userpanel has failed to load! Please contact Jems as soon as possible!!",false),
  202.         guiCreateWindow(screenWidth/2-mainWindowWidth/2,screenHeight/2-mainWindowHeight/2,mainWindowWidth,mainWindowHeight,"Players",false),
  203.         guiCreateWindow(screenWidth/2-mainWindowWidth/2,screenHeight/2-mainWindowHeight/2,mainWindowWidth,mainWindowHeight,"Achievements",false),
  204.         guiCreateWindow(screenWidth/2-mainWindowWidth/2,screenHeight/2-mainWindowHeight/2,mainWindowWidth,mainWindowHeight,"Shop",false),
  205.         guiCreateWindow(screenWidth/2-mainWindowWidth/2,screenHeight/2-mainWindowHeight/2,mainWindowWidth,mainWindowHeight,"Maps",false),
  206.         guiCreateWindow(screenWidth/2-mainWindowWidth/2,screenHeight/2-mainWindowHeight/2,mainWindowWidth,mainWindowHeight,"Options",false)
  207.     }
  208.  
  209.  
  210.     guiSetVisible(tabs[1],false)
  211.     guiSetVisible(tabs[2],false)
  212.     guiSetVisible(tabs[3],false)
  213.     guiSetVisible(tabs[4],false)
  214.     guiSetVisible(tabs[5],false)
  215.     guiSetVisible(tabs[6],false)
  216.  
  217.  
  218.  
  219.     -- "Stats" TAB
  220.     lblStats = guiCreateLabel(18,24,150,49,"Stats",false,tabs[1])
  221.     guiLabelSetColor(lblStats,1,176,240)
  222.     guiLabelSetVerticalAlign(lblStats,"top")
  223.     guiLabelSetHorizontalAlign(lblStats,"left",false)
  224.     guiSetFont(lblStats,"sa-header")
  225.  
  226.     lblPlayerLevel = guiCreateLabel(18,83,136,15,"Level: N/A",false,tabs[1])
  227.     guiSetFont(lblPlayerLevel,"default-bold-small")
  228.  
  229.     lblPlayerStats = guiCreateLabel(18,201,84,16,"Player stats:",false,tabs[1])
  230.     guiLabelSetColor(lblPlayerStats,1,176,240)
  231.     guiSetFont(lblPlayerStats,"default-bold-small")
  232.  
  233.     lblPlayerMoney = guiCreateLabel(18,98,151,14,"Money: N/A",false,tabs[1])
  234.     guiLabelSetColor(lblPlayerMoney,255,255,255)
  235.     guiSetFont(lblPlayerMoney,"default-bold-small")
  236.  
  237.     lblAchievementsUnlocked = guiCreateLabel(18,126,180,14,"Achievements unlocked: 0/40",false,tabs[1])
  238.     guiSetFont(lblAchievementsUnlocked,"default-bold-small")
  239.  
  240.     lblTotalPlayingTime = guiCreateLabel(18,156,292,15,"Total playing time: N/A",false,tabs[1])
  241.     guiSetFont(lblTotalPlayingTime,"default-bold-small")
  242.  
  243.     lblNextLevelProgress = guiCreateLabel(335,131,232,45,"Progress to next level:",false,tabs[1])
  244.     guiLabelSetVerticalAlign(lblNextLevelProgress,"top")
  245.     guiLabelSetHorizontalAlign(lblNextLevelProgress,"center",false)
  246.     guiSetFont(lblNextLevelProgress,"default-bold-small")
  247.  
  248.     lblPlayerLevelRank = guiCreateLabel(388,45,124,22,"Loading...",false,tabs[1])
  249.     guiLabelSetColor(lblPlayerLevelRank,1,176,240)
  250.     guiLabelSetVerticalAlign(lblPlayerLevelRank,"bottom")
  251.     guiLabelSetHorizontalAlign(lblPlayerLevelRank,"center",false)
  252.     guiSetFont(lblPlayerLevelRank,"default-bold-small")
  253.  
  254.     lblMapsWon = guiCreateLabel(18,242,205,15,"Maps won: N/A",false,tabs[1])
  255.     guiSetFont(lblMapsWon,"default-bold-small")
  256.  
  257.     lblTotalMapsPlayed = guiCreateLabel(18,227,205,15,"Total maps played: N/A",false,tabs[1])
  258.     guiSetFont(lblTotalMapsPlayed,"default-bold-small")
  259.  
  260.     lblWinRatio = guiCreateLabel(18,260,205,15,"Map win ratio: N/A",false,tabs[1])
  261.     guiSetFont(lblWinRatio,"default-bold-small")
  262.  
  263.     lblTotalHunters = guiCreateLabel(18,285,205,15,"Total hunters reached: N/A",false,tabs[1])
  264.     guiSetFont(lblTotalHunters,"default-bold-small")
  265.  
  266.     lblTotalToptimes = guiCreateLabel(18,306,205,15,"Total toptimes set: N/A",false,tabs[1])
  267.     guiSetFont(lblTotalToptimes,"default-bold-small")
  268.  
  269.     lblTotalMoney = guiCreateLabel(222,227,205,15,"Total money earned: N/A",false,tabs[1])
  270.     guiSetFont(lblTotalMoney,"default-bold-small")
  271.  
  272.     lblTimesJoined = guiCreateLabel(18,171,205,15,"Times joined the server: N/A",false,tabs[1])
  273.     guiSetFont(lblTimesJoined,"default-bold-small")
  274.  
  275.     lblSentMoney = guiCreateLabel(222,242,205,15,"Money sent to players: N/A",false,tabs[1])
  276.     guiSetFont(lblSentMoney,"default-bold-small")
  277.  
  278.     lblTotalDeaths = guiCreateLabel(447,257,135,15,"Total deaths: N/A",false,tabs[1])
  279.     guiSetFont(lblTotalDeaths,"default-bold-small")
  280.  
  281.     lblTotalBets = guiCreateLabel(222,270,205,15,"Total bets: N/A",false,tabs[1])
  282.     guiSetFont(lblTotalBets,"default-bold-small")
  283.  
  284.     lblBetsWon = guiCreateLabel(222,285,205,15,"Bets won: N/A",false,tabs[1])
  285.     guiSetFont(lblBetsWon,"default-bold-small")
  286.  
  287.     lblMoneyEarnBet = guiCreateLabel(222,307,205,15,"Money earned with betting: N/A",false,tabs[1])
  288.     guiSetFont(lblMoneyEarnBet,"default-bold-small")
  289.  
  290.     lblTotalReactionTests = guiCreateLabel(447,217,135,15,"Reaction tests won: N/A",false,tabs[1])
  291.     guiSetFont(lblTotalReactionTests,"default-bold-small")
  292.  
  293.     lblBestReactionTime = guiCreateLabel(447,232,135,15,"Best reaction time: N/A",false,tabs[1])
  294.     guiSetFont(lblBestReactionTime,"default-bold-small")
  295.  
  296.  
  297.     progressLevel = guiCreateProgressBar(341,148,219,23,false,tabs[1])
  298.     buttonLevelUp = guiCreateButton(342,176,219,19,"Level up",false,tabs[1])
  299.  
  300.     imageLevel = guiCreateStaticImage(370,73,161,52,"levels/LEVEL1.png",false,tabs[1])
  301.  
  302.  
  303.     -- "Achievements" TAB
  304.     gridAchievements = guiCreateGridList(13,50,335,285,false,tabs[3])
  305.  
  306.     lblAchievementsUnlockedTab = guiCreateLabel(13,25,180,20,"Achievements unlocked: 0/40",false,tabs[3])
  307.     guiLabelSetColor(lblAchievementsUnlockedTab,1,176,240)
  308.     guiSetFont(lblAchievementsUnlockedTab,"default-bold-small")
  309.  
  310.     lblClickOnAchievement = guiCreateLabel(373,126,202,32,"Click on an achievement to see it's details!",false,tabs[3])
  311.     guiLabelSetColor(lblClickOnAchievement,1,176,240)
  312.     guiLabelSetVerticalAlign(lblClickOnAchievement,"top")
  313.     guiLabelSetHorizontalAlign(lblClickOnAchievement,"center",true)
  314.     guiSetFont(lblClickOnAchievement,"default-bold-small")
  315.  
  316.     lblAchievementName = guiCreateLabel(373,185,202,17,"Achievement name:  ",false,tabs[3])
  317.     guiLabelSetColor(lblAchievementName,171,205,239)
  318.     guiLabelSetVerticalAlign(lblAchievementName,"top")
  319.     guiLabelSetHorizontalAlign(lblAchievementName,"center",false)
  320.     guiSetFont(lblAchievementName,"default-bold-small")
  321.  
  322.     lblUnlockCondition = guiCreateLabel(373,250,202,17,"Unlock condition:",false,tabs[3])
  323.     guiLabelSetColor(lblUnlockCondition,171,205,239)
  324.     guiLabelSetVerticalAlign(lblUnlockCondition,"top")
  325.     guiLabelSetHorizontalAlign(lblUnlockCondition,"center",false)
  326.     guiSetFont(lblUnlockCondition,"default-bold-small")
  327.  
  328.     lblAchievementNameText = guiCreateLabel(373,207,197,31,"N/A",false,tabs[3])
  329.     guiLabelSetColor(lblAchievementNameText,255,255,255)
  330.     guiLabelSetVerticalAlign(lblAchievementNameText,"top")
  331.     guiLabelSetHorizontalAlign(lblAchievementNameText,"center",true)
  332.  
  333.     lblUnlockConditionText = guiCreateLabel(373,271,202,42,"N/A",false,tabs[3])
  334.     guiLabelSetColor(lblUnlockConditionText,255,255,255)
  335.     guiLabelSetVerticalAlign(lblUnlockConditionText,"top")
  336.     guiLabelSetHorizontalAlign(lblUnlockConditionText,"center",true)
  337.  
  338.     imageAchievement = guiCreateStaticImage(379,44,191,62,"img/Achievements.png",false,tabs[3])
  339.  
  340.     guiGridListAddColumn(gridAchievements,"Achievement name",0.9)
  341.     guiGridListSetSortingEnabled(gridAchievements,false)
  342.  
  343.     for i=1,#achievements do
  344.         local row = guiGridListAddRow (gridAchievements)
  345.         guiGridListSetItemText(gridAchievements,row,1,"   -- Locked --",false,false)
  346.         guiGridListSetItemColor(gridAchievements,row,1,170,170,170,255)
  347.     end
  348.  
  349.  
  350.     -- "Options" TAB
  351.  
  352.     buttonEditPersonalDetails = guiCreateButton(15,308,167,33,"Edit personal details",false,tabs[6])
  353.  
  354.     imageOptions = guiCreateStaticImage(209,21,381,84,"img/Options.png",false,tabs[6])
  355.  
  356.     buttonSaveOptions = guiCreateButton(480,308,110,32,"Save",false,tabs[6])
  357.  
  358.  
  359.     checkboxAllowPersonalDetails = guiCreateCheckBox(15,95,282,19,"Allow other players to see my personal details",false,false,tabs[6])
  360.     guiCheckBoxSetSelected(checkboxAllowPersonalDetails,true)
  361.  
  362.     checkboxAllowStats = guiCreateCheckBox(15,115,282,19,"Allow other players to see my stats",false,false,tabs[6])
  363.     guiCheckBoxSetSelected(checkboxAllowStats,true)
  364.  
  365.     checkboxShowOnDeath = guiCreateCheckBox(15,279,167,19,"Show userpanel on death",false,false,tabs[6])
  366.  
  367.     radioChatManual = guiCreateRadioButton(418,140,138,15,"Manual",false,tabs[6])
  368.     radioChatAccept = guiCreateRadioButton(418,160,138,15,"Automatically accept",false,tabs[6])
  369.     radioChatDecline = guiCreateRadioButton(418,181,138,15,"Automatically decline",false,tabs[6])
  370.     guiRadioButtonSetSelected(radioChatManual,true)
  371.  
  372.     lblGeneralSettings = guiCreateLabel(11,74,98,15,"General settings",false,tabs[6])
  373.     guiLabelSetColor(lblGeneralSettings,1,176,240)
  374.     guiSetFont(lblGeneralSettings,"default-bold-small")
  375.  
  376.     lblChat1 = guiCreateLabel(411,119,172,15,"Chat - accepting requests",false,tabs[6])
  377.     guiLabelSetColor(lblChat1,1,176,240)
  378.     guiSetFont(lblChat1,"default-bold-small")
  379.  
  380.     checkboxPlayWithCustomSkin = guiCreateCheckBox(15,150,293,19,"Play with purchased character skin",false,false,tabs[6])
  381.     guiCheckBoxSetSelected(checkboxPlayWithCustomSkin,true)
  382.  
  383.     checkboxPlayWithCustomVehicleColor = guiCreateCheckBox(15,169,282,19,"Play with custom vehicle color",false,false,tabs[6])
  384.     guiCheckBoxSetSelected(checkboxPlayWithCustomVehicleColor,true)
  385.  
  386.     lblChat2 = guiCreateLabel(411,214,172,15,"Chat - sound notifications",false,tabs[6])
  387.     guiLabelSetColor(lblChat2,1,176,240)
  388.     guiSetFont(lblChat2,"default-bold-small")
  389.  
  390.     checkboxSoundMessage = guiCreateCheckBox(414,238,158,17,"Sound on new message",false,false,tabs[6])
  391.     guiCheckBoxSetSelected(checkboxSoundMessage,true)
  392.  
  393.     checkboxSoundRequest = guiCreateCheckBox(414,259,158,17,"Sound on chat request",false,false,tabs[6])
  394.     guiCheckBoxSetSelected(checkboxSoundRequest,true)
  395.  
  396.     checkboxCustomNametag = guiCreateCheckBox(15,188,282,19,"Play with purchased nametag color",false,false,tabs[6])
  397.     guiCheckBoxSetSelected(checkboxCustomNametag,true)
  398.  
  399.  
  400.     lblSaveNotice = guiCreateLabel(192,308,278,33,"Make sure to click \"Save\" after you are done changing the settings!",false,tabs[6])
  401.     guiLabelSetColor(lblSaveNotice,255,255,150)
  402.     guiLabelSetVerticalAlign(lblSaveNotice,"center")
  403.     guiLabelSetHorizontalAlign(lblSaveNotice,"center",true)
  404.     guiSetFont(lblSaveNotice,"default-bold-small")
  405.  
  406.     checkboxHunterSkin = guiCreateCheckBox(15,224,282,19,"Use the custom hunter skin",false,false,tabs[6])
  407.  
  408.  
  409.     personalDetailsWindow = guiCreateWindow(screenWidth/2-PDWindowWidth/2,screenHeight/2-PDWindowHeight/2,PDWindowWidth,PDWindowHeight,"Personal details",false) -- Window for entering the personal details
  410.     guiSetVisible(personalDetailsWindow,false)
  411.  
  412.     pDetailsName = guiCreateEdit(138,40,214,25,"",false,personalDetailsWindow)
  413.  
  414.     pDetailsAge = guiCreateEdit(138,75,212,25,"",false,personalDetailsWindow)
  415.  
  416.     pDetailsEmail = guiCreateEdit(138,110,212,25,"",false,personalDetailsWindow)
  417.  
  418.     pDetailsMsn = guiCreateEdit(138,145,212,25,"",false,personalDetailsWindow)
  419.  
  420.     pDetailsSkype = guiCreateEdit(138,180,212,25,"",false,personalDetailsWindow)
  421.  
  422.     pDetailsXfire = guiCreateEdit(138,215,212,25,"",false,personalDetailsWindow)
  423.  
  424.     pDetailsICQ = guiCreateEdit(138,250,212,25,"",false,personalDetailsWindow)
  425.  
  426.     pDetailsXBL = guiCreateEdit(138,285,212,25,"",false,personalDetailsWindow)
  427.  
  428.     lblPDName = guiCreateLabel(20,40,101,25,"Name:",false,personalDetailsWindow)
  429.     guiLabelSetColor(lblPDName,1,176,240)
  430.     guiLabelSetVerticalAlign(lblPDName,"center")
  431.     guiLabelSetHorizontalAlign(lblPDName,"center",false)
  432.     guiSetFont(lblPDName,"default-bold-small")
  433.  
  434.     lblPDAge = guiCreateLabel(20,75,101,25,"Age:",false,personalDetailsWindow)
  435.     guiLabelSetColor(lblPDAge,1,176,240)
  436.     guiLabelSetVerticalAlign(lblPDAge,"center")
  437.     guiLabelSetHorizontalAlign(lblPDAge,"center",false)
  438.     guiSetFont(lblPDAge,"default-bold-small")
  439.  
  440.     lblPDEmail = guiCreateLabel(20,110,101,25,"eMail address:",false,personalDetailsWindow)
  441.     guiLabelSetColor(lblPDEmail,1,176,240)
  442.     guiLabelSetVerticalAlign(lblPDEmail,"center")
  443.     guiLabelSetHorizontalAlign(lblPDEmail,"center",false)
  444.     guiSetFont(lblPDEmail,"default-bold-small")
  445.  
  446.     lblPDMsn = guiCreateLabel(20,145,101,25,"MSN:",false,personalDetailsWindow)
  447.     guiLabelSetColor(lblPDMsn,1,176,240)
  448.     guiLabelSetVerticalAlign(lblPDMsn,"center")
  449.     guiLabelSetHorizontalAlign(lblPDMsn,"center",false)
  450.     guiSetFont(lblPDMsn,"default-bold-small")
  451.  
  452.     lblPDSkype = guiCreateLabel(20,180,101,25,"Skype:",false,personalDetailsWindow)
  453.     guiLabelSetColor(lblPDSkype,1,176,240)
  454.     guiLabelSetVerticalAlign(lblPDSkype,"center")
  455.     guiLabelSetHorizontalAlign(lblPDSkype,"center",false)
  456.     guiSetFont(lblPDSkype,"default-bold-small")
  457.  
  458.     lblPDXfire = guiCreateLabel(20,215,101,25,"XFire:",false,personalDetailsWindow)
  459.     guiLabelSetColor(lblPDXfire,1,176,240)
  460.     guiLabelSetVerticalAlign(lblPDXfire,"center")
  461.     guiLabelSetHorizontalAlign(lblPDXfire,"center",false)
  462.     guiSetFont(lblPDXfire,"default-bold-small")
  463.  
  464.     lblPDIcq = guiCreateLabel(20,250,101,25,"ICQ:",false,personalDetailsWindow)
  465.     guiLabelSetColor(lblPDIcq ,1,176,240)
  466.     guiLabelSetVerticalAlign(lblPDIcq ,"center")
  467.     guiLabelSetHorizontalAlign(lblPDIcq ,"center",false)
  468.     guiSetFont(lblPDIcq ,"default-bold-small")
  469.  
  470.     lblPDXbl = guiCreateLabel(20,285,101,25,"XBL Gamertag:",false,personalDetailsWindow)
  471.     guiLabelSetColor(lblPDXbl,1,176,240)
  472.     guiLabelSetVerticalAlign(lblPDXbl,"center")
  473.     guiLabelSetHorizontalAlign(lblPDXbl,"center",false)
  474.     guiSetFont(lblPDXbl,"default-bold-small")
  475.  
  476.     buttonPersonalDetailsSave = guiCreateButton(224,326,126,35,"Save",false,personalDetailsWindow)
  477.  
  478.  
  479.     -- "Players" TAB
  480.  
  481.     gridOnlinePlayers = guiCreateGridList(20,51,162,280,false,tabs[2])
  482.     guiGridListSetSortingEnabled(gridOnlinePlayers, false)
  483.     guiGridListAddColumn(gridOnlinePlayers,"Name",0.9)
  484.  
  485.     for _,player in ipairs(getElementsByType("player")) do
  486.         local row = guiGridListAddRow (gridOnlinePlayers)
  487.         guiGridListSetItemText(gridOnlinePlayers,row,1,string.gsub(getPlayerName(player),"#%x%x%x%x%x%x", ""),false,false)
  488.     end
  489.  
  490.     lblConnectedPlayers = guiCreateLabel(20,26,162,19,"Connected players",false,tabs[2])
  491.     guiLabelSetColor(lblConnectedPlayers,1,176,240)
  492.     guiLabelSetVerticalAlign(lblConnectedPlayers,"center")
  493.     guiLabelSetHorizontalAlign(lblConnectedPlayers,"center",false)
  494.     guiSetFont(lblConnectedPlayers,"default-bold-small")
  495.  
  496.     btnViewPersonalDetails = guiCreateButton(196,51,128,36,"View personal details",false,tabs[2])
  497.  
  498.     btnViewStats = guiCreateButton(196,96,128,36,"View stats",false,tabs[2])
  499.  
  500.     btnGiveMoney = guiCreateButton(417,288,130,43,"Send money",false,tabs[2])
  501.  
  502.     btnClearChat = guiCreateButton(196,206,128,26,"Clear chat",false,tabs[2])
  503.  
  504.     btnChatAIO = guiCreateButton(196,160,128,36,"Chat with player",false,tabs[2])
  505.     guiSetFont(btnChatAIO,"default-bold-small")
  506.  
  507.  
  508.     lblChattingWNotice = guiCreateLabel(343,26,80,19,"Chatting with:",false,tabs[2])
  509.     guiSetFont(lblChattingWNotice,"default-bold-small")
  510.  
  511.     lblChattingWith = guiCreateLabel(427,26,153,19,"Nobody",false,tabs[2])
  512.     guiLabelSetColor(lblChattingWith,255,0,0)
  513.     guiSetFont(lblChattingWith,"default-bold-small")
  514.  
  515.     btnSendInputMessage = guiCreateButton(528,206,52,25,"Send",false,tabs[2])
  516.  
  517.  
  518.     playerStatsWindow = guiCreateWindow(screenWidth/2-SWindowWidth/2,screenHeight/2-SWindowHeight/2,SWindowWidth,SWindowHeight,"Loading, please wait...",false)
  519.     guiWindowSetSizable(playerStatsWindow,false)
  520.     guiSetVisible(playerStatsWindow,false)
  521.  
  522.     lblPStats = guiCreateLabel(17,22,107,49,"Stats",false,playerStatsWindow)
  523.     guiLabelSetColor(lblPStats,1,176,240)
  524.     guiSetFont(lblPStats,"sa-header")
  525.  
  526.     lblPLevel = guiCreateLabel(17,81,97,16,"Level: N/A",false,playerStatsWindow)
  527.     guiSetFont(lblPLevel,"default-bold-small")
  528.  
  529.     lblPMoney = guiCreateLabel(17,97,129,16,"Money: N/A",false,playerStatsWindow)
  530.     guiSetFont(lblPMoney,"default-bold-small")
  531.  
  532.     lblPAchievementsUnlocked = guiCreateLabel(17,123,204,18,"Achievements unlocked: 0/40",false,playerStatsWindow)
  533.     guiSetFont(lblPAchievementsUnlocked,"default-bold-small")
  534.  
  535.     lblPTimesJoined = guiCreateLabel(17,141,204,18,"Times joined the server: N/A",false,playerStatsWindow)
  536.     guiSetFont(lblPTimesJoined,"default-bold-small")
  537.  
  538.     lblPLevel2 = guiCreateLabel(327,39,121,16,"Loading...",false,playerStatsWindow)
  539.     guiLabelSetColor(lblPLevel2,1,176,240)
  540.     guiLabelSetVerticalAlign(lblPLevel2,"center")
  541.     guiLabelSetHorizontalAlign(lblPLevel2,"center",false)
  542.     guiSetFont(lblPLevel2,"default-bold-small")
  543.  
  544.     lblPTotalMapsPlayed = guiCreateLabel(17,162,230,14,"Total maps played: N/A",false,playerStatsWindow)
  545.     guiSetFont(lblPTotalMapsPlayed,"default-bold-small")
  546.  
  547.     lblPMapsWon = guiCreateLabel(17,178,230,14,"Maps won: N/A",false,playerStatsWindow)
  548.     guiSetFont(lblPMapsWon,"default-bold-small")
  549.  
  550.     lblPWinRatio = guiCreateLabel(17,193,230,14,"Map win ratio: Calculating...",false,playerStatsWindow)
  551.     guiSetFont(lblPWinRatio,"default-bold-small")
  552.  
  553.     lblPTotalHunters = guiCreateLabel(17,212,230,14,"Total hunters reached: N/A",false,playerStatsWindow)
  554.     guiSetFont(lblPTotalHunters,"default-bold-small")
  555.  
  556.     lblPTotalToptimes = guiCreateLabel(17,226,230,14,"Total toptimes set: N/A",false,playerStatsWindow)
  557.     guiSetFont(lblPTotalToptimes,"default-bold-small")
  558.  
  559.     lblPTotalMoneyEarned = guiCreateLabel(247,141,230,18,"Total money earned: N/A",false,playerStatsWindow)
  560.     guiSetFont(lblPTotalMoneyEarned,"default-bold-small")
  561.  
  562.     lblPMoneySent = guiCreateLabel(247,159,230,14,"Money sent to players: N/A",false,playerStatsWindow)
  563.     guiSetFont(lblPMoneySent,"default-bold-small")
  564.  
  565.     lblPMoneyBetEarned = guiCreateLabel(247,208,230,14,"Money earned with betting: N/A",false,playerStatsWindow)
  566.     guiSetFont(lblPMoneyBetEarned,"default-bold-small")
  567.  
  568.     lblPTotalBets = guiCreateLabel(247,178,138,15,"Total bets: N/A",false,playerStatsWindow)
  569.     guiSetFont(lblPTotalBets,"default-bold-small")
  570.  
  571.     lblPBetsWon = guiCreateLabel(247,193,138,15,"Bets won: N/A",false,playerStatsWindow)
  572.     guiSetFont(lblPBetsWon,"default-bold-small")
  573.  
  574.     lblPTotalDeaths = guiCreateLabel(17,245,138,15,"Total deaths: N/A",false,playerStatsWindow)
  575.     guiSetFont(lblPTotalDeaths,"default-bold-small")
  576.  
  577.     lblPTotalPlayingTime = guiCreateLabel(247,123,230,18,"Total playing time: N/A",false,playerStatsWindow)
  578.     guiSetFont(lblPTotalPlayingTime,"default-bold-small")
  579.  
  580.     lblPTotalReactionTests = guiCreateLabel(247,231,175,14,"Reaction tests won: N/A",false,playerStatsWindow)
  581.     guiSetFont(lblPTotalReactionTests,"default-bold-small")
  582.  
  583.     lblPBestReactionTime = guiCreateLabel(247,245,159,14,"Best reaction time: N/A",false,playerStatsWindow)
  584.     guiSetFont(lblPBestReactionTime,"default-bold-small")
  585.  
  586.     pImageLevel = guiCreateStaticImage(303,61,159,52,"levels/LEVEL1.png",false,playerStatsWindow)
  587.  
  588.     btnClosePlayerStatsWindow = guiCreateButton(428,226,102,38,"Close",false,playerStatsWindow)
  589.  
  590.  
  591.  
  592.     lblGiveMoneyLineCombo = guiCreateLabel(204,235,376,18,"-----------------------------   Send money  -----------------------------",false,tabs[2])
  593.     guiLabelSetVerticalAlign(lblGiveMoneyLineCombo,"top")
  594.     guiLabelSetHorizontalAlign(lblGiveMoneyLineCombo,"center",false)
  595.     guiSetFont(lblGiveMoneyLineCombo,"default-bold-small")
  596.     guiLabelSetColor(lblGiveMoneyLineCombo,1,176,240)
  597.  
  598.     lblGiveMoneyNotice = guiCreateLabel(204,259,372,19,"Please double-check who you're sending the money to!",false,tabs[2])
  599.     guiLabelSetVerticalAlign(lblGiveMoneyNotice ,"center")
  600.     guiLabelSetHorizontalAlign(lblGiveMoneyNotice ,"center",false)
  601.     guiSetFont(lblGiveMoneyNotice,"default-bold-small")
  602.  
  603.     lblAmountToSend = guiCreateLabel(204,288,94,19,"Amount:",false,tabs[2])
  604.     guiLabelSetVerticalAlign(lblAmountToSend,"top")
  605.     guiLabelSetHorizontalAlign(lblAmountToSend,"center",false)
  606.  
  607.     editInputChatText = guiCreateEdit(343,206,181,25,"",false,tabs[2])
  608.     editAmountToSend = guiCreateEdit(204,307,94,24,"",false,tabs[2])
  609.  
  610.     memoPlayerChat = guiCreateMemo(343,41,247,149,"",false,tabs[2])
  611.     guiMemoSetReadOnly(memoPlayerChat,true)
  612.  
  613.     chatStatusImage = guiCreateStaticImage(screenWidth/1.33-chatImageSize/2,screenHeight/5.8-chatImageSize/2,chatImageSize,chatImageSize,"img/empty.png",false)
  614.  
  615.  
  616.     chatRequestNotificationWindow = guiCreateWindow(screenWidth/2-CNWindowWidth/2,screenHeight/2-CNWindowHeight/2,CNWindowWidth,CNWindowHeight,"Chat notification",false)
  617.     guiSetAlpha(chatRequestNotificationWindow,0.95)
  618.     guiSetVisible(chatRequestNotificationWindow,false)
  619.     guiWindowSetSizable(chatRequestNotificationWindow,false)
  620.  
  621.     btnAcceptChatInvite = guiCreateButton(32,79,125,33,"Accept",false,chatRequestNotificationWindow)
  622.     btnDeclineChatInvite = guiCreateButton(184,79,125,33,"Decline",false,chatRequestNotificationWindow)
  623.  
  624.     lblChatRequestInformation = guiCreateLabel(14,38,313,18,"<g.data_player> would like to chat with you!",false,chatRequestNotificationWindow)
  625.     guiLabelSetColor(lblChatRequestInformation,1,176,240)
  626.     guiLabelSetVerticalAlign(lblChatRequestInformation,"center")
  627.     guiLabelSetHorizontalAlign(lblChatRequestInformation,"center",false)
  628.  
  629.  
  630.  
  631.     chatRequestingWindow = guiCreateWindow(screenWidth/2-CNWindowWidth/2,screenHeight/2-CNWindowHeight/2,CNWindowWidth,CNWindowHeight,"Sending a chat request",false)
  632.     guiSetAlpha(chatRequestingWindow,0.95)
  633.     guiSetVisible(chatRequestingWindow,false)
  634.     guiWindowSetSizable(chatRequestingWindow,false)
  635.  
  636.     btnCancelPendingRequest = guiCreateButton(110,79,125,33,"Cancel",false,chatRequestingWindow)
  637.  
  638.     lblRequestChatAccept = guiCreateLabel(14,38,313,18,"Waiting for <g.data_rPlayer> to accept...",false,chatRequestingWindow)
  639.     guiLabelSetColor(lblRequestChatAccept,1,176,240)
  640.     guiLabelSetVerticalAlign(lblRequestChatAccept,"center")
  641.     guiLabelSetHorizontalAlign(lblRequestChatAccept,"center",false)
  642.  
  643.  
  644.     -- "Maps" TAB
  645.  
  646.     gridMaps = guiCreateGridList(17,51,315,285,false,tabs[5])
  647.     guiGridListSetSortingEnabled(gridMaps,false)
  648.     guiGridListAddColumn(gridMaps,"Map name",0.9)
  649.  
  650.     lblMapsInfo = guiCreateLabel(342,210,245,45,"You need to be level 17 or higher to set maps. Each map costs $4000, regardless whether it's DM or DD.",false,tabs[5])
  651.     guiLabelSetVerticalAlign(lblMapsInfo,"center")
  652.     guiLabelSetHorizontalAlign(lblMapsInfo,"center",true)
  653.     guiSetFont(lblMapsInfo,"default-bold-small")
  654.  
  655.  
  656.     lblTotalMapsOnServer = guiCreateLabel(342,28,193,19,"Total maps on the server: N/A",false,tabs[5])
  657.     guiSetFont(lblTotalMapsOnServer,"default-bold-small")
  658.  
  659.     lblTotalDmMaps = guiCreateLabel(342,47,193,19,"Total DM maps: N/A",false,tabs[5])
  660.     guiSetFont(lblTotalDmMaps,"default-bold-small")
  661.  
  662.     lblTotalDdMaps = guiCreateLabel(342,62,193,19,"Total DD maps: N/A",false,tabs[5])
  663.     guiSetFont(lblTotalDdMaps,"default-bold-small")
  664.  
  665.     lblSetNextMapTitle = guiCreateLabel(342,189,245,16,"Set a next map",false,tabs[5])
  666.     guiLabelSetColor(lblSetNextMapTitle,1,176,240)
  667.     guiLabelSetVerticalAlign(lblSetNextMapTitle,"center")
  668.     guiLabelSetHorizontalAlign(lblSetNextMapTitle,"center",false)
  669.     guiSetFont(lblSetNextMapTitle,"default-bold-small")
  670.  
  671.     lblSearchForMaps = guiCreateLabel(25,25,101,14,"Search for maps:",false,tabs[5])
  672.     guiLabelSetColor(lblSearchForMaps,1,176,240)
  673.     guiLabelSetVerticalAlign(lblSearchForMaps,"center")
  674.     guiSetFont(lblSearchForMaps,"default-bold-small")
  675.  
  676.     lblSelectedMapNameTitle = guiCreateLabel(342,97,245,16,"Selected map name:",false,tabs[5])
  677.     guiLabelSetColor(lblSelectedMapNameTitle,150,255,150)
  678.     guiSetFont(lblSelectedMapNameTitle,"default-bold-small")
  679.  
  680.     lblSelectedMapAuthorTitle = guiCreateLabel(342,136,245,16,"Map type:",false,tabs[5])
  681.     guiLabelSetColor(lblSelectedMapAuthorTitle,150,255,150)
  682.     guiSetFont(lblSelectedMapAuthorTitle,"default-bold-small")
  683.  
  684.  
  685.     lblSelectedMapName = guiCreateLabel(342,113,245,16,"N/A",false,tabs[5])
  686.  
  687.     lblSelectedMapAuthor = guiCreateLabel(342,152,245,16,"N/A",false,tabs[5])
  688.  
  689.  
  690.     lblMapTabLine1 = guiCreateLabel(342,309,245,27,"---------------------------------------------------------------",false,tabs[5])
  691.     guiLabelSetColor(lblMapTabLine1,1,176,240)
  692.     guiLabelSetVerticalAlign(lblMapTabLine1,"center")
  693.     guiLabelSetHorizontalAlign(lblMapTabLine1,"center",false)
  694.     guiSetFont(lblMapTabLine1,"default-bold-small")
  695.  
  696.     lblMapTabLine2 = guiCreateLabel(342,173,245,16,"---------------------------------------------------------------",false,tabs[5])
  697.     guiLabelSetColor(lblMapTabLine2,1,176,240)
  698.     guiLabelSetVerticalAlign(lblMapTabLine2,"center")
  699.     guiLabelSetHorizontalAlign(lblMapTabLine2,"center",false)
  700.     guiSetFont(lblMapTabLine2,"default-bold-small")
  701.  
  702.     lblMapTabLine3 = guiCreateLabel(342,81,245,16,"---------------------------------------------------------------",false,tabs[5])
  703.     guiLabelSetColor(lblMapTabLine3,1,176,240)
  704.     guiLabelSetVerticalAlign(lblMapTabLine3,"center")
  705.     guiLabelSetHorizontalAlign(lblMapTabLine3,"center",false)
  706.     guiSetFont(lblMapTabLine3,"default-bold-small")
  707.  
  708.     editMapSearch = guiCreateEdit(129,23,198,21,"",false,tabs[5])
  709.  
  710.     btnBuyNextMap = guiCreateButton(380,265,169,44,"Buy as next map - $4000",false,tabs[5])
  711.  
  712.  
  713.  
  714.     -- "Shop" TAB
  715.  
  716.     -- buttons
  717.     btnOpenSkinsWindow = guiCreateButton(33,295,123,38,"Buy a skin",false,tabs[4])
  718.     btnChangeHeadlightsColor = guiCreateButton(445,295,123,38,"Headlights color",false,tabs[4])
  719.     btnChangeVehicleColor = guiCreateButton(308,295,123,38,"Vehicle color",false,tabs[4])
  720.     btnChangeNametagColor = guiCreateButton(171,295,123,38,"Buy nametag color",false,tabs[4])
  721.  
  722.     -- general elements
  723.     lblPriceSkin = guiCreateLabel(33,266,123,19,"Price: $1300",false,tabs[4])
  724.     guiLabelSetVerticalAlign(lblPriceSkin,"center")
  725.     guiLabelSetHorizontalAlign(lblPriceSkin,"center",false)
  726.     guiSetFont(lblPriceSkin,"default-bold-small")
  727.  
  728.     lblPriceFree1 = guiCreateLabel(445,266,123,19,"Price: $2000",false,tabs[4])
  729.     guiLabelSetVerticalAlign(lblPriceFree1,"center")
  730.     guiLabelSetHorizontalAlign(lblPriceFree1,"center",false)
  731.     guiSetFont(lblPriceFree1,"default-bold-small")
  732.  
  733.     lblPriceFree2 = guiCreateLabel(308,266,123,19,"Price: $2000",false,tabs[4])
  734.     guiLabelSetVerticalAlign(lblPriceFree2,"center")
  735.     guiLabelSetHorizontalAlign(lblPriceFree2,"center",false)
  736.     guiSetFont(lblPriceFree2,"default-bold-small")
  737.  
  738.     lblPriceNametag = guiCreateLabel(171,266,123,19,"Price: FREE",false,tabs[4])
  739.     guiLabelSetVerticalAlign(lblPriceNametag,"center")
  740.     guiLabelSetHorizontalAlign(lblPriceNametag,"center",false)
  741.     guiSetFont(lblPriceNametag,"default-bold-small")
  742.  
  743.  
  744.     lblWaterColor = guiCreateLabel(389,22,146,18,"Water color",false,tabs[4])
  745.     guiLabelSetColor(lblWaterColor,1,176,240)
  746.     guiLabelSetHorizontalAlign(lblWaterColor,"center",false)
  747.     guiSetFont(lblWaterColor,"default-bold-small")
  748.  
  749.     lblNewWaterColor = guiCreateLabel(398,40,135,14,"New color (rrr,ggg,bbb)",false,tabs[4])
  750.     guiSetFont(lblNewWaterColor,"default-bold-small")
  751.  
  752.     lblTime = guiCreateLabel(389,132,146,18,"Time",false,tabs[4])
  753.     guiLabelSetColor(lblTime,1,176,240)
  754.     guiLabelSetHorizontalAlign(lblTime,"center",false)
  755.     guiSetFont(lblTime,"default-bold-small")
  756.  
  757.     lblNewTime = guiCreateLabel(411,150,135,14,"New time (hh:mm)",false,tabs[4])
  758.     guiSetFont(lblNewTime,"default-bold-small")
  759.  
  760.     editWaterColorRed = guiCreateEdit(389,58,42,22,"",false,tabs[4])
  761.     editWaterColorGreen = guiCreateEdit(441,58,42,22,"",false,tabs[4])
  762.     editWaterColorBlue = guiCreateEdit(493,58,42,22,"",false,tabs[4])
  763.     editTimeHours = guiCreateEdit(416,171,42,22,"",false,tabs[4])
  764.     editTimeMinutes = guiCreateEdit(468,171,42,22,"",false,tabs[4])
  765.     guiEditSetMaxLength(editWaterColorRed,3)
  766.     guiEditSetMaxLength(editWaterColorGreen,3)
  767.     guiEditSetMaxLength(editWaterColorBlue,3)
  768.     guiEditSetMaxLength(editTimeHours,2)
  769.     guiEditSetMaxLength(editTimeMinutes,2)
  770.  
  771.     btnChangeWaterColor = guiCreateButton(389,90,146,23,"Change color - $400",false,tabs[4])
  772.     btnChangeTime = guiCreateButton(389,203,146,23,"Change time - $250",false,tabs[4])
  773.  
  774.  
  775.     -- horn interface
  776.     gridHorns = guiCreateGridList(24,56,191,154,false,tabs[4])
  777.     guiGridListAddColumn(gridHorns,"Horn",0.6)
  778.     guiGridListAddColumn(gridHorns,"Price",0.3)
  779.     guiGridListSetSortingEnabled(gridHorns,false)
  780.  
  781.     for _,horn in ipairs(hornName) do
  782.         local row = guiGridListAddRow(gridHorns)
  783.         guiGridListSetItemText(gridHorns,row,1,horn,false,false)
  784.         guiGridListSetItemColor(gridHorns,row,1,180,180,180,255)
  785.     end
  786.  
  787.     for _,price in ipairs(hornPrice) do
  788.         guiGridListSetItemText(gridHorns,_-1,2,price,false,false)
  789.         guiGridListSetItemColor(gridHorns,_-1,2,180,180,180,255)
  790.     end
  791.  
  792.  
  793.     lblCustomHornInfo = guiCreateLabel(24,22,143,16,"Custom horn sounds",false,tabs[4])
  794.     guiLabelSetColor(lblCustomHornInfo,1,176,240)
  795.     guiSetFont(lblCustomHornInfo,"default-bold-small")
  796.  
  797.     btnSetHornSound = guiCreateButton(24,215,191,24,"Use selected horn",false,tabs[4])
  798.  
  799.     btnPreviewHorn = guiCreateButton(225,80,83,26,"Preview horn",false,tabs[4])
  800.  
  801.     btnBuyHorn = guiCreateButton(225,167,83,26,"Buy horn",false,tabs[4])
  802.  
  803.     lblHornPriceNot = guiCreateLabel(225,127,83,15,"Price:",false,tabs[4])
  804.     guiLabelSetHorizontalAlign(lblHornPriceNot,"center",false)
  805.     guiSetFont(lblHornPriceNot,"default-bold-small")
  806.  
  807.     lblHornPrice = guiCreateLabel(225,142,83,15,"N/A",false,tabs[4])
  808.     guiLabelSetVerticalAlign(lblHornPrice,"center")
  809.     guiLabelSetHorizontalAlign(lblHornPrice,"center",false)
  810.     guiSetFont(lblHornPrice,"default-bold-small")
  811.  
  812.     lblCurrentHorn = guiCreateLabel(24,38,175,16,"Current horn: N/A",false,tabs[4])
  813.     guiSetFont(lblCurrentHorn,"default-bold-small")
  814.  
  815.  
  816.     -- color pick window
  817.     colorWindow = guiCreateWindow(screenWidth/2-colorWindowWidth/2,screenHeight/2-colorWindowHeight/2,colorWindowWidth,colorWindowHeight,"Select your color...",false)
  818.     guiSetAlpha(colorWindow,0.95)
  819.     guiSetVisible(colorWindow,false)
  820.  
  821.     labelRed = guiCreateLabel(15,39,102,20,"RED",false,colorWindow)
  822.     guiLabelSetColor(labelRed,255,0,0)
  823.     guiLabelSetVerticalAlign(labelRed,"center")
  824.     guiLabelSetHorizontalAlign(labelRed,"left",false)
  825.     guiSetFont(labelRed,"default-bold-small")
  826.  
  827.     labelGreen = guiCreateLabel(15,78,101,20,"GREEN",false,colorWindow)
  828.     guiLabelSetColor(labelGreen,0,255,0)
  829.     guiLabelSetVerticalAlign(labelGreen,"center")
  830.     guiLabelSetHorizontalAlign(labelGreen,"left",false)
  831.     guiSetFont(labelGreen,"default-bold-small")
  832.  
  833.     labelBlue = guiCreateLabel(15,117,100,20,"BLUE",false,colorWindow)
  834.     guiLabelSetColor(labelBlue,0,30,255)
  835.     guiLabelSetVerticalAlign(labelBlue,"center")
  836.     guiLabelSetHorizontalAlign(labelBlue,"left",false)
  837.     guiSetFont(labelBlue,"default-bold-small")
  838.  
  839.     gridOne = guiCreateGridList(10000,12,0,164,false,colorWindow)
  840.     guiGridListSetSelectionMode(gridOne,2)
  841.  
  842.     gridTwo = guiCreateGridList(10000,12,0,164,false,colorWindow)
  843.     guiGridListSetSelectionMode(gridTwo,2)
  844.  
  845.     redBar = guiCreateScrollBar( 0.2, 0.2, 0.69, 0.1, true, true, colorWindow)
  846.     greenBar = guiCreateScrollBar( 0.2, 0.4, 0.69, 0.1, true, true, colorWindow)
  847.     blueBar = guiCreateScrollBar( 0.2, 0.6, 0.69, 0.1, true, true, colorWindow)
  848.  
  849.     lblColorPreview = guiCreateLabel(15,152,181,31,"Preview     [||||||||||||||]",false,colorWindow)
  850.     guiLabelSetVerticalAlign(lblColorPreview,"center")
  851.     guiLabelSetHorizontalAlign(lblColorPreview,"center",false)
  852.     guiSetFont(lblColorPreview,"default-bold-small")
  853.  
  854.     btnSaveColor = guiCreateButton(214,152,81,31,"Save",false,colorWindow)
  855.  
  856.     btnCancelColorSelection = guiCreateButton(305,152,77,31,"Cancel",false,colorWindow)
  857.  
  858.  
  859.  
  860.     -- skin window
  861.     skinsWindow = guiCreateWindow(screenWidth/2-SkinWindowWidth/2,screenHeight/2-SkinWindowHeight/2,604,429,"Skins",false)
  862.     guiWindowSetSizable(skinsWindow,false)
  863.     guiSetVisible(skinsWindow, false)
  864.  
  865.     lblSkinsText = guiCreateLabel(10,27,583,109,"Here you can change your character's skin. Changing the skin costs $1300. For your convenience, the skins are arranged in several groups. \n\nYou can preview skins by clicking on them. Your character's skin will change into the selected one for a few seconds. \n\nWhen you find a skin you want, select it and click the \"Buy skin\" button. This will save the skin to your account and you will play with it until you decide to change it again.",false,skinsWindow)
  866.     guiLabelSetHorizontalAlign(lblSkinsText,"left",true)
  867.     guiSetFont(lblSkinsText,"default-bold-small")
  868.  
  869.     skin_groupTable = guiCreateGridList(10,157,167,261,false,skinsWindow)
  870.     guiGridListSetSortingEnabled(skin_groupTable, false)
  871.     skin_groupTable_01 = guiGridListAddColumn(skin_groupTable, "Group", 0.8)
  872.     local groupTable_row = nil
  873.  
  874.     lblSkinLine = guiCreateLabel(16,136,570,11,"--------------------------------------------------------------------------------------------------------------------------------",false,skinsWindow)
  875.     guiLabelSetColor(lblSkinLine,1,176,240)
  876.     guiLabelSetHorizontalAlign(lblSkinLine,"center",false)
  877.     guiSetFont(lblSkinLine,"default-bold-small")
  878.  
  879.     skin_skinTable = guiCreateGridList(207,157,224,261,false,skinsWindow)
  880.     guiGridListSetSortingEnabled(skin_skinTable, false)
  881.     skin_skinTable_01 = guiGridListAddColumn(skin_skinTable, "ID", 0.454545)
  882.     skin_skinTable_02 = guiGridListAddColumn(skin_skinTable, "Skin Name", 0.454545)
  883.     local skinTable_row = nil
  884.  
  885.     btnCloseSkinWindow = guiCreateButton(456,382,126,36,"Close",false,skinsWindow)
  886.  
  887.     btnBuySkin = guiCreateButton(456,232,126,36,"Buy skin",false,skinsWindow)
  888.  
  889.     lblBuySelectedSkin = guiCreateLabel(456,209,126,18,"Buy the selected skin",false,skinsWindow)
  890.     guiLabelSetColor(lblBuySelectedSkin,1,176,240)
  891.     guiLabelSetHorizontalAlign(lblBuySelectedSkin,"center",false)
  892.     guiSetFont(lblBuySelectedSkin,"default-bold-small")
  893.  
  894.     lblSkinPrice = guiCreateLabel(456,285,126,18,"Price: $1300",false,skinsWindow)
  895.     guiLabelSetColor(lblSkinPrice,1,176,240)
  896.     guiLabelSetHorizontalAlign(lblSkinPrice,"center",false)
  897.     guiSetFont(lblSkinPrice,"default-bold-small")
  898.  
  899.     aSkins = aLoadSkins()
  900.     local i = guiGridListAddRow(skin_groupTable)
  901.     guiGridListSetItemText( skin_groupTable, i, skin_groupTable_01, 'All skins', false, false )
  902.     for name, group in pairs(aSkins) do
  903.         local i = guiGridListAddRow(skin_groupTable)
  904.         guiGridListSetItemText( skin_groupTable, i, skin_groupTable_01, name, false, false )
  905.     end
  906.     guiGridListSetSelectedItem( skin_groupTable, i, 1 )
  907.     addEventHandler('onClientGUIClick', skin_groupTable, groupSelected , false)
  908.     guiGridListSetColumnWidth(skin_skinTable,skin_skinTable_01, 50, false)
  909.     guiGridListSetColumnWidth(skin_skinTable,skin_skinTable_02, 140, false)
  910.     addEventHandler('onClientGUIClick', skin_skinTable, skinSelected , false)
  911.     fillTableSkins('All skins')
  912.  
  913.  
  914.  
  915.  
  916.     -- First time join window
  917.     welcomeWindow = guiCreateWindow(screenWidth/2-392,screenHeight/2-214,784,482,"Welcome to ASG//",false)
  918.     guiSetAlpha(welcomeWindow,1)
  919.     guiSetVisible(welcomeWindow,false)
  920.     guiWindowSetSizable(welcomeWindow,false)
  921.     guiWindowSetMovable(welcomeWindow,false)
  922.  
  923.     lblWelcomeToXSS = guiCreateLabel(9,58,766,83,"Welcome to ASG//",false,welcomeWindow)
  924.     guiLabelSetColor(lblWelcomeToXSS,1,176,240)
  925.     guiLabelSetHorizontalAlign(lblWelcomeToXSS,"center",false)
  926.     guiSetFont(lblWelcomeToXSS,"sa-gothic")
  927.  
  928.     lblWelcomeText = guiCreateLabel(9,29,763,359,"\n\n\n\n\n\n\n\n\n\n\nHello and welcome to our server!\n\n\nWe hope you will have fun on our server and enjoy your time with us.\nPlease take your time to read through this guide, as it will only be available once.\n\n\n\n\n\nClick the button to continue...",false,welcomeWindow)
  929.     guiLabelSetHorizontalAlign(lblWelcomeText,"center",false)
  930.     guiSetFont(lblWelcomeText,"clear-normal")
  931.  
  932.     btnContinue = guiCreateButton(303,393,179,63,"Continue",false,welcomeWindow)
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.     -------------------------------------------------------------- |END
  940.  
  941.     callServerFunction("refreshStats",getLocalPlayer())
  942.     setTimer(callServerFunction,5000,1,"checkConvertedMoney",getLocalPlayer()) -- Check for converted money after 5 secs
  943.  
  944.     -- Event handlers
  945.     addEventHandler ( "onClientGUIClick", buttonLevelUp, triggerLevelUp, false )
  946.     addEventHandler ( "onClientGUIClick", buttonSaveOptions, performSettingsUpdate, false )
  947.     addEventHandler ( "onClientGUIClick", gridAchievements, updateAchievementDetailsLabel, false )
  948.     addEventHandler ( "onClientGUIClick", buttonEditPersonalDetails, togglePersonalDetailsWindow, false )
  949.     addEventHandler ( "onClientGUIClick", buttonPersonalDetailsSave, closePersonalDetailsWindow, false )
  950.     addEventHandler ( "onClientGUIClick", btnViewPersonalDetails, displayPersonalDetailsCall, false )
  951.     addEventHandler ( "onClientGUIClick", btnViewStats, getPersonalStats, false )
  952.     addEventHandler ( "onClientGUIClick", btnClosePlayerStatsWindow, closeStatsWindow, false )
  953.     addEventHandler ( "onClientGUIClick", btnCancelPendingRequest, cancelChatInvitation, false )
  954.     addEventHandler ( "onClientGUIClick", btnGiveMoney, giveMoney, false )
  955.     addEventHandler ( "onClientGUIClick", btnClearChat, clearClientChat, false )
  956.     addEventHandler ( "onClientGUIClick", btnChatAIO, toggleChatMode, false )
  957.     addEventHandler ( "onClientGUIClick", btnSendInputMessage, playerChatHandler, false )
  958.     addEventHandler ( "onClientGUIClick", btnAcceptChatInvite, acceptChatInvitation, false )
  959.     addEventHandler ( "onClientGUIClick", btnDeclineChatInvite, declineChatInvitation, false )
  960.     addEventHandler ( "onClientGUIClick", gridMaps, updateMapLabels, false )
  961.     addEventHandler ( "onClientGUIClick", btnBuyNextMap, buyNextMap, false )
  962.     addEventHandler ( "onClientGUIChanged", editMapSearch, mapSearch, false )
  963.     addEventHandler ( "onClientGUIClick", btnOpenSkinsWindow, openSkinsWindowCheck, false )
  964.     addEventHandler ( "onClientGUIClick", btnBuySkin, on_buySkinButton_clicked,false )
  965.     addEventHandler ( "onClientGUIClick", btnCloseSkinWindow, closeSkinsWindow, false )
  966.     addEventHandler ( "onClientGUIClick", btnChangeVehicleColor, requestVehColor,false )
  967.     addEventHandler ( "onClientGUIClick", btnChangeHeadlightsColor, requestHeadlights,false )
  968.     addEventHandler ( "onClientGUIClick", btnChangeNametagColor, getNametagLevel,false )
  969.     addEventHandler ( "onClientGUIClick", btnCancelColorSelection, closeColorSelectionWindow,false )
  970.     addEventHandler ( "onClientGUIClick", btnSaveColor, saveData, false )
  971.     addEventHandler ( "onClientGUIClick", btnPreviewHorn, hornPreview, false )
  972.     addEventHandler ( "onClientGUIClick", btnSetHornSound, setHornCheck, false )
  973.     addEventHandler ( "onClientGUIClick", btnBuyHorn, buyHorn, false )
  974.     addEventHandler ( "onClientGUIClick", gridHorns, updateHornPriceLabel, false )
  975.     addEventHandler ( "onClientGUIClick", btnChangeWaterColor, buyChangeWaterColor, false )
  976.     addEventHandler ( "onClientGUIClick", btnChangeTime, buyChangeTime, false )
  977.     addEventHandler ( "onClientGUIClick", btnContinue, welcomeProcedureHandler, false )
  978. end
  979. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onPlayerResourceStart)
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988. ---------- Main userpanel functions -----------
  989.  
  990. -- Show/hide seperate tabs
  991. -- This function gets called from the DX Menu script
  992. function displayTab(openTab)
  993.     if openTab == 1 then -- Stats tab
  994.         guiSetVisible(tabs[2],false)
  995.         guiSetVisible(tabs[3],false)
  996.         guiSetVisible(tabs[4],false)
  997.         guiSetVisible(tabs[5],false)
  998.         guiSetVisible(tabs[6],false)
  999.         guiSetVisible(statsWindow,false)
  1000.         guiSetVisible(personalDetailsWindow,false)
  1001.         guiSetVisible(colorWindow,false)
  1002.         guiSetVisible(skinsWindow,false)
  1003.         guiSetVisible(chatRequestingWindow,false)
  1004.         guiSetVisible(chatRequestNotificationWindow,false)
  1005.  
  1006.         local visible = guiGetVisible(tabs[1])
  1007.         if visible == false then
  1008.             guiSetVisible(tabs[1],true)
  1009.         else
  1010.             guiSetVisible(tabs[1],false)
  1011.         end
  1012.     elseif openTab == 2 then -- Players tab
  1013.         guiSetVisible(tabs[1],false)
  1014.         guiSetVisible(tabs[3],false)
  1015.         guiSetVisible(tabs[4],false)
  1016.         guiSetVisible(tabs[5],false)
  1017.         guiSetVisible(tabs[6],false)
  1018.         guiSetVisible(statsWindow,false)
  1019.         guiSetVisible(personalDetailsWindow,false)
  1020.         guiSetVisible(colorWindow,false)
  1021.         guiSetVisible(skinsWindow,false)
  1022.         guiSetVisible(chatRequestingWindow,false)
  1023.         guiSetVisible(chatRequestNotificationWindow,false)
  1024.  
  1025.         local visible = guiGetVisible(tabs[2])
  1026.         if visible == false then
  1027.             guiSetVisible(tabs[2],true)
  1028.             if newMessageArrived == true then
  1029.                 newMessageArrived = false
  1030.                 guiStaticImageLoadImage(chatStatusImage,"img/empty.png")
  1031.             end
  1032.             if chatRequestMode == true then
  1033.                 guiSetVisible(chatRequestingWindow,true)
  1034.                 guiBringToFront(chatRequestingWindow)
  1035.             end
  1036.             if chatNotificationMode == true then
  1037.                 guiSetVisible(chatRequestNotificationWindow, true)
  1038.                 guiBringToFront(chatRequestNotificationWindow)
  1039.             end
  1040.         else
  1041.             guiSetVisible(tabs[2],false)
  1042.             guiSetVisible(personalDetailsWindow, false)
  1043.             guiSetVisible(chatRequestingWindow, false)
  1044.             guiSetVisible(chatRequestNotificationWindow, false)
  1045.             if newMessageArrived == false or chatRequestMode == false or chatNotificationMode == false then
  1046.                 guiStaticImageLoadImage(chatStatusImage,"img/empty.png")
  1047.             end
  1048.         end
  1049.     elseif openTab == 3 then -- Achievements tab
  1050.         guiSetVisible(tabs[1],false)
  1051.         guiSetVisible(tabs[2],false)
  1052.         guiSetVisible(tabs[4],false)
  1053.         guiSetVisible(tabs[5],false)
  1054.         guiSetVisible(tabs[6],false)
  1055.         guiSetVisible(statsWindow,false)
  1056.         guiSetVisible(personalDetailsWindow,false)
  1057.         guiSetVisible(colorWindow,false)
  1058.         guiSetVisible(skinsWindow,false)
  1059.         guiSetVisible(chatRequestingWindow,false)
  1060.         guiSetVisible(chatRequestNotificationWindow,false)
  1061.  
  1062.         local visible = guiGetVisible(tabs[3])
  1063.         if visible == false then
  1064.             guiSetVisible(tabs[3],true)
  1065.         else
  1066.             guiSetVisible(tabs[3],false)
  1067.         end
  1068.     elseif openTab == 4 then -- Shop tab
  1069.         guiSetVisible(tabs[1],false)
  1070.         guiSetVisible(tabs[2],false)
  1071.         guiSetVisible(tabs[3],false)
  1072.         guiSetVisible(tabs[5],false)
  1073.         guiSetVisible(tabs[6],false)
  1074.         guiSetVisible(statsWindow,false)
  1075.         guiSetVisible(personalDetailsWindow,false)
  1076.         guiSetVisible(colorWindow,false)
  1077.         guiSetVisible(skinsWindow,false)
  1078.         guiSetVisible(chatRequestingWindow,false)
  1079.         guiSetVisible(chatRequestNotificationWindow,false)
  1080.  
  1081.         local visible = guiGetVisible(tabs[4])
  1082.         if visible == false then
  1083.             guiSetVisible(tabs[4],true)
  1084.         else
  1085.             guiSetVisible(tabs[4],false)
  1086.         end
  1087.     elseif openTab == 5 then -- Maps tab
  1088.         guiSetVisible(tabs[1],false)
  1089.         guiSetVisible(tabs[2],false)
  1090.         guiSetVisible(tabs[3],false)
  1091.         guiSetVisible(tabs[4],false)
  1092.         guiSetVisible(tabs[6],false)
  1093.         guiSetVisible(statsWindow,false)
  1094.         guiSetVisible(personalDetailsWindow,false)
  1095.         guiSetVisible(colorWindow,false)
  1096.         guiSetVisible(skinsWindow,false)
  1097.         guiSetVisible(chatRequestingWindow,false)
  1098.         guiSetVisible(chatRequestNotificationWindow,false)
  1099.  
  1100.         local visible = guiGetVisible(tabs[5])
  1101.         if visible == false then
  1102.             guiSetVisible(tabs[5],true)
  1103.         else
  1104.             guiSetVisible(tabs[5],false)
  1105.         end
  1106.     elseif openTab == 6 then -- Options tab
  1107.         guiSetVisible(tabs[1],false)
  1108.         guiSetVisible(tabs[2],false)
  1109.         guiSetVisible(tabs[3],false)
  1110.         guiSetVisible(tabs[4],false)
  1111.         guiSetVisible(tabs[5],false)
  1112.         guiSetVisible(statsWindow,false)
  1113.         guiSetVisible(personalDetailsWindow,false)
  1114.         guiSetVisible(colorWindow,false)
  1115.         guiSetVisible(skinsWindow,false)
  1116.         guiSetVisible(chatRequestingWindow,false)
  1117.         guiSetVisible(chatRequestNotificationWindow,false)
  1118.  
  1119.         local visible = guiGetVisible(tabs[6])
  1120.         if visible == false then
  1121.             guiSetVisible(tabs[6],true)
  1122.         else
  1123.             guiSetVisible(tabs[6],false)
  1124.         end
  1125.     elseif openTab == 0 then -- Close all tabs
  1126.         guiSetVisible(tabs[1],false)
  1127.         guiSetVisible(tabs[2],false)
  1128.         guiSetVisible(tabs[3],false)
  1129.         guiSetVisible(tabs[4],false)
  1130.         guiSetVisible(tabs[5],false)
  1131.         guiSetVisible(tabs[6],false)
  1132.         guiSetVisible(statsWindow,false)
  1133.         guiSetVisible(personalDetailsWindow,false)
  1134.         guiSetVisible(colorWindow,false)
  1135.         guiSetVisible(skinsWindow,false)
  1136.         guiSetVisible(chatRequestingWindow,false)
  1137.         guiSetVisible(chatRequestNotificationWindow,false)
  1138.     end
  1139. end
  1140.  
  1141.  
  1142.  
  1143.  
  1144. -- Welcome window for new players
  1145. function displayWelcomeWindow()
  1146.     if guiGetVisible(welcomeWindow) == false then
  1147.         guiSetVisible(welcomeWindow,true)
  1148.         guiBringToFront(welcomeWindow)
  1149.         showCursor(true)
  1150.         fadeCamera(false,0,0,0,0)
  1151.     elseif guiGetVisible(welcomeWindow) == true then
  1152.         guiSetVisible(welcomeWindow,false)
  1153.         showCursor(false)
  1154.         fadeCamera(true,10)
  1155.     end
  1156. end
  1157.  
  1158.  
  1159. function welcomeProcedureHandler(sStage)
  1160.     if (sStage) and (sStage == "openWindow") then
  1161.         displayWelcomeWindow()
  1162.         stage = 1
  1163.         return
  1164.     end
  1165.  
  1166.     if isTimer(rulesTimer) then
  1167.         outputChatBox("#FF6600* #FFFFFFPlease take some time to read through the server rules.",255,255,255,true)
  1168.         return
  1169.     end
  1170.  
  1171.     if stage == 5 then
  1172.         displayWelcomeWindow()
  1173.         callServerFunction("achievement1",getLocalPlayer())
  1174.         return
  1175.     end
  1176.     welcomeProcedure()
  1177. end
  1178.  
  1179.  
  1180. function welcomeProcedure()
  1181.     if (stage == 1) then   -- First continue click
  1182.         stage = 2
  1183.         rulesTimer = setTimer(function () end, 20000,1)
  1184.         guiSetText(lblWelcomeToXSS," ")
  1185.         guiSetText(lblWelcomeText,"\n---------------------------------------------- Server Rules ----------------------------------------------\n\n\n~ No cheating! Cheaters will be banned forever! ~\n\n~ No vehicle mods! However, skin mods are allowed ~\n\n~ No spamming, swearing and insulting other players ~\n\n~ No camping. Please disconnect if you're AFK ~\n\n~ No bug abusing! Abusers will be severely punished ~\n\n~ No advertising for other clans or websites ~\n\n~ Please report all script-related issues to Jems, or just post it on our website ~\n\n\n\n\n\nWhen you're familiar with the rules, click the 'Continue' button...")
  1186.     elseif (stage == 2) then    -- Second continue click
  1187.         stage = 3
  1188.         guiSetText(lblWelcomeText,"\nPress 'F7' to open the userpanel!\n\n\nThe userpanel allows you to view your stats, start private chats with players and buy various items from the shop.\n\nSome functions may be require a certain level to use, so make sure to advance to the next level every once in a while.\n\n\nThe userpanel also allows you to browse your achievements!\nThere are currently 40 achievements available for you to unlock.\n\nYou cannot actually see what the achievement is until you unlock it.\nGood luck discovering them all!\n\n\n\nYour stats like money and level are stored by your serial in a mySQL database.\nThere is no need to login when you join.\n\n\n\n\nClick on the button when you're ready to continue...")
  1189.     elseif (stage == 3) then    -- Third continue click
  1190.         stage = 4
  1191.         guiSetText(lblWelcomeText,"\n\n\n\n\n\n\n\n\n\nIf you would like to join the ASG// clan, visit our website at:\nwww.asg-racing.co.cc\n\nPlease do not ask us if you can join ingame.")
  1192.     elseif (stage == 4) then    -- Last continue click
  1193.         stage = 5
  1194.         guiSetText(lblWelcomeText,"\n\n\n\n\n\n\n\n\n\nThis concludes the server guide.\n\n\n\nRemember to follow the rules, and you'll have a great time!\n\nIf you have any questions, stop by our website and post it there.\nYou can also send us a Private Message, and we'll try to help you the best we can.\n\n\n\nRegards,\nThe ASG// Clan")
  1195.         guiSetText(lblWelcomeToXSS,"Welcome to our server")
  1196.         guiSetText(btnContinue,"Start playing!")
  1197.     end
  1198. end
  1199.  
  1200. function checkForFirstTimeJoined()
  1201.     callServerFunction("checkForFirstTimeJoined",getLocalPlayer())
  1202. end
  1203. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),checkForFirstTimeJoined)
  1204.  
  1205.  
  1206.  
  1207.  
  1208.  
  1209. -- Level up button
  1210. function triggerLevelUp()
  1211.     callServerFunction("newLevelSystem",getLocalPlayer())
  1212. end
  1213.  
  1214.  
  1215.  
  1216. -- Options
  1217. function performSettingsUpdate()
  1218.     if recentlySavedSettings == false then
  1219.         allowPersonalDetails = tostring(guiCheckBoxGetSelected(checkboxAllowPersonalDetails))
  1220.         allowStats = tostring(guiCheckBoxGetSelected(checkboxAllowStats))
  1221.         useCustomHorn = tostring(guiCheckBoxGetSelected(checkboxCustomNametag))
  1222.         useCustomSkin = tostring(guiCheckBoxGetSelected(checkboxPlayWithCustomSkin))
  1223.         useCustomVehicleColor = tostring(guiCheckBoxGetSelected(checkboxPlayWithCustomVehicleColor))
  1224.         soundMessage = tostring(guiCheckBoxGetSelected(checkboxSoundMessage)) -- client
  1225.         soundRequest = tostring(guiCheckBoxGetSelected(checkboxSoundRequest)) -- client
  1226.         showOnDeath = tostring(guiCheckBoxGetSelected(checkboxShowOnDeath)) -- client
  1227.         useHunterSkin = tostring(guiCheckBoxGetSelected(checkboxHunterSkin)) -- client
  1228.         if guiRadioButtonGetSelected(radioChatManual) == true then
  1229.             callServerFunction("saveClientSettings",getLocalPlayer(),allowPersonalDetails,allowStats,useCustomHorn,useCustomSkin,useCustomVehicleColor,soundMessage,soundRequest,showOnDeath,useHunterSkin,"1")
  1230.             acceptMode = 1
  1231.         elseif guiRadioButtonGetSelected(radioChatAccept) == true then
  1232.             callServerFunction("saveClientSettings",getLocalPlayer(),allowPersonalDetails,allowStats,useCustomHorn,useCustomSkin,useCustomVehicleColor,soundMessage,soundRequest,showOnDeath,useHunterSkin,"2")
  1233.             acceptMode = 2
  1234.         elseif guiRadioButtonGetSelected(radioChatDecline) == true then
  1235.             callServerFunction("saveClientSettings",getLocalPlayer(),allowPersonalDetails,allowStats,useCustomHorn,useCustomSkin,useCustomVehicleColor,soundMessage,soundRequest,showOnDeath,useHunterSkin,"3")
  1236.             acceptMode = 3
  1237.         end
  1238.         if useHunterSkin == "true" then
  1239.             useHunterSkin = true
  1240.             hunterReplace()
  1241.         end
  1242.         recentlySavedSettings = true
  1243.         setTimer(function()
  1244.             recentlySavedSettings = false
  1245.         end,5000,1)
  1246.     else
  1247.         outputChatBox("#FF0000* #FFFFFFYou have to wait 5 seconds before you can save your settings again!",255,255,255,true)
  1248.     end
  1249. end
  1250.  
  1251.  
  1252. function configureOptions(mode,a,b,c,d,e,f,g,h,i,j)
  1253.     if (mode) then
  1254.         if (mode == true) then
  1255.             -- Select the correct options
  1256.             if a == "true" then
  1257.                 guiCheckBoxSetSelected(checkboxAllowPersonalDetails,true)
  1258.             elseif a == "false" then
  1259.                 guiCheckBoxSetSelected(checkboxAllowPersonalDetails,false)
  1260.             end
  1261.  
  1262.             if b == "true" then
  1263.                 guiCheckBoxSetSelected(checkboxAllowStats,true)
  1264.             elseif b == "false" then
  1265.                 guiCheckBoxSetSelected(checkboxAllowStats,false)
  1266.             end
  1267.  
  1268.             if c == "true" then
  1269.                 guiCheckBoxSetSelected(checkboxCustomNametag,true)
  1270.             elseif c == "false" then
  1271.                 guiCheckBoxSetSelected(checkboxCustomNametag,false)
  1272.             end
  1273.  
  1274.             if d == "true" then
  1275.                 guiCheckBoxSetSelected(checkboxPlayWithCustomSkin,true)
  1276.             elseif d == "false" then
  1277.                 guiCheckBoxSetSelected(checkboxPlayWithCustomSkin,false)
  1278.             end
  1279.  
  1280.             if e == "true" then
  1281.                 guiCheckBoxSetSelected(checkboxPlayWithCustomVehicleColor,true)
  1282.             elseif e == "false" then
  1283.                 guiCheckBoxSetSelected(checkboxPlayWithCustomVehicleColor,false)
  1284.             end
  1285.  
  1286.             if f == "true" then
  1287.                 guiCheckBoxSetSelected(checkboxSoundMessage,true)
  1288.                 soundMessage = true
  1289.             elseif f == "false" then
  1290.                 guiCheckBoxSetSelected(checkboxSoundMessage,false)
  1291.                 soundMessage = false
  1292.             end
  1293.  
  1294.             if g == "true" then
  1295.                 guiCheckBoxSetSelected(checkboxSoundRequest,true)
  1296.                 soundRequest = true
  1297.             elseif g == "false" then
  1298.                 guiCheckBoxSetSelected(checkboxSoundRequest,false)
  1299.                 soundRequest = false
  1300.             end
  1301.  
  1302.             if h == "true" then
  1303.                 guiCheckBoxSetSelected(checkboxShowOnDeath,true)
  1304.                 showOnDeath = true
  1305.             elseif h == "false" then
  1306.                 guiCheckBoxSetSelected(checkboxShowOnDeath,false)
  1307.                 showOnDeath = false
  1308.             end
  1309.  
  1310.             if i == "true" then
  1311.                 guiCheckBoxSetSelected(checkboxHunterSkin,true)
  1312.                 useHunterSkin = true
  1313.                 hunterReplace()
  1314.             elseif i == "false" then
  1315.                 guiCheckBoxSetSelected(checkboxHunterSkin,false)
  1316.                 useHunterSkin = false
  1317.             end
  1318.  
  1319.             if j == 1 then
  1320.                 guiRadioButtonSetSelected(radioChatManual,true)
  1321.                 acceptMode = 1
  1322.             elseif j == 2 then
  1323.                 guiRadioButtonSetSelected(radioChatAccept,true)
  1324.                 acceptMode = 2
  1325.             elseif j == 3 then
  1326.                 guiRadioButtonSetSelected(radioChatDecline,true)
  1327.                 acceptMode = 3
  1328.             end
  1329.  
  1330.         else
  1331.             callServerFunction("getClientSettings",getLocalPlayer())
  1332.         end
  1333.     end
  1334. end
  1335. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),configureOptions)
  1336.  
  1337.  
  1338.  
  1339.  
  1340.  
  1341. -- Chat
  1342. function clearClientChat()
  1343.     if playerIsChatting == true then
  1344.         guiSetText(memoPlayerChat,"")
  1345.         outputChatBox("#FF6600* #FFFFFFChat cleared!",255,255,255,true)
  1346.     else
  1347.         outputChatBox("#FF6600* #FFFFFFERROR! You are not in a chat!",255,255,255,true)
  1348.     end
  1349. end
  1350.  
  1351.  
  1352. function playerChatHandler()
  1353.     local messageToSend = guiGetText(editInputChatText)
  1354.     if playerIsChatting == true then
  1355.         if not (messageToSend == "") then
  1356.             callServerFunction("playerChatHandler",getLocalPlayer(),getElementData(getLocalPlayer(),"chattingWith"),messageToSend)
  1357.         else
  1358.             outputChatBox("#FF6600* #FFFFFFERROR! Please write a message to send!",255,255,255,true)
  1359.             return false
  1360.         end
  1361.     else
  1362.         outputChatBox("#FF6600* #FFFFFFERROR! You are not chatting with anybody! Please start a chat first!",255,255,255,true)
  1363.     end
  1364. end
  1365.  
  1366. function addPlayerChatText(sendingPlayer,message)
  1367.     guiSetText(memoPlayerChat,guiGetText(memoPlayerChat).."* "..sendingPlayer..": "..message)
  1368.     guiSetProperty(memoPlayerChat,"CaratIndex",tostring(string.len(guiGetText(memoPlayerChat))))
  1369.     if guiGetVisible(tabs[2]) == false then
  1370.         guiStaticImageLoadImage(chatStatusImage,"img/newmessage.png")
  1371.         if soundMessage == true then
  1372.             newMessage = playSound("sounds/newmsg.wav")
  1373.         end
  1374.         newMessageArrived = true
  1375.     end
  1376. end
  1377.  
  1378.  
  1379. function resetInputField()
  1380.     guiSetText(editInputChatText,"")
  1381. end
  1382.  
  1383. function toggleChatMode()
  1384.     if (guiGetText(btnChatAIO) == "Chat with player") then
  1385.         local row,column = guiGridListGetSelectedItem(gridOnlinePlayers)
  1386.         local playerName = guiGridListGetItemText(gridOnlinePlayers,row,1)
  1387.         if not (playerName == "") then
  1388.             if not (getLocalPlayer() == findPlayerByName(playerName)) then
  1389.                 if not (chatRequestMode == true) and not (chatNotificationMode == true) then
  1390.                     callServerFunction("chatModeHandler",getLocalPlayer(),findPlayerByName(playerName))
  1391.                 else
  1392.                     outputChatBox("#FF6600* #FFFFFFERROR! You cannot perform this action at the moment!",255,255,255,true)
  1393.                 end
  1394.             else
  1395.                 outputChatBox("#FF6600* #FFFFFFERROR! You cannot chat with yourself!",255,255,255,true)
  1396.                 return false
  1397.             end
  1398.         else
  1399.             outputChatBox("#FF6600* #FFFFFFERROR! Please select a player!",255,255,255,true)
  1400.             return false
  1401.         end
  1402.     elseif (guiGetText(btnChatAIO) == "Stop chatting") then
  1403.         callServerFunction("chatModeHandler",getLocalPlayer(),getElementData(getLocalPlayer(),"chattingWith"))
  1404.     end
  1405. end
  1406.  
  1407.  
  1408. function setChatMode(mode,playerName)
  1409.     if (mode == 1) then
  1410.         playerIsChatting = true
  1411.         setElementData(getLocalPlayer(),"chattingWith",playerName)
  1412.         guiSetText(btnChatAIO,"Stop chatting")
  1413.         guiSetText(lblChattingWith,string.gsub(getPlayerName(playerName),"#%x%x%x%x%x%x", ""))
  1414.         guiLabelSetColor(lblChattingWith,0,255,0)
  1415.         outputChatBox("#FF6600* #FFFFFFChat started with "..getPlayerName(playerName).."#FFFFFF!",255,255,255,true)
  1416.         callServerFunction("achievement29",playerName)
  1417.     elseif (mode == 0) then
  1418.         playerIsChatting = false
  1419.         setElementData(getLocalPlayer(),"chattingWith","none")
  1420.         guiSetText(btnChatAIO,"Chat with player")
  1421.         guiSetText(lblChattingWith,"Nobody")
  1422.         guiLabelSetColor(lblChattingWith,255,0,0)
  1423.         outputChatBox("#FF6600* #FFFFFFThe chat with player "..getPlayerName(playerName).."#FFFFFF has ended!",255,255,255,true)
  1424.     end
  1425. end
  1426.  
  1427.  
  1428. function acceptChatInvitation()
  1429.     if chatNotificationMode == true then
  1430.         callServerFunction("acceptChatInvite",chatRequestedBy,getLocalPlayer())
  1431.     end
  1432. end
  1433.  
  1434. function declineChatInvitation()
  1435.     if chatNotificationMode == true then
  1436.         callServerFunction("declineChatInvite",chatRequestedBy,getLocalPlayer())
  1437.     end
  1438. end
  1439.  
  1440. function cancelChatInvitation()
  1441.     if chatRequestMode == true then
  1442.         callServerFunction("cancelChatInvite",chatRequestedBy,getLocalPlayer())
  1443.     end
  1444. end
  1445.  
  1446. function setNotInChat()
  1447.     setElementData(getLocalPlayer(),"isPlayerInChat",false)
  1448. end
  1449. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),setNotInChat)
  1450.  
  1451.  
  1452. function setBusyStatus(kCtrlState)
  1453.     if kCtrlState == 1 then playerIsBusy = true end
  1454.     if kCtrlState == 2 then playerIsBusy = false end
  1455. end
  1456.  
  1457.  
  1458. function showChatWindows(windowMode,requestingPlayer,targetPlayer)
  1459.     if windowMode == 1 then
  1460.         if playerIsBusy == false then
  1461.             if chatNotificationMode == false then
  1462.                 chatNotificationMode = true
  1463.                 chatRequestedBy = requestingPlayer
  1464.                 if acceptMode == 1 then
  1465.                     guiSetText(lblChatRequestInformation,string.gsub(getPlayerName(requestingPlayer),"#%x%x%x%x%x%x", "").." would like to chat with you!")
  1466.                     if guiGetVisible(tabs[2]) == true then
  1467.                         guiSetVisible(chatRequestNotificationWindow,true)
  1468.                         guiBringToFront(chatRequestNotificationWindow)
  1469.                     else
  1470.                         guiStaticImageLoadImage(chatStatusImage,"img/newchatrequest.png")
  1471.                         if soundRequest == true then
  1472.                             newRequest = playSound("sounds/newrequest.wav")
  1473.                             setSoundVolume(newRequest,1.3)
  1474.                         end
  1475.                     end
  1476.                     setTimer(function()
  1477.                         playerIsBusy = true
  1478.                     end,200,1)
  1479.                 elseif acceptMode == 2 then
  1480.                     callServerFunction("acceptChatInvite",chatRequestedBy,getLocalPlayer())
  1481.                 elseif acceptMode == 3 then
  1482.                     callServerFunction("declineChatInvite",chatRequestedBy,getLocalPlayer())
  1483.                 end
  1484.             else
  1485.                 guiSetVisible(chatRequestNotificationWindow,false)
  1486.                 guiStaticImageLoadImage(chatStatusImage,"img/empty.png")
  1487.                 chatNotificationMode = false
  1488.                 chatRequestedBy = "none"
  1489.                 playerIsBusy = false
  1490.             end
  1491.         else
  1492.         end
  1493.     elseif windowMode == 2 then
  1494.         if playerIsBusy == false then
  1495.             if chatRequestMode == false then
  1496.                 guiSetText(lblRequestChatAccept,"Waiting for "..string.gsub(getPlayerName(targetPlayer),"#%x%x%x%x%x%x", "").." to accept...")
  1497.                 guiSetVisible(chatRequestingWindow,true)
  1498.                 guiBringToFront(chatRequestingWindow)
  1499.                 chatRequestMode = true
  1500.                 chatRequestedBy = targetPlayer
  1501.                 setTimer(function()
  1502.                     playerIsBusy = true
  1503.                 end,200,1)
  1504.             else
  1505.                 guiSetVisible(chatRequestingWindow,false)
  1506.                 guiStaticImageLoadImage(chatStatusImage,"img/empty.png")
  1507.                 chatRequestMode = false
  1508.                 chatRequestedBy = "none"
  1509.                 playerIsBusy = false
  1510.             end
  1511.         else
  1512.             callServerFunction("chatErrorResponse",1,requestingPlayer,getLocalPlayer())
  1513.         end
  1514.     end
  1515. end
  1516.  
  1517. function quitChatHandler(leavingPlayer,reason)
  1518.     if chatRequestMode == true and chatRequestedBy == leavingPlayer then
  1519.         setElementData(getLocalPlayer(),"isPlayerInChat",false)
  1520.         setElementData(getLocalPlayer(),"chattingWith","none")
  1521.         showChatWindows(2,getLocalPlayer(),leavingPlayer)
  1522.         outputChatBox("#FF6600* #FFFFFFChat request cancelled! "..getPlayerName(leavingPlayer).."#FFFFFF has left the game. #FF6600[#FFFFFF"..reason.."#FF6600]",255,255,255,true)
  1523.     end
  1524.     if (leavingPlayer == getElementData(getLocalPlayer(),"chattingWith")) then
  1525.         setElementData(getLocalPlayer(),"isPlayerInChat",false)
  1526.         setElementData(getLocalPlayer(),"chattingWith","none")
  1527.         guiSetVisible(chatRequestingWindow,false)
  1528.         guiSetVisible(chatRequestNotificationWindow,false)
  1529.         chatRequestMode = false
  1530.         chatNotificationMode = false
  1531.         playerIsBusy = false
  1532.         chatRequestedBy = "none"
  1533.         guiSetText(lblChattingWith,"Nobody")
  1534.         guiLabelSetColor(lblChattingWith,255,0,0)
  1535.         guiSetText(btnChatAIO,"Chat with player")
  1536.         outputChatBox("#FF6600* #FFFFFFThe chat with player "..getPlayerName(leavingPlayer).."#FFFFFF has ended! #FF6600[#FFFFFF"..reason.."#FF6600]",255,255,255,true)
  1537.         guiStaticImageLoadImage(chatStatusImage,"img/empty.png")
  1538.     end
  1539. end
  1540.  
  1541.  
  1542.  
  1543.  
  1544.  
  1545.  
  1546. -- Get all maps on server
  1547. function getMaps()
  1548.     totalServerMaps = 0
  1549.     totalDmMaps = 0
  1550.     totalDdMaps = 0
  1551.     setTimer(callServerFunction,500,1,"getServerMaps",getLocalPlayer())
  1552. end
  1553. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getMaps)
  1554.  
  1555.  
  1556.  
  1557. function loadMaps(gamemodeMapTable, gamemode, map)
  1558.     guiGridListClear(gridMaps)
  1559.     if gamemodeMapTable then
  1560.         aGamemodeMapTable = gamemodeMapTable
  1561.         for id,gamemode in pairs (gamemodeMapTable) do
  1562.             if (gamemode.name == "Race") then
  1563.                 for id,map in ipairs (gamemode.maps) do
  1564.                     local row = guiGridListAddRow ( gridMaps )
  1565.                     guiGridListSetItemText ( gridMaps, row, 1, map.name, false, false )
  1566.                     guiGridListSetItemData ( gridMaps, row, 1, map.resname)
  1567.                     totalServerMaps = totalServerMaps+1
  1568.                     if (string.find(map.name,"[DM]",1,true)) then
  1569.                         totalDmMaps = totalDmMaps+1
  1570.                     elseif (string.find(map.name,"[DD]",1,true)) then
  1571.                         totalDdMaps = totalDdMaps+1
  1572.                     end
  1573.                     updateMapLabels(1)
  1574.                 end
  1575.             end
  1576.         end
  1577.     end
  1578. end
  1579.  
  1580.  
  1581. -- Map search
  1582. function mapSearch()
  1583.     guiGridListClear(gridMaps)
  1584.     local searchString = string.lower(guiGetText(editMapSearch))
  1585.     if ( searchString == "" ) then
  1586.         for id,gamemode in pairs (aGamemodeMapTable) do
  1587.             if (gamemode.name == "Race") then
  1588.                 for id,map in ipairs (gamemode.maps) do
  1589.                     local row = guiGridListAddRow ( gridMaps )
  1590.                     guiGridListSetItemText ( gridMaps, row, 1, map.name, false, false )
  1591.                     guiGridListSetItemData ( gridMaps, row, 1, map.resname)
  1592.                 end
  1593.             end
  1594.         end
  1595.     else
  1596.         for id,gamemode in pairs (aGamemodeMapTable) do
  1597.             if (gamemode.name == "Race") then
  1598.                 local noMapsFound = true
  1599.                 for id,map in ipairs (gamemode.maps) do
  1600.                     if string.find(string.lower(map.name.." "..map.resname), searchString, 1, true) then
  1601.                         local row = guiGridListAddRow ( gridMaps )
  1602.                         guiGridListSetItemText ( gridMaps, row, 1, map.name, false, false )
  1603.                         guiGridListSetItemData ( gridMaps, row, 1, map.resname)
  1604.                         noMapsFound = false
  1605.                     end
  1606.                 end
  1607.                 if noMapsFound == true then
  1608.                     local row = guiGridListAddRow(gridMaps)
  1609.                     guiGridListSetItemText (gridMaps, row, 1, "No maps matching your search query!", false, false)
  1610.                     guiGridListSetItemColor (gridMaps, row, 1, 255,50,50)
  1611.                 end
  1612.             end
  1613.         end
  1614.     end
  1615.     updateMapLabels(2)
  1616. end
  1617.  
  1618. function buyNextMap()
  1619.     local row,column = guiGridListGetSelectedItem(gridMaps)
  1620.     local mapName = guiGridListGetItemText(gridMaps,row,1)
  1621.     triggerServerEvent("buyMapFromPanel", getLocalPlayer(), mapName)
  1622. end
  1623.  
  1624.  
  1625. -- Update labels
  1626. function updateMapLabels(updateMode)
  1627.     if updateMode == 1 then
  1628.         guiSetText(lblTotalMapsOnServer,"Total maps on the server: "..totalServerMaps)
  1629.         guiSetText(lblTotalDmMaps,"Total DM Maps:  "..totalDmMaps)
  1630.         guiSetText(lblTotalDdMaps,"Total DD Maps:  "..totalDdMaps)
  1631.     else
  1632.         local row,column = guiGridListGetSelectedItem(gridMaps)
  1633.         local mapName = guiGridListGetItemText(gridMaps,row,1)
  1634.         if mapName == "" then
  1635.             guiSetText(lblSelectedMapName,"N/A")
  1636.             guiSetText(lblSelectedMapAuthor,"N/A")
  1637.         else
  1638.             guiSetText(lblSelectedMapName,mapName)
  1639.             if string.find(mapName,"[DM]",1,true) then
  1640.                 guiSetText(lblSelectedMapAuthor,"Deathmatch")
  1641.             elseif string.find(mapName,"[DD]",1,true) then
  1642.                 guiSetText(lblSelectedMapAuthor,"Destruction Derby")
  1643.             elseif string.find(mapName,"[FUN]",1,true) then
  1644.                 guiSetText(lblSelectedMapAuthor,"Fun map")
  1645.             else
  1646.                 guiSetText(lblSelectedMapAuthor,"UNKNOWN")
  1647.             end
  1648.         end
  1649.     end
  1650. end
  1651.  
  1652.  
  1653.  
  1654.  
  1655. -- Skins
  1656. function openSkinsWindowCheck()
  1657.     callServerFunction("checkSkinLevel",getLocalPlayer())
  1658. end
  1659.  
  1660. function openSkinsWindow()
  1661.     guiSetVisible(skinsWindow,true)
  1662.     guiSetVisible(tabs[4],false)
  1663.     guiBringToFront(skinsWindow)
  1664. end
  1665.  
  1666. function closeSkinsWindow()
  1667.     guiSetVisible(skinsWindow,false)
  1668.     guiSetVisible(tabs[4],true)
  1669. end
  1670.  
  1671.  
  1672. function on_buySkinButton_clicked(button, state, absoluteX, absoluteY)
  1673.     if (button ~= "left") or (state ~= "up") then
  1674.         return
  1675.     end
  1676.     if (currentSkin) then
  1677.         if type(currentSkin) =='number' then
  1678.             callServerFunction("saveSkin",getLocalPlayer(),tostring(currentSkin))
  1679.         end
  1680.     else
  1681.         outputChatBox("#FF6600* #FFFFFFERROR! Please select a skin!",255,255,255,true)
  1682.     end
  1683. end
  1684.  
  1685. function skinSelected(button, state, absoluteX, absoluteY)
  1686.     if (button ~= "left") or (state ~= "up") or source ~= skin_skinTable then
  1687.         return
  1688.     end
  1689.     local x, y = guiGridListGetSelectedItem(source)
  1690.     if tonumber(x) and  tonumber(y) then
  1691.         local skinID = guiGridListGetItemText(source, x, skin_skinTable_01)
  1692.         currentSkin = getSkinID(skinID)
  1693.         if type(currentSkin) =='number' then
  1694.             backToID = backToID or getElementModel(getLocalPlayer())
  1695.             if isTimer(skinTimer) then
  1696.                 killTimer(skinTimer)
  1697.                 skinTimer = setTimer(function() setElementModel(getLocalPlayer(), backToID) backToID=nil end, 5000, 1 )
  1698.             else
  1699.                 skinTimer = setTimer(function() setElementModel(getLocalPlayer(), backToID) backToID=nil end, 5000, 1 )
  1700.             end
  1701.             setElementModel(getLocalPlayer(), currentSkin)
  1702.         end
  1703.     end
  1704. end
  1705.  
  1706. function groupSelected(button, state, absoluteX, absoluteY)
  1707.     if (button ~= "left") or (state ~= "up") or source ~= skin_groupTable then
  1708.         return
  1709.     end
  1710.     local x, y = guiGridListGetSelectedItem(source)
  1711.     if tonumber(x) and  tonumber(y) then
  1712.         local groupName = guiGridListGetItemText(source, x, y)
  1713.         fillTableSkins(groupName)
  1714.     end
  1715. end
  1716.  
  1717. function fillTableSkins ( group )
  1718.     if group == 'All skins' or aSkins[group] then
  1719.         guiGridListClear(skin_skinTable)
  1720.         if group == 'All skins' then
  1721.             local used_id = {}
  1722.             for name, group in pairs(aSkins) do
  1723.                 for ID, skin in ipairs(group) do
  1724.                     if not used_id[skin['model']] then
  1725.                         local i = guiGridListAddRow(skin_skinTable)
  1726.                         guiGridListSetItemText( skin_skinTable, i, skin_skinTable_01, skin['model'], false, true )
  1727.                         guiGridListSetItemText( skin_skinTable, i, skin_skinTable_02, skin['name'], false, false )
  1728.                         used_id[skin['model']] = skin['model']
  1729.                     end
  1730.                 end
  1731.             end
  1732.         elseif aSkins[group] then
  1733.             for ID, skin in ipairs(aSkins[group]) do
  1734.                 local i = guiGridListAddRow(skin_skinTable)
  1735.                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_01, skin['model'], false, true )
  1736.                 guiGridListSetItemText( skin_skinTable, i, skin_skinTable_02, skin['name'], false, false )
  1737.             end
  1738.             currentSkin = nil
  1739.         end
  1740.     end
  1741. end
  1742.  
  1743. function aLoadSkins ()
  1744.     local table = {}
  1745.     local node = xmlLoadFile ( "skins.xml" )
  1746.     if ( node ) then
  1747.         local groups = 0
  1748.         while ( xmlFindChild ( node, "group", groups ) ~= false ) do
  1749.             local group = xmlFindChild ( node, "group", groups )
  1750.             local groupn = xmlNodeGetAttribute ( group, "name" )
  1751.             table[groupn] = {}
  1752.             local skins = 0
  1753.             while ( xmlFindChild ( group, "skin", skins ) ~= false ) do
  1754.                 local skin = xmlFindChild ( group, "skin", skins )
  1755.                 local id = #table[groupn] + 1
  1756.                 table[groupn][id] = {}
  1757.                 table[groupn][id]["model"] = xmlNodeGetAttribute ( skin, "model" )
  1758.                 table[groupn][id]["name"] = xmlNodeGetAttribute ( skin, "name" )
  1759.                 skins = skins + 1
  1760.             end
  1761.             groups = groups + 1
  1762.         end
  1763.         xmlUnloadFile ( node )
  1764.     end
  1765.     return table
  1766. end
  1767.  
  1768.  
  1769.  
  1770. -- Handle skins
  1771. local skins = {
  1772. [0]=0, [7]=7, [9]=9, [10]=10, [11]=11,
  1773.  
  1774. [12]=12, [13]=13, [14]=14, [15]=15, [16]=16,
  1775.  
  1776. [17]=17, [18]=18, [19]=19, [20]=20, [21]=21,
  1777.  
  1778. [22]=22, [23]=23, [24]=24, [25]=25, [26]=26,
  1779.  
  1780. [27]=27, [28]=28, [29]=29, [30]=30, [31]=31,
  1781.  
  1782. [32]=32, [33]=33, [34]=34, [35]=35, [36]=36,
  1783.  
  1784. [37]=37, [38]=38, [39]=39, [40]=40, [41]=41,
  1785.  
  1786. [43]=43, [44]=44, [45]=45, [46]=46, [47]=47,
  1787.  
  1788. [48]=48, [49]=49, [50]=50, [51]=51, [52]=52,
  1789.  
  1790. [53]=53, [54]=54, [55]=55, [56]=56, [57]=57,
  1791.  
  1792. [58]=58, [59]=59, [60]=60, [61]=61, [62]=62,
  1793.  
  1794. [63]=63, [64]=64, [66]=66, [67]=67, [68]=68,
  1795.  
  1796. [69]=69, [70]=70, [71]=71, [72]=72, [73]=73,
  1797.  
  1798. [75]=75, [76]=76, [77]=77, [78]=78, [79]=79,
  1799.  
  1800. [80]=80, [81]=81, [82]=82, [83]=83, [84]=84,
  1801.  
  1802. [85]=85, [87]=87, [88]=88, [89]=89, [90]=90,
  1803.  
  1804. [91]=91, [92]=92, [93]=93, [94]=94, [95]=95,
  1805.  
  1806. [96]=96, [97]=97, [98]=98, [99]=99, [100]=100,
  1807.  
  1808. [101]=101, [102]=102, [103]=103, [104]=104, [105]=105,
  1809.  
  1810. [106]=106, [107]=107, [108]=108, [109]=109, [110]=110,
  1811.  
  1812. [111]=111, [112]=112, [113]=113, [114]=114, [115]=115,
  1813.  
  1814. [116]=116, [117]=117, [118]=118, [120]=120, [121]=121,
  1815.  
  1816. [122]=122, [123]=123, [124]=124, [125]=125, [126]=126,
  1817.  
  1818. [127]=127, [128]=128, [129]=129, [130]=130, [131]=131,
  1819.  
  1820. [132]=132, [133]=133, [134]=134, [135]=135, [136]=136,
  1821.  
  1822. [137]=137, [138]=138, [139]=139, [140]=140, [141]=141,
  1823.  
  1824. [142]=142, [143]=143, [144]=144, [145]=145, [146]=146,
  1825.  
  1826. [147]=147, [148]=148, [150]=150, [151]=151, [152]=152,
  1827.  
  1828. [153]=153, [154]=154, [155]=155, [156]=156, [157]=157,
  1829.  
  1830. [158]=158, [159]=159, [160]=160, [161]=161, [162]=162,
  1831.  
  1832. [163]=163, [164]=164, [165]=165, [166]=166, [167]=167,
  1833.  
  1834. [168]=168, [169]=169, [170]=170, [171]=171, [172]=172,
  1835.  
  1836. [173]=173, [174]=174, [175]=175, [176]=176, [177]=177,
  1837.  
  1838. [178]=178, [179]=179, [180]=180, [181]=181, [182]=182,
  1839.  
  1840. [183]=183, [184]=184, [185]=185, [186]=186, [187]=187,
  1841.  
  1842. [188]=188, [189]=189, [190]=190, [191]=191, [192]=192,
  1843.  
  1844. [193]=193, [194]=194, [195]=195, [196]=196, [197]=197,
  1845.  
  1846. [198]=198, [199]=199, [200]=200, [201]=201, [202]=202,
  1847.  
  1848. [203]=203, [204]=204, [205]=205, [206]=206, [207]=207,
  1849.  
  1850. [209]=209, [210]=210, [211]=211, [212]=212, [213]=213,
  1851.  
  1852. [214]=214, [215]=215, [216]=216, [217]=217, [218]=218,
  1853.  
  1854. [219]=219, [220]=220, [221]=221, [222]=222, [223]=223,
  1855.  
  1856. [224]=224, [225]=225, [226]=226, [227]=227, [228]=228,
  1857.  
  1858. [229]=229, [230]=230, [231]=231, [232]=232, [233]=233,
  1859.  
  1860. [234]=234, [235]=235, [236]=236, [237]=237, [238]=238,
  1861.  
  1862. [239]=239, [240]=240, [241]=241, [242]=242, [243]=243,
  1863.  
  1864. [244]=244, [245]=245, [246]=246, [247]=247, [248]=248,
  1865.  
  1866. [249]=249, [250]=250, [251]=251, [252]=252, [253]=253,
  1867.  
  1868. [254]=254, [255]=255, [256]=256, [257]=257, [258]=258,
  1869.  
  1870. [259]=259, [260]=260, [261]=261, [262]=262, [263]=263,
  1871.  
  1872. [264]=264, [274]=274, [275]=275, [276]=276, [277]=277,
  1873.  
  1874. [278]=278, [279]=279, [280]=280, [281]=281, [282]=282,
  1875.  
  1876. [283]=283, [284]=284, [285]=285, [286]=286, [287]=287,
  1877.  
  1878. [288]=288
  1879. }
  1880.  
  1881. function getSkinID ( ID )
  1882.     return skins[tonumber(ID)] or false
  1883. end
  1884.  
  1885.  
  1886.  
  1887.  
  1888. -- Headlights
  1889. function requestHeadlights()
  1890.     local thePlayer = getLocalPlayer()
  1891.     callServerFunction("retrieveLevel",thePlayer)
  1892. end
  1893.  
  1894. function checkLevel(playerLevel)
  1895.     if playerLevel >= 5 then
  1896.         colorPickMode = "headlights"
  1897.         guiSetText(colorWindow,"Select your headlights color...")
  1898.         showHLCWindow()
  1899.     else
  1900.         outputChatBox("#FF6600* #FFFFFFYou need to be at least level #ABCDEF5 #FFFFFFto change your headlights color!",255,255,255,true)
  1901.     end
  1902. end
  1903.  
  1904. function showHLCWindow ()
  1905.     local self = getLocalPlayer()
  1906.     local vehicle = getPedOccupiedVehicle(self)
  1907.     if (vehicle) then
  1908.         getVisible = guiGetVisible (colorWindow)
  1909.         if (getVisible == false) then
  1910.             guiSetVisible (colorWindow, true)
  1911.             guiBringToFront(colorWindow)
  1912.         end
  1913.     else
  1914.         outputChatBox("#FF6600* #FFFFFFYou need to be in a vehicle to change your headlights color!",255,255,255,true)
  1915.     end
  1916. end
  1917.  
  1918.  
  1919. function lightColor()
  1920.     if source == redBar or source == greenBar or source == blueBar then
  1921.         if PickMode == "headlights" then
  1922.             local player = source
  1923.             local car = getPedOccupiedVehicle(getLocalPlayer()) setVehicleHeadLightColor(car,(guiScrollBarGetScrollPosition(redBar)*2.55),(guiScrollBarGetScrollPosition(greenBar)*2.55),(guiScrollBarGetScrollPosition(blueBar)*2.55))
  1924.         end
  1925.         guiLabelSetColor(lblColorPreview,guiScrollBarGetScrollPosition(redBar)*2.55,guiScrollBarGetScrollPosition(greenBar)*2.55,guiScrollBarGetScrollPosition(blueBar)*2.55)
  1926.     end
  1927. end
  1928. addEventHandler("onClientGUIScroll",getRootElement(),lightColor)
  1929.  
  1930.  
  1931.  
  1932. -- Nametag color
  1933. function getNametagLevel()
  1934.     callServerFunction("getNametagLevel",getLocalPlayer())
  1935. end
  1936.  
  1937. function showNametagWindow()
  1938.     if (guiGetVisible(colorWindow) == false) then
  1939.         guiSetVisible (colorWindow, true)
  1940.         guiBringToFront(colorWindow)
  1941.     end
  1942.     colorPickMode = "nametag"
  1943.     guiSetText(colorWindow,"Select your nametag color...")
  1944. end
  1945.  
  1946.  
  1947.  
  1948.  
  1949.  
  1950. -- Combined from Headlights and Nametags
  1951. function saveData ()
  1952.     thePlayer = getLocalPlayer()
  1953.     if colorPickMode == "headlights" then
  1954.         local colorRed = tonumber(guiScrollBarGetScrollPosition(redBar)*2.55)
  1955.         local colorGreen = tonumber(guiScrollBarGetScrollPosition(greenBar)*2.55)
  1956.         local colorBlue = tonumber(guiScrollBarGetScrollPosition(blueBar)*2.55)
  1957.         --outputChatBox("CLIENT: "..colorRed..","..colorGreen..","..colorBlue.." <---- The arguments passed on",getRootElement())
  1958.         triggerServerEvent ("saveHeadlights", getRootElement(), thePlayer, colorRed, colorGreen, colorBlue)
  1959.         --outputChatBox("CLIENT: Triggering the event, waiting for a reply from the server...",getRootElement())
  1960.         getVisible = guiGetVisible (colorWindow)
  1961.         if (getVisible == true) then
  1962.             guiSetVisible (colorWindow, false)
  1963.         end
  1964.         callServerFunction("achievement27",getLocalPlayer())
  1965.         colorPickMode = false
  1966.     elseif colorPickMode == "nametag" then
  1967.         local colorRed = tonumber(guiScrollBarGetScrollPosition(redBar)*2.55)
  1968.         local colorGreen = tonumber(guiScrollBarGetScrollPosition(greenBar)*2.55)
  1969.         local colorBlue = tonumber(guiScrollBarGetScrollPosition(blueBar)*2.55)
  1970.         callServerFunction("saveNametagColor",thePlayer,colorRed,colorGreen,colorBlue)
  1971.         getVisible = guiGetVisible (colorWindow)
  1972.         if (getVisible == true) then
  1973.             guiSetVisible (colorWindow, false)
  1974.         end
  1975.         colorPickMode = false
  1976.     end
  1977. end
  1978.  
  1979. function closeColorSelectionWindow()
  1980.     if guiGetVisible(colorWindow) == true then
  1981.         guiSetVisible(colorWindow,false)
  1982.     end
  1983.     colorPickMode = false
  1984. end
  1985.  
  1986.  
  1987.  
  1988. -- Horns
  1989. function updateHornsOnStart()
  1990.     callServerFunction("getPurchasedHorns",getLocalPlayer())
  1991.     callServerFunction("getLastSetHorn",getLocalPlayer())
  1992. end
  1993. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),updateHornsOnStart)
  1994.  
  1995. function updateHorns(thePlayer,h1,h2,h3,h4,h5,h6,h7)
  1996.     guiGridListSetItemColor(gridHorns,0,1,100,255,60,255)
  1997.     guiGridListSetItemColor(gridHorns,0,2,100,255,60,255)
  1998.  
  1999.     if h1 == 1 then
  2000.         guiGridListSetItemColor(gridHorns,1,1,100,255,60,255)
  2001.         guiGridListSetItemColor(gridHorns,1,2,100,255,60,255)
  2002.     end
  2003.  
  2004.     if h2 == 1 then
  2005.         guiGridListSetItemColor(gridHorns,2,1,100,255,60,255)
  2006.         guiGridListSetItemColor(gridHorns,2,2,100,255,60,255)
  2007.     end
  2008.  
  2009.     if h3 == 1 then
  2010.         guiGridListSetItemColor(gridHorns,3,1,100,255,60,255)
  2011.         guiGridListSetItemColor(gridHorns,3,2,100,255,60,255)
  2012.     end
  2013.  
  2014.     if h4 == 1 then
  2015.         guiGridListSetItemColor(gridHorns,4,1,100,255,60,255)
  2016.         guiGridListSetItemColor(gridHorns,4,2,100,255,60,255)
  2017.     end
  2018.  
  2019.     if h5 == 1 then
  2020.         guiGridListSetItemColor(gridHorns,5,1,100,255,60,255)
  2021.         guiGridListSetItemColor(gridHorns,5,2,100,255,60,255)
  2022.     end
  2023.  
  2024.     if h6 == 1 then
  2025.         guiGridListSetItemColor(gridHorns,6,1,100,255,60,255)
  2026.         guiGridListSetItemColor(gridHorns,6,2,100,255,60,255)
  2027.     end
  2028.  
  2029.     if h7 == 1 then
  2030.         guiGridListSetItemColor(gridHorns,7,1,100,255,60,255)
  2031.         guiGridListSetItemColor(gridHorns,7,2,100,255,60,255)
  2032.     end
  2033. end
  2034.  
  2035. function setLastUsedHorn(horn)
  2036.     if not (horn == 0) then
  2037.         setHornSound = horn
  2038.         toggleControl("horn",false)
  2039.         guiSetText(lblCurrentHorn,"Current horn: "..hornName[horn+1])
  2040.     else
  2041.         toggleControl("horn",true)
  2042.         guiSetText(lblCurrentHorn,"Current horn: Default GTA horn")
  2043.     end
  2044.     bindKey ("h", "down", playCustomHorn)
  2045. end
  2046.  
  2047.  
  2048. function hornPreview()
  2049.     local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  2050.     if selectedHorn <= 0 then
  2051.         return
  2052.     end
  2053.     if selectedHorn == 6 then
  2054.         local previewHorn = playSound(hornSound[selectedHorn])
  2055.         setSoundVolume(previewHorn,0.6)
  2056.     else
  2057.         local previewHorn = playSound(hornSound[selectedHorn])
  2058.         setSoundVolume(previewHorn,0.8)
  2059.     end
  2060. end
  2061.  
  2062.  
  2063. function buyHorn()
  2064.     local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  2065.     if selectedHorn == -1 then
  2066.         outputChatBox("#FF6600* #FFFFFFERROR! Please select a horn to buy!",255,255,255,true)
  2067.         return
  2068.     end
  2069.     if selectedHorn == 0 then
  2070.         outputChatBox("#FF6600* #FFFFFFERROR! You already own this horn!",255,255,255,true)
  2071.         return
  2072.     end
  2073.     callServerFunction("purchaseHorn",getLocalPlayer(),selectedHorn,hornName[selectedHorn+1])
  2074. end
  2075.  
  2076.  
  2077. function setHornCheck()
  2078.     local selectedHorn = guiGridListGetSelectedItem(gridHorns)
  2079.     if selectedHorn == -1 then
  2080.         outputChatBox("#FF6600* #FFFFFFERROR! Please select a horn!",255,255,255,true)
  2081.         return
  2082.     end
  2083.     if selectedHorn == 0 then
  2084.         outputChatBox("#FF6600* #FFFFFFHorn sound has been set to: #ABCDEF"..hornName[selectedHorn+1],255,255,255,true)
  2085.         callServerFunction("setLastSetHorn",getLocalPlayer(),selectedHorn)
  2086.         setHornSound = 0
  2087.         toggleControl("horn",true)
  2088.         guiSetText(lblCurrentHorn,"Current horn: Default GTA horn")
  2089.         return
  2090.     end
  2091.     callServerFunction("checkForPurchasedHorn",getLocalPlayer(),selectedHorn)
  2092. end
  2093.  
  2094. function setHorn(horn)
  2095.     outputChatBox("#FF6600* #FFFFFFHorn sound has been set to: #ABCDEF"..hornName[horn+1],255,255,255,true)
  2096.     callServerFunction("setLastSetHorn",getLocalPlayer(),horn)
  2097.     toggleControl("horn",false)
  2098.     setHornSound = horn
  2099.     guiSetText(lblCurrentHorn,"Current horn: "..hornName[horn+1])
  2100. end
  2101.  
  2102. function updateHornPriceLabel()
  2103.     local row = guiGridListGetSelectedItem(gridHorns)
  2104.     if (row > 0) then
  2105.         local price = guiGridListGetItemText(gridHorns,row,2)
  2106.         guiSetText(lblHornPrice,"$"..string.gsub(price," ",""))
  2107.     else
  2108.         guiSetText(lblHornPrice,"N/A")
  2109.     end
  2110. end
  2111.  
  2112.  
  2113.  
  2114.  
  2115. -- Play the actual horn sound
  2116. function playCustomHorn()
  2117.     if isControlEnabled("horn") == false then
  2118.         if getElementData(getLocalPlayer(),"state") == "alive" then
  2119.             if hornNum == 0 then
  2120.                 callServerFunction("playHornForAllClients",getLocalPlayer(),tostring(hornSound[setHornSound]),setHornSound)
  2121.             end
  2122.         end
  2123.     elseif setHornSound ~= 0 then
  2124.         toggleControl("horn",false)
  2125.         playCustomHorn()
  2126.     end
  2127. end
  2128.  
  2129.  
  2130. function playHornSound(horningPlayer,hornSoundPath,cSetHornSound)
  2131.     local numItems = 0
  2132.     for k,v in pairs(customHorn) do
  2133.         numItems = numItems + 1
  2134.     end
  2135.     if (cSetHornSound ~= 0) then
  2136.  
  2137.         customHorn[numItems+1] = playSound3D(hornSoundPath,0,0,0)
  2138.  
  2139.         if horningPlayer == getLocalPlayer() then
  2140.             hornNum = numItems+1
  2141.         else
  2142.             hornNum = 0
  2143.         end
  2144.  
  2145.         setSoundMaxDistance(customHorn[numItems+1],60)
  2146.         if (cSetHornSound == 6) then
  2147.             setSoundVolume(customHorn[numItems+1],0.32)
  2148.         elseif (cSetHornSound == 5) then
  2149.             setSoundVolume(customHorn[numItems+1],0.6)
  2150.         elseif (cSetHornSound == 7) then
  2151.             setSoundVolume(customHorn[numItems+1],0.73)
  2152.         elseif (cSetHornSound == 4) then
  2153.             setSoundVolume(customHorn[numItems+1],0.5)
  2154.         elseif (cSetHornSound == 1) then
  2155.             setSoundVolume(customHorn[numItems+1],0.82)
  2156.         else
  2157.             setSoundVolume(customHorn[numItems+1],0.6)
  2158.         end
  2159.  
  2160.         attachElements(customHorn[numItems+1],horningPlayer,0,0,0.5)
  2161.  
  2162.         local length = getSoundLength(customHorn[numItems+1])
  2163.         detachTimer = setTimer(
  2164.             function()
  2165.                 if (customHorn[numItems+1]) then
  2166.                     if isElementAttached(customHorn[numItems+1]) == true then
  2167.                         detachElements(customHorn[numItems+1])
  2168.                     end
  2169.                     stopSound(customHorn[numItems+1])
  2170.                 end
  2171.                 customHorn[numItems+1] = nil
  2172.                 hornNum = 0
  2173.             end,length-100,1)
  2174.     end
  2175. end
  2176. addEvent("onRecieveHorn",true)
  2177. addEventHandler("onRecieveHorn",getRootElement(),playHornSound)
  2178.  
  2179.  
  2180.  
  2181.  
  2182.  
  2183. -- Buy water color and time
  2184. function buyChangeWaterColor()
  2185.     callServerFunction("buyChangeWaterColor",getLocalPlayer(),tonumber(guiGetText(editWaterColorRed)),tonumber(guiGetText(editWaterColorGreen)),tonumber(guiGetText(editWaterColorBlue)))
  2186. end
  2187.  
  2188. function cSetWaterColor(r,g,b)
  2189.     setWaterColor(r,g,b)
  2190. end
  2191.  
  2192.  
  2193. function buyChangeTime()
  2194.     callServerFunction("buyChangeTime",getLocalPlayer(),tonumber(guiGetText(editTimeHours)),tonumber(guiGetText(editTimeMinutes)))
  2195. end
  2196.  
  2197.  
  2198.  
  2199.  
  2200.  
  2201.  
  2202. -- Reaction test console check
  2203. function checkForOpenConsole(message,type)
  2204.     local isOpen = isConsoleActive()
  2205.     callServerFunction("checkReactionTest",getLocalPlayer(),message,type,isOpen)
  2206. end
  2207.  
  2208.  
  2209.  
  2210.  
  2211. ------------------------------------------------
  2212. -- Stats refresing and other userpanel functions
  2213. ------------------------------------------------
  2214.  
  2215. function refreshStats(levelDisplay,levelImage,playerCash,unlockedAchievements,totalTimesJoined,mapsWon,mapsPlayed,winRatio,totalHunters,totalToptimes,totalMoneyEarned,totalMoneySent,totalBets,totalBetsEarned,totalBetsWon,totalDeaths,totalPlayingTimeMinutes,totalPlayingTimeHours,totalReactionTests,bestReactionTime)
  2216.     guiSetText (lblPlayerLevel, "Level: "..levelDisplay)
  2217.     guiSetText (lblPlayerMoney, "Money: $"..playerCash)
  2218.     guiSetText (lblAchievementsUnlocked, "Achievements unlocked: "..unlockedAchievements.."/40")
  2219.     guiSetText (lblAchievementsUnlockedTab, "Achievements unlocked: "..unlockedAchievements.."/40")
  2220.     guiSetText (lblPlayerLevelRank, "Level "..levelDisplay)
  2221.     guiSetText (lblMapsWon,"Maps won: "..mapsWon)
  2222.     guiSetText (lblTotalMapsPlayed,"Total maps played: "..mapsPlayed)
  2223.     guiSetText (lblWinRatio,"Map win ratio: "..winRatio.."%")
  2224.     guiSetText (lblTimesJoined,"Times joined the server: "..totalTimesJoined)
  2225.     guiSetText (lblTotalHunters,"Total hunters reached: "..totalHunters)
  2226.     guiSetText (lblTotalToptimes,"Total toptimes set: "..totalToptimes)
  2227.     guiSetText (lblTotalMoney,"Total money earned: $"..totalMoneyEarned)
  2228.     guiSetText (lblSentMoney,"Money sent to players: $"..totalMoneySent)
  2229.     guiSetText (lblTotalDeaths,"Total deaths: "..totalDeaths)
  2230.     guiSetText (lblTotalBets,"Total bets: "..totalBets)
  2231.     guiSetText (lblBetsWon,"Bets won: "..totalBetsWon)
  2232.     guiSetText (lblMoneyEarnBet,"Money earned with betting: $"..totalBetsEarned)
  2233.     guiSetText (lblTotalReactionTests,"Reaction tests won: "..totalReactionTests)
  2234.     guiSetText (tabs[1],"Your stats")
  2235.     guiStaticImageLoadImage (imageLevel,levelImage)
  2236.     if totalPlayingTimeMinutes < 10 then
  2237.         guiSetText (lblTotalPlayingTime,"Total playing time: "..totalPlayingTimeHours..":0"..totalPlayingTimeMinutes)
  2238.     else
  2239.         guiSetText (lblTotalPlayingTime,"Total playing time: "..totalPlayingTimeHours..":"..totalPlayingTimeMinutes)
  2240.     end
  2241.  
  2242.     if bestReactionTime == 0 then
  2243.         guiSetText (lblBestReactionTime,"Best reaction time: N/A")
  2244.     else
  2245.         guiSetText (lblBestReactionTime,"Best reaction time: "..bestReactionTime)
  2246.     end
  2247.  
  2248.     local row = 0
  2249.     for detail,detailName in pairs(details) do
  2250.         guiGridListSetItemData(gridAchievements,row,1,detailName)
  2251.         row = row+1
  2252.     end
  2253. end
  2254.  
  2255. function refreshTimePlaying(totalPlayingTimeMinutes,totalPlayingTimeHours)
  2256.     if totalPlayingTimeMinutes < 10 then
  2257.         guiSetText (lblTotalPlayingTime,"Total playing time: "..totalPlayingTimeHours..":0"..totalPlayingTimeMinutes)
  2258.     else
  2259.         guiSetText (lblTotalPlayingTime,"Total playing time: "..totalPlayingTimeHours..":"..totalPlayingTimeMinutes)
  2260.     end
  2261. end
  2262.  
  2263. function triggerScoreboardRefresh()
  2264.     callServerFunction("scoreboardRefresh",getLocalPlayer())
  2265. end
  2266. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),triggerScoreboardRefresh)
  2267.  
  2268.  
  2269. function playingTimeTimer()
  2270.     addTime = setTimer(playingTimeTimerTrigger,60000,0)
  2271. end
  2272. function playingTimeTimerTrigger()
  2273.     callServerFunction("playingTimeAdd",getLocalPlayer())
  2274. end
  2275. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),playingTimeTimer)
  2276.  
  2277. function playingTimeTimerStop()
  2278.     killTimer(addTime)
  2279. end
  2280. addEventHandler("onClientResourceStop",getResourceRootElement(getThisResource()),playingTimeTimerStop)
  2281.  
  2282. function setProgressBar(progressBarValue)
  2283.     guiProgressBarSetProgress(progressLevel,progressBarValue)
  2284. end
  2285.  
  2286. function updateProgressBar(progressBarValue)
  2287.     guiProgressBarSetProgress(progressLevel,progressBarValue)
  2288. end
  2289. function triggerProgressBarOnStart()
  2290.     callServerFunction("progressBarUpdate",getLocalPlayer())
  2291. end
  2292. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),triggerProgressBarOnStart)
  2293.  
  2294. function togglePersonalDetailsWindow()
  2295.     local visible = guiGetVisible(personalDetailsWindow)
  2296.     if visible == false then
  2297.         guiEditSetReadOnly(pDetailsName,false)
  2298.         guiEditSetReadOnly(pDetailsAge,false)
  2299.         guiEditSetReadOnly(pDetailsEmail,false)
  2300.         guiEditSetReadOnly(pDetailsMsn,false)
  2301.         guiEditSetReadOnly(pDetailsSkype,false)
  2302.         guiEditSetReadOnly(pDetailsXfire,false)
  2303.         guiEditSetReadOnly(pDetailsICQ,false)
  2304.         guiEditSetReadOnly(pDetailsXBL,false)
  2305.         guiSetVisible(personalDetailsWindow,true)
  2306.         guiBringToFront(personalDetailsWindow)
  2307.     end
  2308. end
  2309.  
  2310. function closePersonalDetailsWindow()
  2311.     if (guiGetText(buttonPersonalDetailsSave) == "Save") then
  2312.         guiSetVisible(personalDetailsWindow,false)
  2313.         callServerFunction("savePersonalDetails",getLocalPlayer(),guiGetText(pDetailsName),guiGetText(pDetailsAge),guiGetText(pDetailsEmail),guiGetText(pDetailsMsn),guiGetText(pDetailsSkype),guiGetText(pDetailsXfire),guiGetText(pDetailsICQ),guiGetText(pDetailsXBL))
  2314.     else
  2315.         guiSetVisible(personalDetailsWindow,false)
  2316.         guiSetText(buttonPersonalDetailsSave,"Save")
  2317.     end
  2318. end
  2319.  
  2320. function refreshConnectedPlayers()
  2321.     guiGridListClear(gridOnlinePlayers)
  2322.     for _,player in ipairs(getElementsByType("player")) do
  2323.         local row = guiGridListAddRow (gridOnlinePlayers)
  2324.         guiGridListSetItemText(gridOnlinePlayers,row,1,string.gsub(getPlayerName(player),"#%x%x%x%x%x%x", ""),false,false)
  2325.     end
  2326.     if playerIsChatting == true then
  2327.         guiSetText(lblChattingWith,string.gsub(getPlayerName(getElementData(getLocalPlayer(),"chattingWith")),"#%x%x%x%x%x%x", ""))
  2328.     end
  2329. end
  2330.  
  2331. function giveMoney()
  2332.     local row,column = guiGridListGetSelectedItem(gridOnlinePlayers)
  2333.     local playerName = guiGridListGetItemText(gridOnlinePlayers,row,1)
  2334.     local amount = guiGetText(editAmountToSend)
  2335.     callServerFunction("giveMoney",getLocalPlayer(),playerName,amount)
  2336. end
  2337.  
  2338. function getDataOnStart()
  2339.     callServerFunction("getDataOnStart",getLocalPlayer())
  2340. end
  2341. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),getDataOnStart)
  2342.  
  2343. function setDataOnStart(pName,pAge,pEmail,pMsn,pSkype,pXFire,pIcq,pXbl)
  2344.     if not (pName == 0) then guiSetText(pDetailsName,pName) end
  2345.     if not (pAge == 0) then guiSetText(pDetailsAge,pAge) end
  2346.     if not (pEmail == 0) then guiSetText(pDetailsEmail,pEmail) end
  2347.     if not (pMsn == 0) then guiSetText(pDetailsMsn,pMsn) end
  2348.     if not (pSkype == 0) then guiSetText(pDetailsSkype,pSkype) end
  2349.     if not (pXFire == 0) then guiSetText(pDetailsXfire,pXFire) end
  2350.     if not (pIcq == 0) then guiSetText(pDetailsICQ,pIcq) end
  2351.     if not (pXbl == 0) then guiSetText(pDetailsXBL,pXbl) end
  2352. end
  2353.  
  2354.  
  2355. function displayPersonalDetailsCall()
  2356.     local row,column = guiGridListGetSelectedItem(gridOnlinePlayers)
  2357.     local playerName = guiGridListGetItemText(gridOnlinePlayers,row,1)
  2358.     if not (playerName == "") then
  2359.         callServerFunction("getPersonalDetails",getLocalPlayer(),playerName)
  2360.     else
  2361.         outputChatBox("#FF6600* #FFFFFFERROR! Please select a player!",255,255,255,true)
  2362.     end
  2363. end
  2364.  
  2365. function displayPersonalDetails(pName,pAge,pEmail,pMsn,pSkype,pXFire,pIcq,pXbl)
  2366.     if (pName == 0) then
  2367.         guiSetText(pDetailsName," ")
  2368.     else
  2369.         guiSetText(pDetailsName,pName)
  2370.     end
  2371.  
  2372.     if (pAge == 0) then
  2373.         guiSetText(pDetailsAge," ")
  2374.     else
  2375.         guiSetText(pDetailsAge,pAge)
  2376.     end
  2377.  
  2378.     if (pEmail == 0) then
  2379.         guiSetText(pDetailsEmail," ")
  2380.     else
  2381.         guiSetText(pDetailsEmail,pEmail)
  2382.     end
  2383.  
  2384.     if (pMsn == 0) then
  2385.         guiSetText(pDetailsMsn," ")
  2386.     else
  2387.         guiSetText(pDetailsMsn,pMsn)
  2388.     end
  2389.  
  2390.     if (pSkype == 0) then
  2391.         guiSetText(pDetailsSkype," ")
  2392.     else
  2393.         guiSetText(pDetailsSkype,pSkype)
  2394.     end
  2395.  
  2396.     if (pXFire == 0) then
  2397.         guiSetText(pDetailsXfire," ")
  2398.     else
  2399.         guiSetText(pDetailsXfire,pXFire)
  2400.     end
  2401.  
  2402.     if (pIcq == 0) then
  2403.         guiSetText(pDetailsICQ," ")
  2404.     else
  2405.         guiSetText(pDetailsICQ,pIcq)
  2406.     end
  2407.  
  2408.     if (pXbl == 0) then
  2409.         guiSetText(pDetailsXBL," ")
  2410.     else
  2411.         guiSetText(pDetailsXBL,pXbl)
  2412.     end
  2413.  
  2414.     guiEditSetReadOnly(pDetailsName,true)
  2415.     guiEditSetReadOnly(pDetailsAge,true)
  2416.     guiEditSetReadOnly(pDetailsEmail,true)
  2417.     guiEditSetReadOnly(pDetailsMsn,true)
  2418.     guiEditSetReadOnly(pDetailsSkype,true)
  2419.     guiEditSetReadOnly(pDetailsXfire,true)
  2420.     guiEditSetReadOnly(pDetailsICQ,true)
  2421.     guiEditSetReadOnly(pDetailsXBL,true)
  2422.     guiSetText(buttonPersonalDetailsSave,"Close")
  2423.     guiSetVisible(personalDetailsWindow,true)
  2424.     guiBringToFront(personalDetailsWindow)
  2425. end
  2426.  
  2427.  
  2428. function getPersonalStats()
  2429.     local row,column = guiGridListGetSelectedItem(gridOnlinePlayers)
  2430.     local playerName = guiGridListGetItemText(gridOnlinePlayers,row,1)
  2431.     if not (playerName == "") then
  2432.         callServerFunction("getPlayerStats",getLocalPlayer(),findPlayerByName(playerName))
  2433.     else
  2434.         outputChatBox("#FF6600* #FFFFFFERROR! Please select a player!",255,255,255,true)
  2435.     end
  2436. end
  2437.  
  2438.  
  2439. function displayPersonalStats(thePlayer,levelDisplay,levelImage,playerCash,unlockedAchievements,totalTimesJoined,mapsWon,mapsPlayed,winRatio,totalHunters,totalToptimes,totalMoneyEarned,totalMoneySent,totalBets,totalBetsEarned,totalBetsWon,totalDeaths,totalPlayingTimeMinutes,totalPlayingTimeHours,totalReactionTests,bestReactionTime)
  2440.     guiSetText (lblPLevel, "Level: "..levelDisplay)
  2441.     guiSetText (lblPMoney, "Money: $"..playerCash)
  2442.     guiSetText (lblPAchievementsUnlocked, "Achievements unlocked: "..unlockedAchievements.."/40")
  2443.     guiSetText (lblPLevel2, "Level "..levelDisplay)
  2444.     guiSetText (lblPMapsWon,"Maps won: "..mapsWon)
  2445.     guiSetText (lblPTotalMapsPlayed,"Total maps played: "..mapsPlayed)
  2446.     guiSetText (lblPWinRatio,"Map win ratio: "..winRatio.."%")
  2447.     guiSetText (lblPTimesJoined,"Times joined the server: "..totalTimesJoined)
  2448.     guiSetText (lblPTotalHunters,"Total hunters reached: "..totalHunters)
  2449.     guiSetText (lblPTotalToptimes,"Total toptimes set: "..totalToptimes)
  2450.     guiSetText (lblPTotalMoneyEarned,"Total money earned: $"..totalMoneyEarned)
  2451.     guiSetText (lblPMoneySent,"Money sent to players: $"..totalMoneySent)
  2452.     guiSetText (lblPTotalDeaths,"Total deaths: "..totalDeaths)
  2453.     guiSetText (lblPTotalBets,"Total bets: "..totalBets)
  2454.     guiSetText (lblPBetsWon,"Bets won: "..totalBetsWon)
  2455.     guiSetText (lblPMoneyBetEarned,"Money earned with betting: $"..totalBetsEarned)
  2456.     guiSetText (lblPTotalReactionTests,"Reaction tests won: "..totalReactionTests)
  2457.     guiStaticImageLoadImage (pImageLevel,levelImage)
  2458.     if totalPlayingTimeMinutes < 10 then
  2459.         guiSetText (lblPTotalPlayingTime,"Total playing time: "..totalPlayingTimeHours..":0"..totalPlayingTimeMinutes)
  2460.     else
  2461.         guiSetText (lblPTotalPlayingTime,"Total playing time: "..totalPlayingTimeHours..":"..totalPlayingTimeMinutes)
  2462.     end
  2463.  
  2464.     if bestReactionTime == 0 or bestReactionTime == "" then
  2465.         guiSetText (lblPBestReactionTime,"Best reaction time: N/A")
  2466.     else
  2467.         guiSetText (lblPBestReactionTime,"Best reaction time: "..bestReactionTime)
  2468.     end
  2469.  
  2470.     guiSetText(playerStatsWindow,string.gsub(getPlayerName(thePlayer),"#%x%x%x%x%x%x", "").."'s stats")
  2471.     guiSetVisible(playerStatsWindow,true)
  2472.     guiBringToFront(playerStatsWindow)
  2473. end
  2474.  
  2475.  
  2476. function closeStatsWindow()
  2477.     guiSetVisible(playerStatsWindow,false)
  2478. end
  2479.  
  2480.  
  2481.  
  2482.  
  2483.  
  2484.  
  2485. ---------------
  2486. -- Achievements
  2487. ---------------
  2488.  
  2489. -- Fancy achievement FX
  2490. local sx,sy = guiGetScreenSize()
  2491. local gMe = getLocalPlayer()
  2492. local achievement = {}
  2493.  
  2494. addEventHandler("onClientResourceStart",resourceRoot,function()
  2495.     achievement.width = 400
  2496.     achievement.queue = {}
  2497.     achievement.left = "left.png"
  2498.     achievement.left_image = "left_1.png"
  2499.     achievement.left_fade = 255
  2500.     achievement.right = "right.png"
  2501.     achievement.background = "background.png"
  2502. end)
  2503.  
  2504. function showAchievement(locked,text,worth)
  2505.     achievementActive = 1
  2506.     achievement.text = text
  2507.     achievement.worth = tostring(worth)
  2508.     achievement.background = "background.png"
  2509.     achievement.locked = locked
  2510.     achievement.active = true
  2511.     achievement.width = dxGetTextWidth((achievement.locked == true and "Achievement Locked" or "Achievement Unlocked"),2,"default-bold")
  2512.     achievement.fade = 0
  2513.     achievement.step = 10
  2514.     achievement.left_fade = 0
  2515.     achievement.left_step = 10
  2516.     if dxGetTextWidth(tostring(worth) .. "X - " .. text,2,"default-bold") > achievement.width then -- Check for width with the 'X' points, even though they're disabled (might add them later)
  2517.         if dxGetTextWidth(tostring(worth) .. "X - " .. text,2,"default-bold") <= 500 then
  2518.             achievement.width = dxGetTextWidth(tostring(worth) .. "X - " .. text,2,"default-bold")
  2519.         else
  2520.             achievement.width = 500
  2521.            
  2522.         end
  2523.     end
  2524.     playSound("sounds/achievement.mp3",false)
  2525.     achievement.width = achievement.width + 10
  2526.     addEventHandler("onClientRender",root,drawAchievement)
  2527.     achievement.swap = setTimer(function()
  2528.         achievement.left_step = achievement.left_step > 0 and -40 or 40
  2529.     end,2000,0)
  2530.     achievement.timer = setTimer(function()
  2531.         achievement.step = -10
  2532.         achievement.left_step = -10
  2533.         achievement.left_fade = achievement.fade
  2534.     end,7000,1)
  2535. end
  2536. addEvent("showClientAchievement",true)
  2537. addEventHandler("showClientAchievement",root,showAchievement)
  2538.  
  2539. function drawAchievement()
  2540.     local alpha = fade(achievement.fade,achievement.step)
  2541.     if alpha == 0 and achievement.fade > alpha then
  2542.         removeAchievement()
  2543.     end
  2544.     achievement.fade = alpha
  2545.     if achievement.fade == 255 then
  2546.         dxDrawImage((sx/2)-(achievement.width/2)-63,sy-200,64,64,"img/"..achievement.left,0,0,0,tocolor(255,255,255,achievement.fade))
  2547.     end
  2548.     dxDrawImage((sx/2)+(achievement.width/2)-1,sy-200,64,64,"img/"..achievement.right,0,0,0,tocolor(255,255,255,achievement.fade))
  2549.     alpha = fade(achievement.left_fade,achievement.left_step)
  2550.     if alpha == 0 and achievement.left_fade > alpha then
  2551.         achievement.left_image = achievement.left_image == "left_1.png" and "left_2.png" or "left_1.png"
  2552.         achievement.left_step = 40
  2553.     end
  2554.     achievement.left_fade = alpha
  2555.     dxDrawImage((sx/2)-(achievement.width/2)-63,sy-200,64,64,"img/"..achievement.left_image,0,0,0,tocolor(255,255,255,achievement.left_fade))
  2556.     dxDrawImage((sx/2)-(achievement.width/2),sy-200,achievement.width,64,"img/"..achievement.background,0,0,0,tocolor(255,255,255,achievement.fade))
  2557.     dxDrawText((achievement.locked == true and "Achievement Locked" or "Achievement Unlocked") .. "\n"--[[ .. achievement.worth .. "X - " -]].. achievement.text,
  2558.                 (sx/2)-(achievement.width/2),
  2559.                 sy-200,
  2560.                 (sx/2)+(achievement.width/2),
  2561.                 sy-136,
  2562.                 tocolor(255,255,255,achievement.fade),
  2563.                 2,
  2564.                 "default-bold",
  2565.                 "center",
  2566.                 "top",
  2567.                 true,
  2568.                 true)
  2569. end
  2570.  
  2571. function fade(value,step)
  2572.     if step > 0 then
  2573.         if value < 255 then
  2574.             value = value + step
  2575.             if value > 255 then
  2576.                 value = 255
  2577.             end
  2578.         end
  2579.     else
  2580.         if value > 0 then
  2581.             value = value + step
  2582.             if value <= 0 then
  2583.                 value = 0
  2584.             end
  2585.         end
  2586.     end
  2587.     return value
  2588. end
  2589.  
  2590. function removeAchievement()
  2591.     if achievement.swap and isTimer(achievement.swap) then killTimer(achievement.swap) end
  2592.     if achievement.timer and isTimer(achievement.timer) then killTimer(achievement.timer) end
  2593.     removeEventHandler("onClientRender",root,drawAchievement)
  2594.     achievement.active = false
  2595.     if achievement.queue then
  2596.         if achievement.queue[1] then
  2597.             showAchievement(achievement.queue[1][1],achievement.queue[1][2],achievement.queue[1][3])
  2598.             table.remove(achievement.queue,1)
  2599.         end
  2600.     end
  2601.     achievementActive = 0
  2602. end
  2603.  
  2604.  
  2605.  
  2606. -- The actual achievements recording
  2607. function checkAchievementsOnStart(ach1,ach2,ach3,ach4,ach5,ach6,ach7,ach8,ach9,ach10,ach11,ach12,ach13,ach14,ach15,ach16,ach17,ach18,ach19,ach20,ach21,ach22,ach23,ach24,ach25,ach26,ach27,ach28,ach29,ach30,ach31,ach32,ach33,ach34,ach35,ach36,ach37,ach38,ach39,ach40)
  2608.     if ach1 == 1 then setAchievementText(1) end
  2609.     if ach2 == 1 then setAchievementText(2) end
  2610.     if ach3 == 1 then setAchievementText(3) end
  2611.     if ach4 == 1 then setAchievementText(4) end
  2612.     if ach5 == 1 then setAchievementText(5) end
  2613.     if ach6 == 1 then setAchievementText(6) end
  2614.     if ach7 == 1 then setAchievementText(7) end
  2615.     if ach8 == 1 then setAchievementText(8) end
  2616.     if ach9 == 1 then setAchievementText(9) end
  2617.     if ach10 == 1 then setAchievementText(10) end
  2618.     if ach11 == 1 then setAchievementText(11) end
  2619.     if ach12 == 1 then setAchievementText(12) end
  2620.     if ach13 == 1 then setAchievementText(13) end
  2621.     if ach14 == 1 then setAchievementText(14) end
  2622.     if ach15 == 1 then setAchievementText(15) end
  2623.     if ach16 == 1 then setAchievementText(16) end
  2624.     if ach17 == 1 then setAchievementText(17) end
  2625.     if ach18 == 1 then setAchievementText(18) end
  2626.     if ach19 == 1 then setAchievementText(19) end
  2627.     if ach20 == 1 then setAchievementText(20) end
  2628.     if ach21 == 1 then setAchievementText(21) end
  2629.     if ach22 == 1 then setAchievementText(22) end
  2630.     if ach23 == 1 then setAchievementText(23) end
  2631.     if ach24 == 1 then setAchievementText(24) end
  2632.     if ach25 == 1 then setAchievementText(25) end
  2633.     if ach26 == 1 then setAchievementText(26) end
  2634.     if ach27 == 1 then setAchievementText(27) end
  2635.     if ach28 == 1 then setAchievementText(28) end
  2636.     if ach29 == 1 then setAchievementText(29) end
  2637.     if ach30 == 1 then setAchievementText(30) end
  2638.     if ach31 == 1 then setAchievementText(31) end
  2639.     if ach32 == 1 then setAchievementText(32) end
  2640.     if ach33 == 1 then setAchievementText(33) end
  2641.     if ach34 == 1 then setAchievementText(34) end
  2642.     if ach35 == 1 then setAchievementText(35) end
  2643.     if ach36 == 1 then setAchievementText(36) end
  2644.     if ach37 == 1 then setAchievementText(37) end
  2645.     if ach38 == 1 then setAchievementText(38) end
  2646.     if ach39 == 1 then setAchievementText(39) end
  2647.     if ach40 == 1 then setAchievementText(40) end
  2648.  
  2649.     local achcount = 0
  2650.  
  2651.     if ach1 == 1 then achcount = achcount+1 end
  2652.     if ach2 == 1 then achcount = achcount+1 end
  2653.     if ach3 == 1 then achcount = achcount+1 end
  2654.     if ach4 == 1 then achcount = achcount+1 end
  2655.     if ach5 == 1 then achcount = achcount+1 end
  2656.     if ach6 == 1 then achcount = achcount+1 end
  2657.     if ach7 == 1 then achcount = achcount+1 end
  2658.     if ach8 == 1 then achcount = achcount+1 end
  2659.     if ach9 == 1 then achcount = achcount+1 end
  2660.     if ach10 == 1 then achcount = achcount+1 end
  2661.     if ach11 == 1 then achcount = achcount+1 end
  2662.     if ach12 == 1 then achcount = achcount+1 end
  2663.     if ach13 == 1 then achcount = achcount+1 end
  2664.     if ach14 == 1 then achcount = achcount+1 end
  2665.     if ach15 == 1 then achcount = achcount+1 end
  2666.     if ach16 == 1 then achcount = achcount+1 end
  2667.     if ach17 == 1 then achcount = achcount+1 end
  2668.     if ach18 == 1 then achcount = achcount+1 end
  2669.     if ach19 == 1 then achcount = achcount+1 end
  2670.     if ach20 == 1 then achcount = achcount+1 end
  2671.     if ach21 == 1 then achcount = achcount+1 end
  2672.     if ach22 == 1 then achcount = achcount+1 end
  2673.     if ach23 == 1 then achcount = achcount+1 end
  2674.     if ach24 == 1 then achcount = achcount+1 end
  2675.     if ach25 == 1 then achcount = achcount+1 end
  2676.     if ach26 == 1 then achcount = achcount+1 end
  2677.     if ach27 == 1 then achcount = achcount+1 end
  2678.     if ach28 == 1 then achcount = achcount+1 end
  2679.     if ach29 == 1 then achcount = achcount+1 end
  2680.     if ach30 == 1 then achcount = achcount+1 end
  2681.     if ach31 == 1 then achcount = achcount+1 end
  2682.     if ach32 == 1 then achcount = achcount+1 end
  2683.     if ach33 == 1 then achcount = achcount+1 end
  2684.     if ach34 == 1 then achcount = achcount+1 end
  2685.     if ach35 == 1 then achcount = achcount+1 end
  2686.     if ach36 == 1 then achcount = achcount+1 end
  2687.     if ach37 == 1 then achcount = achcount+1 end
  2688.     if ach38 == 1 then achcount = achcount+1 end
  2689.     if ach39 == 1 then achcount = achcount+1 end
  2690.     if ach40 == 1 then achcount = achcount+1 end
  2691.     updateUnlockedAchievementsNumberLabel(achcount)
  2692.     callServerFunction("unlockedAchievementsSet",getLocalPlayer(),achcount)
  2693. end
  2694.  
  2695.  
  2696. -- Check for unlocked achievements on client resource start and unlock them in the userpanel
  2697. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),
  2698. function ()
  2699.     callServerFunction("achievement23",getLocalPlayer()) -- Checking for the 23rd achievement
  2700.     callServerFunction("checkAchievementsOnStart",getLocalPlayer())
  2701. end)
  2702.  
  2703. function setAchievementText(row)
  2704.     guiGridListSetItemText (gridAchievements,row-1,1,achievements[row],false,false)
  2705.     guiGridListSetItemColor(gridAchievements,row-1,1,100,255,60,255)
  2706. end
  2707.  
  2708.  
  2709. -- Main function for unlocking achievements
  2710. function unlockAchievement(achievementNumber)
  2711.     if achievementActive == 0 then  -- If the achievement pop-up is NOT active, unlock the achievement
  2712.         local achievementName = achievements[achievementNumber]
  2713.         showAchievement(false,achievementName,1)
  2714.         guiGridListSetItemText (gridAchievements,achievementNumber-1,1,achievements[achievementNumber],false,false)
  2715.         guiGridListSetItemColor(gridAchievements,achievementNumber-1,1,100,255,60,255)
  2716.         callServerFunction("displayFancyUnlockText",getLocalPlayer(),achievements[achievementNumber])
  2717.         callServerFunction("achievement40",getLocalPlayer())
  2718.     else
  2719.         achievementTimer(achievementNumber) -- Call a function to check for the achievement pop-up again after 2 seconds
  2720.     end
  2721. end
  2722. function achievementTimer(achievementNumber)
  2723.     setTimer(unlockAchievement,2000,1,achievementNumber)
  2724. end
  2725.  
  2726. -- Displays the achievement information on the labels
  2727. function updateAchievementDetailsLabel()
  2728.     local row,column = guiGridListGetSelectedItem(gridAchievements)
  2729.     local checkLocked = guiGridListGetItemText(gridAchievements,row,1)
  2730.     if not (checkLocked == "   -- Locked --") then
  2731.         local achname = achievements[row+1]
  2732.         local details = guiGridListGetItemData(gridAchievements,row,1)
  2733.         guiSetText(lblAchievementNameText,achname)
  2734.         guiSetText(lblUnlockConditionText,details)
  2735.     else
  2736.         local achnameLocked = "-- Locked --"
  2737.         local detailsLocked = "-- Locked --"
  2738.         guiSetText(lblAchievementNameText,achnameLocked)
  2739.         guiSetText(lblUnlockConditionText,detailsLocked)
  2740.     end
  2741. end
  2742.  
  2743.  
  2744. function updateUnlockedAchievementsNumberLabel(unlockedNumber)
  2745.     guiSetText(lblAchievementsUnlockedTab,"Achievements unlocked: "..unlockedNumber.."/40")
  2746.     guiSetText(lblAchievementsUnlocked,"Achievements unlocked: "..unlockedNumber.."/40")
  2747. end
  2748.  
  2749.  
  2750. -- This part is for the fake unlock command :)
  2751. function fakeUnlock(message)
  2752.     showAchievement(false,message,1)
  2753. end
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761. -----------------------
  2762. -- Display static image
  2763. -----------------------
  2764.  
  2765. function displayLogo()
  2766.     guiCreateStaticImage(0.57, 0, 0.43, 0.1333, 'img/url.png', true, nil)
  2767.     NavmanPlate = guiCreateStaticImage(0, 0.751666666666, 0.22125, 0.248333333333, 'img/radar.png', false, nil)
  2768.     guiMoveToBack( NavmanPlate )
  2769. end
  2770.  
  2771. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),displayLogo)
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777. --------------------------------
  2778. -- Custom hunter model & texture
  2779. --------------------------------
  2780.  
  2781. function hunterReplace()
  2782.     if useHunterSkin == true then
  2783.         hunterTexture = engineLoadTXD ( "model/hunter.txd" )
  2784.         engineImportTXD ( hunterTexture, 425 )
  2785.         hunterModel = engineLoadDFF ( "model/hunter.dff", 425 )
  2786.         engineReplaceModel ( hunterModel, 425 )
  2787.     end
  2788. end
  2789.  
  2790. addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), hunterReplace)
  2791.  
  2792.  
  2793.  
  2794.  
  2795.  
  2796.  
  2797. ------------------------------------------
  2798. -- Calling function from the client's side
  2799. ------------------------------------------
  2800.  
  2801. function callClientFunction(funcname, ...)
  2802.     local arg = { ... }
  2803.     if (arg[1]) then
  2804.         for key, value in next, arg do arg[key] = tonumber(value) or value end
  2805.     end
  2806.     loadstring("return "..funcname)()(unpack(arg))
  2807. end
  2808. addEvent("onServerCallsClientFunction", true)
  2809. addEventHandler("onServerCallsClientFunction", resourceRoot, callClientFunction)
  2810.  
  2811.  
  2812.  
  2813.  
  2814.  
  2815.  
  2816.  
  2817. -----------------------
  2818. -- Call server function
  2819. -----------------------
  2820.  
  2821. function callServerFunction(funcname, ...)
  2822.     local arg = { ... }
  2823.     if (arg[1]) then
  2824.         for key, value in next, arg do
  2825.             if (type(value) == "number") then arg[key] = tostring(value) end
  2826.         end
  2827.     end
  2828.     triggerServerEvent("onClientCallsServerFunction", resourceRoot , funcname, unpack(arg))
  2829. end
  2830.  
  2831.  
  2832.  
  2833.  
  2834.  
  2835. -----------------
  2836. -- Betting system
  2837. -----------------
  2838.  
  2839. function addNewBet(toPlayerName,newAmount)
  2840.     betPlayer = toPlayerName
  2841.     betAmount = newAmount
  2842.     oldAmount = newAmount
  2843. end
  2844.  
  2845. function triggerBettingSystem(thePlayer,toPlayer,newAmount)
  2846.     if oldAmount == nil then
  2847.         oldAmount = 0
  2848.     end
  2849.     if betPlayer == "none" then
  2850.         local betState = 0
  2851.         callServerFunction("createNewBet",thePlayer,toPlayer,newAmount,oldAmount,betState)
  2852.     else
  2853.         local betState = getPlayerName(betPlayer)
  2854.         callServerFunction("createNewBet",thePlayer,toPlayer,newAmount,oldAmount,betState)
  2855.     end
  2856. end
  2857.  
  2858. function clearData()
  2859.     betPlayer = "none"
  2860.     betAmount = 0
  2861.     oldAmount = 0
  2862. end
  2863.  
  2864. function compareResult(winner)
  2865.     if (winner == betPlayer) then
  2866.         callServerFunction("onPlayerBetWin",getLocalPlayer(),betAmount)
  2867.     end
  2868.     clearData()
  2869. end
  2870.  
  2871.  
  2872.  
  2873. ----------------
  2874. -- Fun functions
  2875. ----------------
  2876.  
  2877. function enableFlyCheat(state)
  2878.     if state == "true" then
  2879.         setWorldSpecialPropertyEnabled("aircars",true)
  2880.     else
  2881.         setWorldSpecialPropertyEnabled("aircars",false)
  2882.     end
  2883. end
  2884.  
  2885.  
  2886. function enableHoverCheat(state)
  2887.     if state == "true" then
  2888.         setWorldSpecialPropertyEnabled("hovercars",true)
  2889.     else
  2890.         setWorldSpecialPropertyEnabled("hovercars",false)
  2891.     end
  2892. end
  2893.  
  2894.  
  2895.  
  2896. -------------
  2897. -- AFK killer
  2898. -------------
  2899.  
  2900. local MaxAFKtime = 50
  2901. local warnTime = 40
  2902. local v = 0
  2903. local AFKtime = 0
  2904. local sx,sy = guiGetScreenSize()
  2905. local wEvent = false
  2906.  
  2907. function rWarn()
  2908.     dxDrawImage( sx/2 - 300, sy/2 - 100, 600, 200, "img/warn.png")
  2909.     dxDrawText("You will be killed in "..tostring(tCount).." seconds",sx/2 - 255, sy/2 + 45,sx,sy,tocolor(1,176,240,255),1.01,"bankgothic")
  2910. end
  2911.  
  2912. function stopWarn()
  2913.     if(wEvent) then
  2914.         removeEventHandler("onClientRender", getRootElement(), rWarn)
  2915.         wEvent = false
  2916.     end
  2917. end
  2918.  
  2919. function imgHandler()
  2920.     stopWarn()
  2921. end
  2922. addEventHandler("onClientPlayerWasted",getLocalPlayer(),imgHandler)
  2923.  
  2924. function checkMain()
  2925.     if isPedInVehicle ( getLocalPlayer() ) then
  2926.         aTimeAdd()
  2927.     end
  2928. end
  2929.  
  2930. function aTimeAdd()
  2931.     AFKtime = AFKtime + 1
  2932.     local isFinished = getElementData ( getLocalPlayer(), "dead")
  2933.     if(isVehicleFrozen ( getPedOccupiedVehicle ( getLocalPlayer() )) and isFinished == false) then
  2934.         aTimeClear()
  2935.     end
  2936.     local isNew = getElementData (getLocalPlayer(), "state")
  2937.     if isNew == "waiting" or isNew == "dead" then
  2938.         aTimeClear()
  2939.     end
  2940.     if(getPedOccupiedVehicle ( getLocalPlayer() ) ~= false) then
  2941.     local player = getLocalPlayer()
  2942.         if(AFKtime >= MaxAFKtime) then
  2943.             if (afkCounter <= 2) then
  2944.                 triggerServerEvent ( "afkWarn", player, 1, afkCounter)
  2945.                 afkCounter = afkCounter+1
  2946.                 triggerServerEvent ( "afkSlap", player)
  2947.                 stopWarn()
  2948.             elseif (afkCounter > 2) then
  2949.                 triggerServerEvent ( "afkWarn", player, 1, afkCounter)
  2950.                 triggerServerEvent ( "afkWarn", player, 2)
  2951.                 afkCounter = 1
  2952.                 triggerServerEvent ( "afkKick", player , player)
  2953.             end
  2954.         elseif(AFKtime >= warnTime) then
  2955.             tCount = tCount - 1
  2956.             if(not wEvent) then
  2957.                 addEventHandler("onClientRender", getRootElement(), rWarn)
  2958.                 wEvent = true
  2959.             end
  2960.         end
  2961.     end
  2962. end
  2963. setTimer ( checkMain, 1000, -1)
  2964.  
  2965.  
  2966. function aTimeClear()
  2967.     AFKtime = 0
  2968.     tCount = 11
  2969.     stopWarn()
  2970. end
  2971.  
  2972. bindKey("accelerate","down",aTimeClear)
  2973. bindKey("vehicle_left","down",aTimeClear)
  2974. bindKey("vehicle_right","down",aTimeClear)
  2975. bindKey("brake_reverse","down",aTimeClear)
  2976.  
  2977.  
  2978. function onClientLoaded(res)
  2979.     triggerServerEvent("onClientLoaded",getLocalPlayer())
  2980. end
  2981. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),onClientLoaded)
  2982.  
  2983.  
  2984. function loadSettings(maxtime, wtime )
  2985.     MaxAFKtime = tonumber(maxtime)
  2986.     warnTime = tonumber(wtime)
  2987. end
  2988. addEvent( "onSettingsReady", true )
  2989. addEventHandler( "onSettingsReady", getRootElement(), loadSettings )
  2990.  
  2991.  
  2992. function setKBA(thePlayer)
  2993.     killedByAfk = 1
  2994. end
  2995.  
  2996. function getKBA(thePlayer)
  2997.     if killedByAfk == 0 then
  2998.         thePlayer = getLocalPlayer()
  2999.         callServerFunction("earnMoney", thePlayer)
  3000.     end
  3001. end
  3002.  
  3003. function deathReset()
  3004.     if killedByAfk == 0 then
  3005.         afkCounter = 1
  3006.     else
  3007.     end
  3008. end
  3009. addEventHandler("onClientPlayerWasted",getLocalPlayer(),deathReset)
  3010.  
  3011. function resetKBA()
  3012.     killedByAfk = 0
  3013. end
  3014.  
  3015.  
  3016.  
  3017.  
  3018. ----------------------
  3019. -- Find player by name
  3020. ----------------------
  3021.  
  3022. function findPlayerByName (name)
  3023.     local player = getPlayerFromName(name)
  3024.     if player then return player end
  3025.     for i, player in ipairs(getElementsByType("player")) do
  3026.         if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then
  3027.             return player
  3028.         end
  3029.     end
  3030. return false
  3031. end
  3032.  
  3033.  
  3034.  
  3035.  
  3036.  
  3037. -------------------------------------
  3038. -- Set the player's element data call
  3039. -------------------------------------
  3040. addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),
  3041. function ()
  3042.     setTimer(callServerFunction,200,1,"setElementDataOnStart",getLocalPlayer())
  3043. end)
  3044.  
  3045.  
  3046.  
  3047.  
  3048.  
  3049.  
  3050.  
  3051.  
  3052. ----------------------
  3053. -- Play various sounds
  3054. ----------------------
  3055. function playWinSound()
  3056.     playSound("sounds/win.mp3")
  3057. end
  3058.  
  3059.  
  3060. ------------------------------------------
  3061. --          Script by NeXTreme          --
  3062. --                                      --
  3063. --                                      --
  3064. --       You've read all of this!?      --
  3065. --                                      --
  3066. ------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment