Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 21st, 2012  |  syntax: Lua  |  size: 86.28 KB  |  hits: 41  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. gRoot = getRootElement()
  2.  
  3. AchievementsName = {
  4. "First Win!", -- 1sze zwyciestwo                        1
  5. "First Hunter!", -- 1szy hunter                         2
  6. "Top Winner!", -- 300 wins                              3
  7. "Awesome Winner!", -- 1000 wins                 4
  8. "Top Gamer!", -- 2000 map                               5
  9. "Long Time Player!", -- 7 dni                           6
  10. "Hunter Owner!", -- hunter 50 razy                      7
  11. "Beat my TT kid!", -- pierwszy TT                       8
  12. "5 Maps In a Row LOL!", -- 5x                           9
  13. "Triple Deathmatch!", -- 3x dm pod rzad                         10
  14. "Triple Dest. Derby!", -- 3x DD                                 11
  15. "Hunter Power", -- hunterfight z 3 graczami                     12
  16. "Map Buyer", -- 10 razy kupic mape                              13
  17. "Top Times collector!", -- 50 toptimow                          14
  18. "Rich player!", -- 1 mln                                        15
  19. "Rich player I", -- 2 mln                                       16
  20. "Hunter Owner I", -- hunter 150 razy                            17
  21. "Top Times collector I", -- 150 toptimow                                18
  22. "Hunter Power I", -- hunterfight z 8 graczami                              19
  23. "King of Points", -- get 1500 Points                                             20
  24. "King of Points I", -- get 500.000 Points                                      21
  25. }
  26.  
  27. LastWinnersDD={"","","","",""}
  28. LastWinnersDM={"","","","",""}
  29. LastWinners={"","","","",""}
  30. HunterCount = 0
  31.  
  32. ------------------------------------------
  33. -- Settings
  34. ------------------------------------------
  35. mapCost = 5000                        -- The price for setting maps.
  36. playerCash = 200000     -- Limits the amount of money you can bet. (playerCash = maxBet)
  37. betTimeLimit = 40               -- Duration of the betting period in seconds.
  38. minPlayers = 1          -- Minimum required players to bet.
  39. buyjant = 50000                         -- Buy Rims,cost 50.000$
  40. skinLevel = 0           -- Minimum level required to buy skins. (3000 Points)
  41. skinCost = 1300                  -- The price of skins.
  42. nametagLevel = 0                      -- Minimum level to buy a nametag color. (2000 Points)
  43. nametagPrice = 2000     -- Price for buying a nametag color.
  44. hornLevel = 0           -- Minimum level to buy different horn styles.
  45. moneyEarnPart = 30              -- The amount of money to calculate with to get the final money to give to the player.
  46.  
  47. function startResource ()
  48.         exports.scoreboard:removeScoreboardColumn("race rank")
  49.         exports.scoreboard:removeScoreboardColumn("checkpoint")
  50.         exports.scoreboard:addScoreboardColumn("Money",gRoot,5,100)
  51.         exports.scoreboard:addScoreboardColumn("Points",gRoot,5,100)
  52.         mapIsAlreadySet = false
  53.         for i,pla in ipairs(getElementsByType("player")) do
  54.                 scoreboardRefresh(pla)
  55.         end
  56. end
  57. addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), startResource )
  58.  
  59. addEventHandler ("onPlayerRaceWasted",getRootElement(),
  60. function()
  61.   killPed (source)
  62.   setElementHealth (source,0)
  63.   if (isPedInVehicle(source)) then
  64.     blowVehicle (getPedOccupiedVehicle(source))
  65.   end
  66. end)
  67.  
  68. -- Prices for each horn
  69. hornPrice={2000,4000,6000,8000,10000,15000,20000}
  70.  
  71. ------------------------------------------
  72. -- Load All Stats on Join
  73. ------------------------------------------
  74. function scoreboardRefresh(thePlayer)
  75.         local playerCash = loadPlayerData(thePlayer,"cash")
  76.         local playerPoint = loadPlayerData(thePlayer,"point")
  77.         setElementData(thePlayer,"Money","$"..playerCash)
  78.         setElementData(thePlayer,"Points",""..playerPoint)
  79.         callClientFunction(thePlayer, "refreshCash", playerCash, playerPoint)
  80. end
  81.  
  82. function playerJoin ( )
  83.         outputChatBox("#00AAFF# #FFFFFFPress '#00AAFFF7#FFFFFF' to open your User Panel#00AAFF!",source,255,255,255,true)
  84.                  outputChatBox("#ecececWelcome,To The #c1ff17??? #ececec24/7 #abcdef[DD/DM] #ecececRace Server. Have Fun During Your Stay!",source,255,255,255,true)
  85.         outputChatBox ( "#ffffffThere are now '#abcdef" .. getPlayerCount() .. "/32#ffffff' players on this server!",source,255,255,255,true )
  86.         scoreboardRefresh(source)
  87. end
  88. addEventHandler ( "onPlayerJoin", gRoot, playerJoin )
  89. addEventHandler ( "onPlayerQuit", getRootElement(), playerJoin )
  90.  
  91. ------------------------------------------
  92. -- DD/DM/FUN checking
  93. ------------------------------------------
  94. addEvent("onMapStarting")
  95. addEventHandler("onMapStarting", getRootElement(),
  96. function(mapInfo, mapOptions, gameOptions)
  97.         CurrentMap = nil
  98.         HunterCount = 0
  99.         MaxI = 0
  100.         for i,thePlayer in ipairs(getElementsByType("player")) do
  101.                 MaxI = i
  102.         end
  103.         if MaxI >=1 then
  104.                 if (checkMapType(mapInfo.name) == 1) then
  105.                         CurrentMap = 1
  106.                         for i,thePlayer in ipairs(getElementsByType("player")) do
  107.                                 local mapsPlayedDM = tonumber(loadPlayerData(thePlayer,"mapsPlayedDM"))
  108.                                 savePlayerData(thePlayer,"mapsPlayedDM", mapsPlayedDM+1)
  109.                                 CheckAchievement(thePlayer,5)
  110.                         end
  111.                 elseif (checkMapType(mapInfo.name) == 2) then
  112.                         CurrentMap = 2
  113.                         for i,thePlayer in ipairs(getElementsByType("player")) do
  114.                                 local mapsPlayedDD = tonumber(loadPlayerData(thePlayer,"mapsPlayedDD"))
  115.                                 savePlayerData(thePlayer,"mapsPlayedDD", mapsPlayedDD+1)
  116.                                 CheckAchievement(thePlayer,5)
  117.                         end
  118.                 end
  119.         else
  120.                 exports.box:outputMiniBox("#FFFFFF Min. 3 players to get #abcdefStats #FFFFFFand #abcdefCash#ececec!",gRoot)
  121.         end
  122. end)
  123.  
  124. function checkMapType(mapname)
  125. if string.find(mapname, "[DM]", 1, true) then
  126.         return 1
  127. elseif string.find(mapname, "[DD]", 1,true) then
  128.         return 2
  129. elseif string.find(mapname, "[FUN]", 1,true) then
  130.         return 3
  131. end
  132. end
  133.  
  134.  
  135. function getRaceAlivePlayers()
  136.         local result = {}
  137.         local _getAlivePlayers = getElementsByType("player")
  138.         for i,v in ipairs(_getAlivePlayers) do
  139.                 if getElementData(v,"state") == "alive" then
  140.                         table.insert(result,v)
  141.                 end
  142.         end
  143.         return result
  144. end
  145.  
  146. ------------------------------------------
  147. -- Wins Stats
  148. ------------------------------------------
  149. function onPlayerDeadInRace()
  150.         local thePlayer = source
  151.         local dPlayers = getDeadRacePlayers()
  152.         local aPlayers = getAliveRacePlayers()
  153.         local Position = aPlayers + 1
  154.         if dPlayers + aPlayers >= 1 then -- Set Minimum Players
  155.                 local cashForPlayer = math.floor((200/Position)*(dPlayers + aPlayers))
  156.                 local pointForPlayer = math.floor((7/Position)*(dPlayers + aPlayers))
  157.                 local playerCash = loadPlayerData(thePlayer,"cash")
  158.                 local playerPoint = loadPlayerData(thePlayer,"point")
  159.                 savePlayerData(thePlayer,"cash",playerCash+cashForPlayer)
  160.                 savePlayerData(thePlayer,"point",playerPoint+pointForPlayer)
  161.                 CheckAchievement(thePlayer,15)
  162.                 CheckAchievement(thePlayer,16)
  163.                 CheckAchievement(thePlayer,20)
  164.                 CheckAchievement(thePlayer,21)
  165.                 scoreboardRefresh(thePlayer)
  166.                 if Position == 1 then
  167.                         outputChatBox("#ffffff "..getPlayerName(thePlayer).." #FFFFFFHas Won The Map Earned $#00AAFF" .. cashForPlayer.. " #ffffffand #00aaff"..pointForPlayer.." #FFFFFFPoints!",gRoot,255,255,255,true)
  168.                         --triggerClientEvent ( "showWinMessage", getRootElement(), thePlayer, cashForPlayer, pointForPlayer)
  169.                        
  170.                                 if LastWinners[1] == "" then
  171.                                         if LastWinners[2] == "" then
  172.                                                 if LastWinners[3] == "" then
  173.                                                         if LastWinners[4] == "" then
  174.                                                                 if LastWinners[5] == "" then
  175.                                                                         LastWinners[5] = thePlayer
  176.                                                                 else
  177.                                                                         LastWinners[4] = thePlayer
  178.                                                                 end
  179.                                                         else
  180.                                                                 LastWinners[3] = thePlayer
  181.                                                         end
  182.                                                 else
  183.                                                         LastWinners[2] = thePlayer
  184.                                                 end
  185.                                         else
  186.                                                 LastWinners[1] = thePlayer
  187.                                         end
  188.                                 else
  189.                                         LastWinners[5] = LastWinners[4]
  190.                                         LastWinners[4] = LastWinners[3]
  191.                                         LastWinners[3] = LastWinners[2]
  192.                                         LastWinners[2] = LastWinners[1]
  193.                                         LastWinners[1] = thePlayer
  194.                                         CheckAchievement(thePlayer,9)
  195.                                 end
  196.                        
  197.                        
  198.                        
  199.                         if CurrentMap and CurrentMap == 1 then
  200.                                 local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM"))
  201.                                 savePlayerData(thePlayer,"mapsWonDM", mapsWonDM+1)
  202.                                 CheckAchievement(thePlayer,1)
  203.                                 CheckAchievement(thePlayer,3)
  204.                                 CheckAchievement(thePlayer,4)
  205.                                 if LastWinnersDM[1] == ""then
  206.                                         if LastWinnersDM[2] == "" then
  207.                                                 if LastWinnersDM[3] == "" then
  208.                                                         LastWinnersDM[3] = thePlayer
  209.                                                 else
  210.                                                         LastWinnersDM[2] = thePlayer
  211.                                                 end
  212.                                         else
  213.                                                 LastWinnersDM[1] = thePlayer
  214.                                         end
  215.                                 else
  216.                                         LastWinnersDM[3] = LastWinnersDM[2]
  217.                                         LastWinnersDM[2] = LastWinnersDM[1]
  218.                                         LastWinnersDM[1] = thePlayer
  219.                                         CheckAchievement(thePlayer,10)
  220.                                 end
  221.                                 if HunterCount >= 3 then
  222.                                         unlockedAC(thePlayer,12)
  223.                                 end
  224.                                 if HunterCount >= 8 then
  225.                                         unlockedAC(thePlayer,19)
  226.                                 end
  227.                         elseif CurrentMap and CurrentMap == 2 then
  228.                                 local mapsWonDD = tonumber(loadPlayerData(thePlayer,"mapsWonDD"))
  229.                                 savePlayerData(thePlayer,"mapsWonDD", mapsWonDD+1)
  230.                                 CheckAchievement(thePlayer,1)
  231.                                 CheckAchievement(thePlayer,3)
  232.                                 CheckAchievement(thePlayer,4)
  233.                                 if LastWinnersDD[1] == "" then
  234.                                         if LastWinnersDD[2] == "" then
  235.                                                 if LastWinnersDD[3] == "" then
  236.                                                         LastWinnersDD[3] = thePlayer
  237.                                                 else
  238.                                                         LastWinnersDD[2] = thePlayer
  239.                                                 end
  240.                                         else
  241.                                                 LastWinnersDD[1] = thePlayer
  242.                                         end
  243.                                 else
  244.                                         LastWinnersDD[3] = LastWinnersDD[2]
  245.                                         LastWinnersDD[2] = LastWinnersDD[1]
  246.                                         LastWinnersDD[1] = thePlayer
  247.                                         CheckAchievement(thePlayer,11)
  248.                                 end
  249.                         end
  250.                 else
  251.                         outputChatBox("#FFFFFFYou Have Recieved $#00AAFF" .. cashForPlayer .. " #FFFFFFand #00aaff" .. pointForPlayer .. " #ffffffPoints!",thePlayer,255,255,255,true)
  252.                 end
  253.         else
  254.                 outputChatBox("#FFFFFF Min. 3 players to get #abcdefStats #FFFFFFand #abcdefCash#ececec!",thePlayer,255,255,255,true)
  255.         end
  256. end
  257. addEvent("onPlayerWasted", true)
  258. addEventHandler("onPlayerWasted", gRoot , onPlayerDeadInRace)
  259.  
  260.  
  261. ------------------------------------------
  262. -- Statystyki
  263. ------------------------------------------
  264. function showStats(thePlayer,CMD,targetPlayer)
  265.         if targetPlayer then
  266.                 if (findPlayerByName(targetPlayer)) then
  267.                         local targetPlayer = findPlayerByName(targetPlayer)
  268.                         local c,p,ddw,ddp,ddr,dmw,dmp,dmr,pt,h,mb,ac,tt = loadPlayerStats(targetPlayer)
  269.                         outputChatBox("#C1FF17# #FFFFFF"..getPlayerName(targetPlayer).."#FFFFFF's Stats:",thePlayer,255,255,255,true)
  270.                         outputChatBox("#00AAFF# [DM] #FFFFFFPlayed: "..dmp.." | Wins: "..dmw.." | Ratio: "..dmr.."%",thePlayer,255,255,255,true)
  271.                         outputChatBox("#00AAFF# [DD] #FFFFFFPlayed: "..ddp.." | Wins: "..ddw.." | Ratio: "..ddr.."%",thePlayer,255,255,255,true)
  272.                         outputChatBox("#00AAFF# #FFFFFFCash: $"..c.." | Points: "..p.." | Hunters: "..h.." | Map Buys: "..mb,thePlayer,255,255,255,true)
  273.                         outputChatBox("#00AAFF# #FFFFFFPlayed Time: "..convertTime(pt),thePlayer,255,255,255,true)
  274.                         ACCOUNT = 0
  275.                         for i=1,#ac do
  276.                                 if ac[i] == 1 then
  277.                                         ACCOUNT = ACCOUNT+1
  278.                                 end
  279.                         end
  280.                         outputChatBox("#00AAFF# #FFFFFFAchievements: "..ACCOUNT.."/21 | TopTimes: "..tt,thePlayer,255,255,255,true)
  281.                 else
  282.                         outputChatBox("#00AAFF# #FFFFFFERROR! The player you specified does not exist!",thePlayer,255,255,255,true)
  283.                 end
  284.         else
  285.                 local c,p,ddw,ddp,ddr,dmw,dmp,dmr,pt,h,mb,ac,tt = loadPlayerStats(thePlayer)
  286.                 outputChatBox("#00AAFF# #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF's stats:",thePlayer,255,255,255,true)
  287.                 outputChatBox("#00AAFF# [DM] #FFFFFFPlayed: "..dmp.." | Wins: "..dmw.." | Ratio: "..dmr.."%",thePlayer,255,255,255,true)
  288.                 outputChatBox("#00AAFF# [DD] #FFFFFFPlayed: "..ddp.." | Wins: "..ddw.." | Ratio: "..ddr.."%",thePlayer,255,255,255,true)
  289.                 outputChatBox("#00AAFF# #FFFFFFCash: $"..c.." | Points: "..p.." | Hunters: "..h.." | Map Buys: "..mb,thePlayer,255,255,255,true)
  290.                 outputChatBox("#00AAFF# #FFFFFFPlayed Time: "..convertTime(pt),thePlayer,255,255,255,true)
  291.                 ACCOUNT = 0
  292.                 for i=1,#ac do
  293.                         if ac[i] == 1 then
  294.                                 ACCOUNT = ACCOUNT+1
  295.                         end
  296.                 end
  297.                 outputChatBox("#00AAFF# #FFFFFFAchievements: "..ACCOUNT.."/21 | TopTimes: "..tt,thePlayer,255,255,255,true)
  298.         end
  299. end
  300. addCommandHandler("stats", showStats)
  301. addCommandHandler("st", showStats)
  302.  
  303. ------------------------------------------
  304. -- Shaders
  305. ------------------------------------------
  306.  
  307. function ShadersUpdate(Who,Shader,Data)
  308.         savePlayerData(Who,"Shader"..Shader,Data)
  309. end
  310. function ClientStarted ( who )
  311.         for i=1,2 do
  312.                 local data = loadPlayerData(who,"Shader"..i)
  313.                 if i == 1 then callClientFunction(who,"CarShaderToggle",who,data)
  314.                 elseif i == 2 then callClientFunction(who,"WaterShaderToggle",who,data)
  315.                 elseif i == 3 then callClientFunction(who,"ShineShaderToogle",who,data)
  316.                 elseif i == 4 then callClientFunction(who,"ContrastShaderToggle",who,data)
  317.                 elseif i == 5 then callClientFunction(who,"SnowShaderToggle",who,data)
  318.                 elseif i == 6 then callClientFunction(who,"GoldShaderToggle",who,data)
  319.                 elseif i == 7 then callClientFunction(who,"SkidmarksShaderToggle",who,data)
  320.                 end
  321.         end
  322. end
  323.  
  324. ------------------------------------------
  325. -- SPD GPD
  326. ------------------------------------------
  327. addCommandHandler("spd",
  328. function(player,command,toplayername,datatype,amount)
  329.         if hasObjectPermissionTo ( player, "function.kickPlayer", false ) then
  330.                 if (toplayername) and (datatype) and (amount) then
  331.                         if datatype == "cash" or datatype == "point" or datatype == "mapsWonDD" or datatype == "mapsPlayedDD" or datatype == "mapsWonDM" or datatype == "mapsPlayedDM" or datatype == "playedTime" or datatype == "hunters" or datatype == "mapBuys" then
  332.                                 if (findPlayerByName (toplayername)) then
  333.                                         toplayer = findPlayerByName (toplayername)
  334.                                         savePlayerData(toplayer,datatype,amount)
  335.                                         outputChatBox ("#00AAFF# #FFFFFFsetPlayerData: " .. getPlayerName(toplayer) .. " #FF0000|#FFFFFF Player's #00AAFF" .. datatype .. "#FFFFFF Has Been Set To: #00AAFF" .. amount, player,255,0,0,true)
  336.                                         outputChatBox ("#00AAFF# #FFFFFF" .. getPlayerName (player) .. " #FFFFFFHas Set Your #ABCDEF" .. datatype .."#FFFFFF To: #00AAFF" .. amount, toplayer,255,0,0,true)
  337.                                         local playerCash = loadPlayerData(toplayer,"cash")
  338.                                         local playerPoint = loadPlayerData(toplayer,"point")
  339.                                         local playerLevel = loadPlayerData(toplayer,"level")
  340.                                         local thePlayer = toplayer
  341.                                         scoreboardRefresh(thePlayer)
  342.                                 end
  343.                         else
  344.                                 outputChatBox ("#00AAFF# #FF0000ERROR! #FFFFFFDatatype: cash/point/mapsWonDD/mapsPlayedDD/mapsWonDM/mapsPlayedDM/playedTime/hunters/mapBuys",player,255,255,255,true)
  345.                         end
  346.                 else
  347.                 outputChatBox ("#00AAFF# #FF0000ERROR!#FFFFFF Syntax: /setPlayerData [playername] [datatype] [new_amount]",player,255,255,255,true)
  348.                 end
  349.         else
  350.         end
  351. end)
  352.  
  353. addCommandHandler("gpd",
  354. function(player,command,toplayername,datatype)
  355.         if hasObjectPermissionTo ( player, "function.kickPlayer", false ) then
  356.                 if (toplayername) and (datatype) then
  357.                         if datatype == "cash" or datatype == "point" or datatype ==  "mapsWonDD" or datatype == "mapsPlayedDD" or datatype == "mapsWonDM" or datatype == "mapsPlayedDM" or datatype == "playedTime" or datatype == "hunters" or datatype == "mapBuys" then             
  358.                                 if (findPlayerByName (toplayername)) then
  359.                                         toplayer = findPlayerByName (toplayername)
  360.                                         local amount = loadPlayerData(toplayer,datatype)
  361.                                         outputChatBox ("#00AAFF# #FFFFFFgetPlayerData: " .. getPlayerName(toplayer) .. " #FF0000|#FFFFFF " .. datatype .."#FFFFFF: #00AAFF" .. amount,player,255,255,255,true)
  362.                                 end
  363.                         else
  364.                                 outputChatBox ("#00AAFF# #FF0000ERROR! #FFFFFFDatatype: cash/point/mapsWonDD/mapsPlayedDD/mapsWonDM/mapsPlayedDM/playedTime/hunters/mapBuys",player,255,255,255,true)
  365.                         end
  366.                 else
  367.                 outputChatBox ("#00AAFF# #FF0000ERROR!#FFFFFF Syntax: /getPlayerData [playername] [datatype]",player,255,255,255,true)
  368.                 end
  369.         end
  370. end)
  371.  
  372.  
  373. ------------------------------------------
  374. -- loadStats
  375. ------------------------------------------
  376. function loadStats(thePlayer,whoask)
  377.         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  378.         setElementData(thePlayer,"Money","$"..playerCash)
  379.         local playerPoint = tonumber(loadPlayerData(thePlayer,"point"))
  380.         setElementData(thePlayer,"Points",""..playerPoint)
  381.         local mapsWonDD = tonumber(loadPlayerData(thePlayer,"mapsWonDD"))
  382.         local mapsPlayedDD = tonumber(loadPlayerData(thePlayer,"mapsPlayedDD"))
  383.         local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM"))
  384.         local mapsPlayedDM = tonumber(loadPlayerData(thePlayer,"mapsPlayedDM"))
  385.                  local totalBets = tonumber(loadPlayerData(thePlayer,"totalBets"))
  386.         local totalBetsEarned = tonumber(loadPlayerData(thePlayer,"totalBetsEarned"))
  387.         local totalBetsWon = tonumber(loadPlayerData(thePlayer,"totalBetsWon"))
  388.         ------ playedTime
  389.                 local PlayerCheckTime = getTickCount ()
  390.                 local PlayerTodayTime = math.floor((PlayerCheckTime - getElementData(thePlayer,"joinTime"))/1000)
  391.                 local PlayerOldTime = loadPlayerData(thePlayer,"playedTime")
  392.                 savePlayerData(thePlayer,"playedTime", PlayerOldTime + PlayerTodayTime)
  393.                 CheckAchievement(thePlayer,6)
  394.                 setElementData(thePlayer,"joinTime", PlayerCheckTime)
  395.         ------
  396.         local playedTime = PlayerOldTime + PlayerTodayTime
  397.         local hunters = tonumber(loadPlayerData(thePlayer,"hunters"))  
  398.         local mapBuys = tonumber(loadPlayerData(thePlayer,"mapBuys"))
  399.         AC = {}
  400.         for i=1,15 do
  401.                 AC[i] = tonumber(loadPlayerData(thePlayer,"ac"..i))
  402.         end
  403.         local toptimes = tonumber(loadPlayerData(thePlayer,"TopTimes"))
  404.         --[[UData = {}
  405.         for j=1,20 do
  406.                 UData[j] = loadPlayerData(thePlayer,"ud"..j)
  407.         end]]--
  408.        
  409.        
  410.         local winRatioDD = 0
  411.         local winRatioDM = 0
  412.         if mapsPlayedDD == 0 and mapsWonDD == 0 then
  413.                 winRatioDD = 0
  414.         elseif mapsPlayedDD ~= 0 and mapsWonDD == 0 then
  415.                 winRatioDD = 0
  416.         elseif mapsPlayedDD ~= 0 and mapsWonDD ~= 0 then
  417.                 winRatioDD = math.round(((100/mapsPlayedDD)*mapsWonDD),2)
  418.         elseif mapsWonDD > mapsPlayedDD then
  419.                 winRatioDD = 0
  420.         end
  421.         if mapsPlayedDM == 0 and mapsWonDM == 0 then
  422.                 winRatioDM = 0
  423.         elseif mapsPlayedDM ~= 0 and mapsWonDM == 0 then
  424.                 winRatioDM = 0
  425.         elseif mapsPlayedDM ~= 0 and mapsWonDM ~= 0 then
  426.                 winRatioDM = math.round(((100/mapsPlayedDM)*mapsWonDM),2)
  427.         elseif mapsWonDM > mapsPlayedDM then
  428.                 winRatioDM = 0
  429.         end
  430.         callClientFunction(whoask, "refreshPanelData", thePlayer ,playerCash, playerPoint, mapsWonDD, mapsPlayedDD, winRatioDD, mapsWonDM, mapsPlayedDM, winRatioDM, playedTime, hunters, mapBuys, AC, toptimes, totalBets, totalBetsEarned, totalBetsWon)
  431. end
  432.  
  433. function loadPlayerStats(thePlayer)
  434.         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  435.         setElementData(thePlayer,"Money","$"..playerCash)
  436.         local playerPoint = tonumber(loadPlayerData(thePlayer,"point"))
  437.         setElementData(thePlayer,"Points"..playerPoint)
  438.         local mapsWonDD = tonumber(loadPlayerData(thePlayer,"mapsWonDD"))
  439.         local mapsPlayedDD = tonumber(loadPlayerData(thePlayer,"mapsPlayedDD"))
  440.         local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM"))
  441.         local mapsPlayedDM = tonumber(loadPlayerData(thePlayer,"mapsPlayedDM"))
  442.                  local totalBets = tonumber(loadPlayerData(thePlayer,"totalBets"))
  443.         local totalBetsEarned = tonumber(loadPlayerData(thePlayer,"totalBetsEarned"))
  444.         local totalBetsWon = tonumber(loadPlayerData(thePlayer,"totalBetsWon"))
  445.         local playedTime = tonumber(loadPlayerData(thePlayer,"playedTime"))    
  446.         local hunters = tonumber(loadPlayerData(thePlayer,"hunters"))  
  447.         local mapBuys = tonumber(loadPlayerData(thePlayer,"mapBuys"))  
  448.         AC = {}
  449.         for i=1,15 do
  450.                 local name = "ac"..i
  451.                 AC[i] = tonumber(loadPlayerData(thePlayer,name))
  452.         end
  453.         local toptimes = tonumber(loadPlayerData(thePlayer,"TopTimes"))
  454.        
  455.         local winRatioDD = 0
  456.         local winRatioDM = 0
  457.         if mapsPlayedDD == 0 and mapsWonDD == 0 then
  458.                 winRatioDD = 0
  459.         elseif mapsPlayedDD ~= 0 and mapsWonDD == 0 then
  460.                 winRatioDD = 0
  461.         elseif mapsPlayedDD ~= 0 and mapsWonDD ~= 0 then
  462.                 winRatioDD = math.round(((100/mapsPlayedDD)*mapsWonDD),2)
  463.         elseif mapsWonDD > mapsPlayedDD then
  464.                 winRatioDD = 0
  465.         end
  466.         if mapsPlayedDM == 0 and mapsWonDM == 0 then
  467.                 winRatioDM = 0
  468.         elseif mapsPlayedDM ~= 0 and mapsWonDM == 0 then
  469.                 winRatioDM = 0
  470.         elseif mapsPlayedDM ~= 0 and mapsWonDM ~= 0 then
  471.                 winRatioDM = math.round(((100/mapsPlayedDM)*mapsWonDM),2)
  472.         elseif mapsWonDM > mapsPlayedDM then
  473.                 winRatioDM = 0
  474.         end
  475.         return playerCash, playerPoint, mapsWonDD, mapsPlayedDD, winRatioDD, mapsWonDM, mapsPlayedDM, winRatioDM, playedTime, hunters, mapBuys, AC, toptimes, totalBets, totalBetsEarned, totalBetsWon
  476. end
  477.  
  478. --[[function NewUserDataFromPanel(ud,thePlayer)
  479.         for i=1,20 do
  480.                 savePlayerData (thePlayer,"ud"..i,ud[i])
  481.         end
  482. end
  483.  
  484. function getUserStats(whoask,who)
  485.         UData = {}
  486.         for j=1,20 do
  487.                 UData[j] = loadPlayerData(who,"ud"..j)
  488.         end
  489.         callClientFunction(whoask,"UserStats",UData)
  490. end]]--
  491. ------------------------------------------
  492. -- Load & Save Data
  493. ------------------------------------------
  494. function loadPlayerData (player,datatype)
  495.   local playerSerial = getPlayerSerial (player)
  496.   if (playerSerial) then
  497.     local root = xmlLoadFile ("DataBase.xml")
  498.     if (root) then
  499.       local usersNode = xmlFindChild (root,"user",0)
  500.       if (usersNode) then
  501.         local playerRootNode = xmlFindChild (usersNode,"SERIAL_" .. playerSerial,0)
  502.         if not (playerRootNode == false) then
  503.           local playerData = xmlNodeGetAttribute (playerRootNode,datatype)
  504.           if (playerData) then
  505.             xmlUnloadFile (root)
  506.                         --outputDebugString("---- LoadD: "..getPlayerName(player).."   ,   "..datatype.."   ,   "..playerData)
  507.             return playerData
  508.           else
  509.             xmlNodeSetAttribute (playerRootNode,datatype,0)
  510.             xmlSaveFile (root)
  511.             xmlUnloadFile (root)
  512.                         --outputDebugString("---- LoadD: "..getPlayerName(player).."   ,   "..datatype.."   ,   0")
  513.             return 0           
  514.           end
  515.         else
  516.           local playerRootNode = xmlCreateChild (usersNode,"SERIAL_" .. playerSerial)
  517.           xmlNodeSetAttribute (playerRootNode,datatype,0)
  518.           xmlSaveFile (root)
  519.           xmlUnloadFile (root)
  520.                   --outputDebugString("---- LoadD: "..getPlayerName(player).."   ,   "..datatype.."   ,   0")
  521.           return 0
  522.         end
  523.       end
  524.     end
  525.   end
  526. end
  527.  
  528. function savePlayerData (player,datatype,newvalue)
  529.   local playerSerial = getPlayerSerial (player)
  530.   if (playerSerial) then
  531.     local root = xmlLoadFile ("DataBase.xml")
  532.     if (root) then
  533.       local usersNode = xmlFindChild (root,"user",0)
  534.       if (usersNode) then
  535.         local playerRootNode = xmlFindChild (usersNode,"SERIAL_" .. playerSerial,0)
  536.         if not (playerRootNode == false) then
  537.           local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue)
  538.           xmlSaveFile (root)
  539.           xmlUnloadFile (root)
  540.                   --outputDebugString("---- SaveD: "..getPlayerName(player).."   ,   "..datatype.."   ,   "..newvalue)
  541.           return newNodeValue
  542.         else
  543.           local playerRootNode = xmlCreateChild (usersNode,"SERIAL_" .. playerSerial)
  544.           local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue)
  545.           xmlSaveFile (root)
  546.           xmlUnloadFile (root)
  547.                   --outputDebugString("---- SaveD: "..getPlayerName(player).."   ,   "..datatype.."   ,   "..newvalue)
  548.           return newNodeValue
  549.         end
  550.       end
  551.     end
  552.   end
  553. end
  554. ------------------------------------------
  555. -- Achievementy
  556. ------------------------------------------
  557.  
  558. function CheckAchievement(thePlayer,achiev)
  559.         local name = "ac"..achiev
  560.         local LockedUnlocked = tonumber(loadPlayerData(thePlayer,name))
  561.         if LockedUnlocked == 0 then
  562.                 if achiev == 1 then -- 1st win
  563.                         local mapsWonDD = tonumber(loadPlayerData(thePlayer,"mapsWonDD"))
  564.                         local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM"))
  565.                         if mapsWonDD > 0 or mapsWonDM > 0 then
  566.                                 unlockedAC(thePlayer,achiev)
  567.                         end
  568.                 elseif achiev == 2 then -- 1st hunter
  569.                         local hunters = tonumber(loadPlayerData(thePlayer,"hunters"))
  570.                         if hunters > 0 then
  571.                                 unlockedAC(thePlayer,achiev)
  572.                         end
  573.                 elseif achiev == 3 then -- 300+ wins
  574.                         local mapsWonDD = tonumber(loadPlayerData(thePlayer,"mapsWonDD"))
  575.                         local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM"))
  576.                         if mapsWonDD + mapsWonDM >= 300 then
  577.                                 unlockedAC(thePlayer,achiev)
  578.                         end
  579.                 elseif achiev == 4 then -- 1000+wins
  580.                         local mapsWonDD = tonumber(loadPlayerData(thePlayer,"mapsWonDD"))
  581.                         local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM"))
  582.                         if mapsWonDD + mapsWonDM >= 1000 then
  583.                                 unlockedAC(thePlayer,achiev)
  584.                         end
  585.                 elseif achiev == 5 then -- 2000 played
  586.                         local mapsPlayedDD = tonumber(loadPlayerData(thePlayer,"mapsPlayedDD"))
  587.                         local mapsPlayedDM = tonumber(loadPlayerData(thePlayer,"mapsPlayedDM"))
  588.                         if mapsPlayedDD + mapsPlayedDM >= 2000 then
  589.                                 unlockedAC(thePlayer,achiev)
  590.                         end
  591.                 elseif achiev == 6 then -- 7days
  592.                         local playedTime = tonumber(loadPlayerData(thePlayer,"playedTime"))
  593.                         if playedTime >= 604800 then
  594.                                 unlockedAC(thePlayer,achiev)
  595.                         end
  596.                 elseif achiev == 7 then -- 50+ hunters
  597.                         local hunters = tonumber(loadPlayerData(thePlayer,"hunters"))
  598.                         if hunters >= 50 then
  599.                                 unlockedAC(thePlayer,achiev)
  600.                         end
  601.                 elseif achiev == 8 then--beat TT
  602.                         local toptimes = tonumber(loadPlayerData(thePlayer,"TopTimes"))
  603.                         if toptimes > 0 then
  604.                                 unlockedAC(thePlayer,achiev)
  605.                         end    
  606.                 elseif achiev == 9 then-- 5x in a row
  607.                         if LastWinners[1] == thePlayer and LastWinners[2] == thePlayer and LastWinners[3] == thePlayer and LastWinners[4] == thePlayer and LastWinners[5] == thePlayer then
  608.                                 unlockedAC(thePlayer,achiev)
  609.                         end
  610.                 elseif achiev == 10 then --3x DM
  611.                         if LastWinnersDM[1] == thePlayer and LastWinnersDM[2] == thePlayer and LastWinnersDM[3] == thePlayer then
  612.                                 unlockedAC(thePlayer,achiev)
  613.                         end
  614.                 elseif achiev == 11 then --3x DD
  615.                         if LastWinnersDD[1] == thePlayer and LastWinnersDD[2] == thePlayer and LastWinnersDD[3] == thePlayer then
  616.                                 unlockedAC(thePlayer,achiev)
  617.                         end
  618.                 elseif achiev == 13 then --10x mapbuy
  619.                         local mapBuys = tonumber(loadPlayerData(thePlayer,"mapBuys"))
  620.                         if mapBuys >= 10 then
  621.                                 unlockedAC(thePlayer,achiev)
  622.                         end                    
  623.                 elseif achiev == 14 then --50 toptimow
  624.                         local toptimes = tonumber(loadPlayerData(thePlayer,"TopTimes"))
  625.                         if toptimes >= 50 then
  626.                                 unlockedAC(thePlayer,achiev)
  627.                         end    
  628.                 elseif achiev == 15 then --1mln
  629.                         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  630.                         if playerCash >= 1000000 then
  631.                                 unlockedAC(thePlayer,achiev)
  632.                         end    
  633.                 elseif achiev == 16 then --2mln
  634.                         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  635.                         if playerCash >= 2000000 then
  636.                                 unlockedAC(thePlayer,achiev)
  637.                                                   end
  638.                 elseif achiev == 17 then --150+ hunters
  639.                         local hunters = tonumber(loadPlayerData(thePlayer,"hunters"))
  640.                         if hunters >= 150 then
  641.                                 unlockedAC(thePlayer,achiev)
  642.                         end                    
  643.                 elseif achiev == 18 then --150 toptimow
  644.                         local toptimes = tonumber(loadPlayerData(thePlayer,"TopTimes"))
  645.                         if toptimes >= 150 then
  646.                                 unlockedAC(thePlayer,achiev)   
  647.                         end                    
  648.                 elseif achiev == 20 then --1500 points
  649.                         local playerPoint = tonumber(loadPlayerData(thePlayer,"point"))
  650.                         if playerPoint >= 1500 then
  651.                                 unlockedAC(thePlayer,achiev)
  652.                         end                    
  653.                 elseif achiev == 21 then --500.000 points
  654.                         local playerPoint = tonumber(loadPlayerData(thePlayer,"point"))
  655.                         if playerPoint >= 500000 then
  656.                                 unlockedAC(thePlayer,achiev)           
  657.                         end    
  658.                 end
  659.         else
  660.                 if achiev == 15 then
  661.                         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  662.                         if playerCash < 1000000 then
  663.                                 savePlayerData(thePlayer,"ac"..achiev,0)
  664.                         end    
  665.                 elseif achiev == 16 then
  666.                         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  667.                         if playerCash < 2000000 then
  668.                                 savePlayerData(thePlayer,"ac"..achiev,0)
  669.                         end
  670.                 elseif achiev == 20 then
  671.                         local playerPoint = tonumber(loadPlayerData(thePlayer,"point"))
  672.                         if playerPoint < 1500 then
  673.                                 savePlayerData(thePlayer,"ac"..achiev,0)
  674.                         end
  675.                 elseif achiev == 21 then
  676.                         local playerPoint = tonumber(loadPlayerData(thePlayer,"point"))
  677.                         if playerPoint < 500000 then
  678.                                 savePlayerData(thePlayer,"ac"..achiev,0)
  679.                         end
  680.                 elseif achiev == 13 then
  681.                         local mapBuys = tonumber(loadPlayerData(thePlayer,"mapBuys"))
  682.                         if mapBuys <= 10 then
  683.                                 unlockedAC(thePlayer,achiev)
  684.                         end    
  685.                 end
  686.         end
  687. end
  688.  
  689. function unlockedAC(thePlayer,achiev)
  690.         callClientFunction(thePlayer,"unlockAChievement", achiev)
  691.         outputChatBox("#FFFFFFAC: #00AAFF"..getPlayerName(thePlayer).."#FFFFFF Has Unlocked An Achievement!",getRootElement(),255,255,255,true)
  692.         outputChatBox("#FFFFFFAC: #00AAFF"..AchievementsName[achiev],getRootElement(),255,255,255,true)
  693.         savePlayerData(thePlayer,"ac"..achiev,1)
  694. end
  695.  
  696. addEvent("onPlayerToptimeImprovement",true)
  697. addEventHandler("onPlayerToptimeImprovement",getRootElement(),
  698. function (player)
  699.         local totalToptimes = tonumber(loadPlayerData(source,"TopTimes"))
  700.         savePlayerData(source,"TopTimes",totalToptimes+1)
  701.         CheckAchievement(source,8)
  702.         CheckAchievement(source,14)
  703.         CheckAchievement(source,18)
  704. end)
  705.  
  706. ------------------------------------------------
  707. -- Set headlights on map start and on veh-change
  708. ------------------------------------------------
  709.  
  710. function setPlayerHeadlightColor(number, sort, model)
  711.         if sort == "vehiclechange" then
  712.                 local hlcRed = getElementData(source,"hlcRed")
  713.                 local hlcGreen = getElementData(source,"hlcGreen")
  714.                 local hlcBlue = getElementData(source,"hlcBlue")
  715.                 if (hlcRed) and (hlcGreen) and (hlcBlue) then
  716.                         local car = getPedOccupiedVehicle(source)
  717.                         setVehicleHeadLightColor(car,hlcRed,hlcGreen,hlcBlue)
  718.                         --outputChatBox("Data sucessfully retrieved, headlights color has been set!",getRootElement(),0,255,0)
  719.                 else
  720.                 end
  721.         end
  722. end
  723.  
  724. function setPlayerHeadlightColor2()
  725.         local hlcRed = getElementData(source,"hlcRed")
  726.         local hlcGreen = getElementData(source,"hlcGreen")
  727.         local hlcBlue = getElementData(source,"hlcBlue")
  728.         if (hlcRed) and (hlcGreen) and (hlcBlue) then
  729.                 local car = getPedOccupiedVehicle(source)
  730.                 setVehicleHeadLightColor(car,hlcRed,hlcGreen,hlcBlue)
  731.                 --outputChatBox("Data sucessfully retrieved, headlights color has been set!",getRootElement(),0,255,0)
  732.         else
  733.         end
  734. end
  735. addEvent("onNotifyPlayerReady", true)
  736. addEventHandler("onNotifyPlayerReady", getRootElement(), setPlayerHeadlightColor2)
  737. addEventHandler("onPlayerPickUpRacePickup",getRootElement(),setPlayerHeadlightColor)
  738.  
  739. ------------------
  740. -- Save headlights
  741. ------------------
  742.  
  743. function saveHeadlights ( thePlayer, colorRed, colorGreen, colorBlue )
  744.         --outputChatBox("SERVER: Event triggered! Saving headlights...")
  745.         local red = colorRed
  746.         local green = colorGreen
  747.         local blue = colorBlue
  748.         local car = getPedOccupiedVehicle(thePlayer)
  749.         setVehicleHeadLightColor(car,red,green,blue)
  750.         savePlayerData(thePlayer,"hlcRed",red)
  751.         savePlayerData(thePlayer,"hlcGreen",green)
  752.         savePlayerData(thePlayer,"hlcBlue",blue)
  753.         setElementData(thePlayer,"hlcRed",red)
  754.         setElementData(thePlayer,"hlcGreen",green)
  755.         setElementData(thePlayer,"hlcBlue",blue)
  756.         outputChatBox("#0095FF* #FFFFFFYour data has been saved!",thePlayer,255,255,255,true)
  757.         --outputChatBox("SERVER: Account found! Data has been saved.")
  758. end
  759. addEvent("saveHeadlights", true)
  760. addEventHandler("saveHeadlights", getRootElement(), saveHeadlights)
  761.  
  762. ---------------------
  763. -- Save vehicle color
  764. ---------------------
  765.  
  766. function saveVehColor(player,c1,c2,c3,c4)
  767.         savePlayerData(player,"c1",c1)
  768.         savePlayerData(player,"c2",c2)
  769.         savePlayerData(player,"c3",c3)
  770.         savePlayerData(player,"c4",c4)
  771.         setElementData(player,"c1",c1)
  772.         setElementData(player,"c2",c2)
  773.         setElementData(player,"c3",c3)
  774.         setElementData(player,"c4",c4)
  775. end
  776.  
  777.  
  778. root = getRootElement()
  779.  
  780. function executecolor(c1,c2,c3,c4)
  781.         carcolor(source,true,c1,c2,c3,c4)
  782. end
  783.  
  784. function executealpha(player,_,alpha)
  785.         alpha = alpha or 255
  786.         setElementAlpha(getPedOccupiedVehicle(player),tonumber(alpha))
  787. end
  788.  
  789. function carcolor(thePlayer,_,arg1,arg2,arg3,arg4)
  790.         local vehicle = getPedOccupiedVehicle(thePlayer)
  791.         if (vehicle) then
  792.                 local old,old2,old3,old4=getVehicleColor(vehicle)
  793.                 local arg11,arg22,arg33,arg44=tonumber(arg1),tonumber(arg2) or old2,tonumber(arg3) or old3,tonumber(arg4) or old4
  794.                 setVehicleColor(vehicle,arg11,arg22,arg33,arg44)
  795.                 outputChatBox("#0095FF* #FFFFFFYour data has been saved!",thePlayer,255,255,255,true)
  796.                 savePlayerData(thePlayer,"everSetCustomVehicleColor",1)
  797.                 setElementData(thePlayer,"everSetCustomVehicleColor",1)
  798.         else
  799.         end
  800. end
  801.  
  802.  
  803. addEvent("colorchange",true)
  804. addEventHandler("colorchange",root, executecolor)
  805. addEvent("alphachange",true)
  806. addEventHandler("alphachange",root, executealpha)
  807.  
  808. ----------------------------------------------------------
  809. -- Set vehicle color on player-ready and on vehicle change
  810. ----------------------------------------------------------
  811.  
  812. function setPlayerVehicleColor(number, sort, model)
  813.         if sort == "vehiclechange" then
  814.                 local ifSet = tonumber(getElementData(source,"everSetCustomVehicleColor"))
  815.                 if ifSet == 1 then
  816.                         local useColor = tostring(getElementData(source,"useCustomVehicleColor"))
  817.                         if (useColor == "true") then
  818.                                 local c1 = tonumber(getElementData(source,"c1"))
  819.                                 local c2 = tonumber(getElementData(source,"c2"))
  820.                                 local c3 = tonumber(getElementData(source,"c3"))
  821.                                 local c4 = tonumber(getElementData(source,"c4"))
  822.                                 local car = getPedOccupiedVehicle(source)
  823.                                 exc1, exc2, exc3, exc4 = getVehicleColor (car)
  824.                                 if not c1 then c1 = exc1 end
  825.                                 if not c2 then c2 = exc2 end
  826.                                 if not c3 then c3 = exc3 end
  827.                                 if not c4 then c4 = exc4 end
  828.                                 setVehicleColor(car,c1,c2,c3,c4)
  829.                         else
  830.                                 local car = getPedOccupiedVehicle(source)
  831.                                 setVehicleColor(car,math.random(1,126),math.random(1,126),math.random(1,126),math.random(1,126))
  832.                         end
  833.                 else
  834.                         local car = getPedOccupiedVehicle(source)
  835.                         setVehicleColor(car,math.random(1,126),math.random(1,126),math.random(1,126),math.random(1,126))
  836.                 end
  837.         end
  838. end
  839.  
  840.  
  841. function setPlayerVehicleColor2()
  842.         local ifSet = tonumber(getElementData(source,"everSetCustomVehicleColor"))
  843.         if ifSet == 1 then
  844.                 local useColor = tostring(getElementData(source,"useCustomVehicleColor"))
  845.                 if (useColor == "true") then
  846.                         local c1 = tonumber(getElementData(source,"c1"))
  847.                         local c2 = tonumber(getElementData(source,"c2"))
  848.                         local c3 = tonumber(getElementData(source,"c3"))
  849.                         local c4 = tonumber(getElementData(source,"c4"))
  850.                         local car = getPedOccupiedVehicle(source)
  851.                         exc1, exc2, exc3, exc4 = getVehicleColor (car)
  852.                         if not c1 then c1 = exc1 end
  853.                         if not c2 then c2 = exc2 end
  854.                         if not c3 then c3 = exc3 end
  855.                         if not c4 then c4 = exc4 end
  856.                         setVehicleColor(car,c1,c2,c3,c4)
  857.                 else
  858.                         local car = getPedOccupiedVehicle(source)
  859.                         setVehicleColor(car,math.random(1,126),math.random(1,126),math.random(1,126),math.random(1,126))
  860.                 end
  861.         else
  862.                 local car = getPedOccupiedVehicle(source)
  863.                 setVehicleColor(car,math.random(1,126),math.random(1,126),math.random(1,126),math.random(1,126))
  864.         end
  865. end
  866.  
  867. addEventHandler("onNotifyPlayerReady", getRootElement(), setPlayerVehicleColor2)
  868. addEventHandler("onPlayerPickUpRacePickup", getRootElement(), setPlayerVehicleColor)
  869.  
  870. ---------------------------------------------
  871. -- Set most widely used stats as element data
  872. ---------------------------------------------
  873.  
  874. function setElementDataOnStart(source)
  875.  
  876.         thePlayer = source
  877.  
  878.         local a = loadPlayerData(thePlayer,"everPurchasedSkin")
  879.         local b = loadPlayerData(thePlayer,"everPurchasedNametagColor")
  880.         local c = loadPlayerData(thePlayer,"everSetCustomVehicleColor")
  881.         local d = loadPlayerData(thePlayer,"useCustomVehicleColor")
  882.         local e = loadPlayerData(thePlayer,"c1")
  883.         local f = loadPlayerData(thePlayer,"c2")
  884.         local g = loadPlayerData(thePlayer,"c3")
  885.         local h = loadPlayerData(thePlayer,"c4")
  886.         local i = loadPlayerData(thePlayer,"hlcRed")
  887.         local j = loadPlayerData(thePlayer,"hlcGreen")
  888.         local k = loadPlayerData(thePlayer,"hlcBlue")
  889.         local adminredo = loadPlayerData(thePlayer,"admin_redo")
  890.         local adminnextmap = loadPlayerData(thePlayer,"admin_nextmap")
  891.  
  892.         setElementData(thePlayer,"everPurchasedSkin",a)
  893.         setElementData(thePlayer,"everPurchasedNametagColor",b)
  894.         setElementData(thePlayer,"everSetCustomVehicleColor",c)
  895.  
  896.         setElementData(thePlayer,"useCustomVehicleColor",d)
  897.  
  898.         setElementData(thePlayer,"c1",e)
  899.         setElementData(thePlayer,"c2",f)
  900.         setElementData(thePlayer,"c3",g)
  901.         setElementData(thePlayer,"c4",h)
  902.  
  903.         setElementData(thePlayer,"hlcRed",i)
  904.         setElementData(thePlayer,"hlcGreen",j)
  905.         setElementData(thePlayer,"hlcBlue",k)
  906.  
  907.         setElementData(thePlayer,"admin_redo",adminredo)
  908.         setElementData(thePlayer,"admin_nextmap",adminnextmap)
  909. end
  910.  
  911. ------------------------------------------
  912. -- Join - PlayedTime
  913. ------------------------------------------
  914. function PlayedTimeJoin()
  915.         local thePlayer = source
  916.         local PlayerJoinTime = getTickCount ()
  917.         setElementData(thePlayer,"joinTime", PlayerJoinTime)
  918. end
  919. addEventHandler ("onPlayerJoin",getRootElement(), PlayedTimeJoin)
  920.  
  921. function PlayedTimeQuit()
  922.         local thePlayer = source
  923.         local PlayerQuitTime = getTickCount ()
  924.         local PlayerTodayTime = math.floor((PlayerQuitTime - getElementData(thePlayer,"joinTime"))/1000)
  925.         local PlayerOldTime = loadPlayerData(thePlayer,"playedTime")
  926.         savePlayerData(thePlayer,"playedTime", PlayerOldTime + PlayerTodayTime)
  927. end
  928. addEventHandler ("onPlayerQuit",getRootElement(), PlayedTimeQuit)
  929.  
  930. function convertTime(timeinseconds)
  931.         Days = math.floor(timeinseconds/86400)
  932.         timeinseconds = timeinseconds - Days*86400
  933.         Hours =  math.floor(timeinseconds/3600)
  934.         timeinseconds = timeinseconds - Hours*3600
  935.         Minutes =  math.floor(timeinseconds/60)
  936.         timeinseconds = timeinseconds - Minutes*60
  937.         Seconds = timeinseconds
  938.         if Days > 0 then
  939.                 Time = Days.." days "..Hours.."h "..Minutes.."m "..Seconds.."s"
  940.         elseif Hours > 0 then
  941.                 Time = Hours.."h "..Minutes.."m "..Seconds.."s"
  942.         elseif Minutes > 0 then
  943.                 Time = Minutes.."m "..Seconds.."s"
  944.         else
  945.                 Time = Seconds.."s"
  946.         end
  947.         return Time
  948. end
  949.  
  950. ------------------------------------------
  951. -- Hunters
  952. ------------------------------------------
  953. function checkForHunter(number,sort,model)
  954.         thePlayer = source
  955.         if sort == "vehiclechange" then
  956.                 if model == 425 then
  957.                         if getElementData(thePlayer,"playerGotHunter") == false then
  958.                                 setElementData(thePlayer,"playerGotHunter",true)
  959.                                 local oldhunters = loadPlayerData(thePlayer,"hunters")
  960.                                 savePlayerData(thePlayer,"hunters", oldhunters + 1)
  961.                                 CheckAchievement(thePlayer,2)
  962.                                 CheckAchievement(thePlayer,7)
  963.                                 CheckAchievement(thePlayer,17)
  964.                                 HunterCount = HunterCount + 1
  965.                         end
  966.                 end
  967.         end
  968. end
  969. addEventHandler("onPlayerPickUpRacePickup",getRootElement(),checkForHunter)
  970. ----------------------
  971. -- Shop (buy repair/nos...)
  972. ----------------------
  973. function nos()
  974.     if getGameType() == "Race" then
  975.         if isPedInVehicle(source) then
  976.             local playerMoney = loadPlayerData (source,"cash")
  977.             if (tonumber(playerMoney) > 7500) then
  978.                     savePlayerData (source,"cash",loadPlayerData(source,"cash") -25000)
  979.                     addVehicleUpgrade(getPedOccupiedVehicle(source),1010)
  980.             setTimer(outputChatBox,50,1,"#ff6464[SHOP]: #ffffff"..getPlayerName (source) .. " #ffffffhas bought nitro! (#abcdef7500$#ffffff)",getRootElement(),0,136,255,true)
  981.             else               
  982.                     outputChatBox("#0fc0fcYou dont have money for buy this.",source, 0,136,255,true)   
  983.                 end
  984.             else
  985.             outputChatBox("#0fc0fcYou are not in a vehicle.",source,0,136,255,true)
  986.         end            
  987.         else
  988.                 outputChatBox("#0fc0fcYou are not in race mode.",source,0,136,255,true)
  989.         end
  990. end
  991. addCommandHandler("bn",nos)    
  992.  
  993. function repair()
  994.     if getGameType() == "Race" then
  995.         if isPedInVehicle(source) then
  996.         local playerMoney = loadPlayerData (source,"cash")
  997.             if (tonumber(playerMoney) > 3000) then
  998.                 savePlayerData (source,"cash",loadPlayerData(source,"cash") -2500)
  999.             fixVehicle(getPedOccupiedVehicle(source))
  1000.             setTimer(outputChatBox,50,1,"#ff6464[SHOP]: #ffffff"..getPlayerName (source) .. " #ffffffhas bought fix! (#abcdef3000$#ffffff)",getRootElement(),0,136,255,true)
  1001.             else       
  1002.                     outputChatBox("#0fc0fcYou dont have money for buy this.",source, 0,136,255,true)
  1003.                 end
  1004.             else
  1005.             outputChatBox("#0fc0fcYou are not in a vehicle.",source,0,136,255,true)    
  1006.         end
  1007.     else
  1008.            outputChatBox("#0fc0fcYou are not in race mode.",source,0,136,255,true)
  1009.     end
  1010. end    
  1011. addCommandHandler("br",repair) 
  1012.  
  1013. function flip()
  1014.     if getGameType() == "Race" then
  1015.         if isPedInVehicle(source) then
  1016.         local playerMoney = loadPlayerData (source,"cash")
  1017.             if (tonumber(playerMoney) > 3500) then
  1018.                     savePlayerData (source,"cash",loadPlayerData(source,"cash") -2500)
  1019.             rx, ry, rz = getVehicleRotation (getPedOccupiedVehicle(source))            
  1020.             setVehicleRotation (getPedOccupiedVehicle(source), rx +180, ry, rz +180)
  1021.             setTimer(outputChatBox,50,1,"#ff6464[SHOP]: #ffffff"..getPlayerName (source) .. " #ffffffhas bought flip! (#abcdef3500$#ffffff)",getRootElement(),0,136,255,true)
  1022.             else               
  1023.                     outputChatBox("#0fc0fcYou dont have money for buy this.",source, 0,136,255,true)
  1024.                 end
  1025.             else
  1026.            outputChatBox("#0fc0fcYou are not in a vehicle.",source,0,136,255,true)
  1027.         end            
  1028.     else
  1029.     outputChatBox("#0fc0fcYou are not in race mode.",source,0,136,255,true)
  1030.     end        
  1031. end
  1032. addCommandHandler("bf",flip)   
  1033.  
  1034.  
  1035. ----------------------
  1036. -- Roll (spin/flip Comming soon)
  1037. ----------------------
  1038.  
  1039. addEventHandler ("onPlayerChat",getRootElement(),
  1040. function(message,type)
  1041.  if (string.find(message,"!roll")) and not (string.find(message," !roll")) then
  1042.     local playerCash = loadPlayerData (source,"cash")
  1043.     if (tonumber(playerCash) > 100) then
  1044.       if not (rollLimitCheckPlayerIsIn (source)) then
  1045.         savePlayerData (source,"cash",loadPlayerData (source,"cash") -100)
  1046.         local firstRollNumber = math.random (1,4)
  1047.         local secondRollNumber = math.random (0,1000)
  1048.         rollLimitAddPlayer (source)
  1049.         if (firstRollNumber == 1) then
  1050.           setTimer(outputChatBox,500,1,"#ff8800[ROLL]: #ffffff"..getPlayerName( source ).." #ffffffhas rolled and #00ff00won #abcdef[#ffffff" .. tostring (secondRollNumber) .. "$#abcdef]#ffffff!",getRootElement(),0,153,255,true)
  1051.           setTimer(savePlayerData,500,1,source,"cash",loadPlayerData(source,"cash") +secondRollNumber)
  1052.         elseif (firstRollNumber == 2) then
  1053.           setTimer(outputChatBox,500,1,"#ff8800[ROLL]: #ffffff"..getPlayerName( source ).." #ffffffhas rolled and #00ff00won #abcdef[#ffffff" .. tostring (secondRollNumber) .. "$#abcdef]#ffffff!",getRootElement(),0,153,255,true)
  1054.           setTimer(savePlayerData,500,1,source,"cash",loadPlayerData(source,"cash") +secondRollNumber)
  1055.         elseif (firstRollNumber == 3) then
  1056.           setTimer(outputChatBox,500,1,"#ff8800[ROLL]: #ffffff"..getPlayerName( source ).." #ffffffhas rolled and #ff0000lost #abcdef[#ffffff" .. tostring (secondRollNumber) .. "$#abcdef]#ffffff!",getRootElement(),0,153,255,true)
  1057.           setTimer(savePlayerData,500,1,source,"cash",loadPlayerData(source,"cash") -secondRollNumber)
  1058.         elseif (firstRollNumber == 4) then
  1059.           setTimer(outputChatBox,500,1,"#ff8800[ROLL]: #ffffff"..getPlayerName( source ).." #ffffffhas rolled and #ff0000lost #abcdef[#ffffff" .. tostring (secondRollNumber) .. "$#abcdef]#ffffff!",getRootElement(),0,153,255,true)
  1060.           setTimer(savePlayerData,500,1,source,"cash",loadPlayerData(source,"cash") -secondRollNumber)
  1061.         end
  1062.       else
  1063.         outputChatBox ("#0099ffYou only can use !roll once a minute!",source,0,153,255,true)
  1064.         cancelEvent()
  1065.       end
  1066.     else
  1067.       setTimer(outputChatBox,50,1,"#0099ffYou don't have got 100$, you need that before rolling!",source,0,153,255,true)
  1068.     end
  1069.  end
  1070. end)
  1071.  
  1072. rollusers = {}
  1073. function rollLimitCheckPlayerIsIn (player)
  1074.   for i,v in ipairs (rollusers) do
  1075.     if (v == player) then
  1076.       return true
  1077.     end
  1078.   end
  1079. end
  1080.  
  1081. function rollLimitAddPlayer (player)
  1082.   table.insert (rollusers,player)
  1083. end
  1084.  
  1085. function rollLimitCleanUp2 ()
  1086.   for i,v in ipairs (rollusers) do
  1087.     table.remove (rollusers,i)
  1088.   end
  1089. end
  1090.  
  1091. addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
  1092. function()
  1093.   if (rollLimitTimer2) then
  1094.     killTimer (rollLimitTimer2)
  1095.     rollLimitTimer2 = setTimer (rollLimitCleanUp2,60000,0)
  1096.   else
  1097.     rollLimitTimer2 = setTimer (rollLimitCleanUp2,60000,0)
  1098.   end
  1099. end)
  1100.  
  1101.  
  1102.  
  1103.  
  1104. addEventHandler("onPlayerChat", getRootElement(),
  1105. function (text)
  1106.         if string.sub(text, 1, 1) == "!" then
  1107.                 local command = string.gsub(gettok(text, 1, 32), "!", "")
  1108.                 local args = string.gsub(text, "!"..command, "")
  1109.                 executeCommandHandler(command, source, args)
  1110.         end
  1111. end
  1112. )
  1113. ------------------------------------------
  1114. -- Mapy
  1115. ------------------------------------------
  1116.  
  1117. local maps = { }
  1118. for _, map in ipairs ( exports.mapmanager:getMapsCompatibleWithGamemode(exports.mapmanager:getRunningGamemode())) do
  1119.  maps[ getResourceInfo ( map, 'name' ) ] = true;
  1120. end
  1121.  
  1122. function buyMap(thePlayer,mapName)
  1123.  mapName = tostring(mapName)
  1124.  if ( mapName ~= "" ) then
  1125.   if ( maps[mapName] ) then
  1126.    if mapIsAlreadySet == false then
  1127.     local playerCash = tonumber(loadPlayerData(thePlayer,"cash"));
  1128.     if playerCash >= mapCost then
  1129.      executeCommandHandler("pnfnsdhasd3w7432jhdsbw3ersdncsdir",thePlayer,mapName)
  1130.      maps[mapName] = false;
  1131.      setTimer (
  1132.       function ( map )
  1133.        maps[map] = true;
  1134.        outputChatBox ( "#ff6464[MAP]:#ffffff'#abcdef" .. map .. "#ffffff' can be bought again!", root, 255, 255, 255, true );
  1135.       end, 1800000, 1,
  1136.      mapName );
  1137.      savePlayerData(thePlayer,"cash",playerCash-mapCost)
  1138.      outputChatBox("#ff6464[MAP]: "..getPlayerName(thePlayer).."#FFFFFF Has Bought a Next Map! #ABCDEF"..mapName,root, 255, 255, 255, true)
  1139.      outputChatBox("#FF6464[MAP]: #ABCDEF"..mapName.." #ffffffAdded in base!",root,255,255,255,true)
  1140.      --outputChatBox("#FFFFFF[MAP]: #ABCDEF "..mapName,root,255,255,255,true)
  1141.      mapIsAlreadySet = true;
  1142.      local oldmapbuys = loadPlayerData(thePlayer,"mapBuys")
  1143.      savePlayerData(thePlayer,"mapBuys", oldmapbuys + 1)
  1144.      CheckAchievement(thePlayer,13)
  1145.      scoreboardRefresh(thePlayer)
  1146.     else
  1147.      outputChatBox("#00AAFF# #FFFFFFYou Don't Have Enough Money To Set a Map!",thePlayer,255,255,255,true)
  1148.     end
  1149.    else
  1150.     outputChatBox("#00AAFF# #FFFFFFA Map is Already Set At The Moment! Please Try Again Later.",thePlayer,255,255,255,true)
  1151.    end
  1152.   else
  1153.    outputChatBox("#00AAFF# #FFFFFFThis map can't be bought yet! Wait some time and try again.",thePlayer,255,255,255,true)
  1154.   end
  1155.  else
  1156.   outputChatBox("#00AAFF# #FFFFFFSelect a map from list first!", thePlayer, 255, 255, 255, true );
  1157.  end
  1158. end
  1159.  
  1160. function unbuyMap(thePlayer)
  1161.  if mapIsAlreadySet ~= false then
  1162.   if mapIsAlreadySet == thePlayer then
  1163.    executeCommandHandler("pnfnsdhasd3w7432jhdsbw3ersdncsdir",thePlayer,nil)
  1164.    local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  1165.    savePlayerData(thePlayer,"cash",playerCash+(mapCost/4)*3)
  1166.    outputChatBox("#FF6464[MAP]: #FFFFFF"..getPlayerName(thePlayer).."#ABCDEF Has Unbought a Next Map!",getRootElement())
  1167.    mapIsAlreadySet = false
  1168.    local oldmapbuys = loadPlayerData(thePlayer,"mapBuys")
  1169.    savePlayerData(thePlayer,"mapBuys", oldmapbuys - 1)
  1170.    CheckAchievement(thePlayer,13)
  1171.    scoreboardRefresh(thePlayer)
  1172.   else
  1173.    outputChatBox("#00AAFF# #FFFFFFYou Didn't Buy That Map!",thePlayer,255,255,255,true)
  1174.   end
  1175.  else
  1176.   outputChatBox("#00AAFF# #FFFFFFNo Map Has Been Bought!",thePlayer,255,255,255,true)
  1177.  end
  1178. end
  1179.  
  1180. function resetMapSetStatus()
  1181.  mapIsAlreadySet = false
  1182. end
  1183. addEventHandler("onMapStarting",getRootElement(),resetMapSetStatus)
  1184.  
  1185. function getServerMaps (loadList,s)
  1186.  local tableOut
  1187.  if loadList then
  1188.   tableOut = {}
  1189.   -- local deletedMaps = {}
  1190.   local gamemodes = {}
  1191.   gamemodes = call(getResourceFromName("mapmanager"), "getGamemodes")
  1192.   for id,gamemode in ipairs (gamemodes) do
  1193.    tableOut[id] = {}
  1194.    tableOut[id].name = getResourceInfo(gamemode, "name") or getResourceName(gamemode)
  1195.    tableOut[id].resname = getResourceName(gamemode)
  1196.    tableOut[id].maps = {}
  1197.    local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode" , gamemode)
  1198.    for _,map in ipairs (maps) do
  1199.     table.insert(tableOut[id]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)})
  1200.    end
  1201.    table.sort(tableOut[id]["maps"], sortCompareFunction)
  1202.   end
  1203.   table.sort((tableOut), sortCompareFunction)
  1204.   table.insert(tableOut, {name = "no gamemode", resname = "no gamemode", maps = {}})
  1205.   local countGmodes = #tableOut
  1206.   local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode")
  1207.   for id,map in ipairs (maps) do
  1208.    -- if fileOpen(":"..getResourceName(map).."/deleted") then
  1209.     -- table.insert(deletedMaps ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)})
  1210.    -- else
  1211.     table.insert(tableOut[countGmodes]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)})
  1212.    -- end
  1213.   end
  1214.   -- table.sort(deletedMaps, sortCompareFunction)
  1215.   table.sort(tableOut[countGmodes]["maps"], sortCompareFunction)
  1216.   -- table.insert(tableOut, {name = "deleted maps", resname = "deleted maps", maps = {}})
  1217.   -- local countGmodes = countGmodes + 1
  1218.   -- tableOut[countGmodes]["maps"] = deletedMaps
  1219.  end
  1220.  
  1221.  local map = call(getResourceFromName("mapmanager"), "getRunningGamemodeMap")
  1222.  local gamemode = call(getResourceFromName("mapmanager"), "getRunningGamemode")
  1223.  gamemode = gamemode and getResourceName(gamemode) or "N/A"
  1224.  map = map and getResourceName(map) or "N/A"
  1225.  callClientFunction(loadList,"loadMaps", tableOut, gamemode, map, s)
  1226. end
  1227.  
  1228. function sortCompareFunction(s1, s2)
  1229.  if type(s1) == "table" and type(s2) == "table" then
  1230.   s1, s2 = s1.name, s2.name
  1231.  end
  1232.     s1, s2 = s1:lower(), s2:lower()
  1233.     if s1 == s2 then
  1234.         return false
  1235.     end
  1236.     local byte1, byte2 = string.byte(s1:sub(1,1)), string.byte(s2:sub(1,1))
  1237.     if not byte1 then
  1238.         return true
  1239.     elseif not byte2 then
  1240.         return false
  1241.     elseif byte1 < byte2 then
  1242.         return true
  1243.     elseif byte1 == byte2 then
  1244.         return sortCompareFunction(s1:sub(2), s2:sub(2))
  1245.     else
  1246.         return false
  1247.     end
  1248. end
  1249.  
  1250. ---------------------
  1251. -- Skin handler
  1252. ---------------------
  1253. function saveSkin(thePlayer,skinID)
  1254.         if (tonumber(loadPlayerData(thePlayer,"cash")) >= skinCost) then
  1255.                 savePlayerData(thePlayer,"skin",skinID)
  1256.                 savePlayerData(thePlayer,"cash",tonumber(loadPlayerData(thePlayer,"cash"))-skinCost)
  1257.                 skinEnabled = loadPlayerData(thePlayer,"useCustomSkin")
  1258.                 if skinEnabled == "true" then
  1259.                         setElementModel(thePlayer,skinID)
  1260.                 end
  1261.                 outputChatBox("#0095FF* #FFFFFFYou have sucessfuly purchased the skin! #FFFF00[#FFFFFFID:"..skinID.."#FFFF00]",thePlayer,255,255,255,true)
  1262.                 setTimer(outputChatBox,700,1,"#0095FF* #FFFFFFThe skin has been saved to your account.",thePlayer,255,255,255,true)
  1263.                 savePlayerData(thePlayer,"everPurchasedSkin",1)
  1264.                 setElementData(thePlayer,"everPurchasedSkin",1)
  1265.                 scoreboardRefresh(thePlayer)
  1266.         else
  1267.                 outputChatBox("#0095FF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
  1268.         end
  1269. end
  1270.  
  1271. function setSkinOnMapStart()
  1272.         if tonumber(getElementData(source,"everPurchasedSkin")) == 1 then
  1273.                 skinEnabled = loadPlayerData(source,"useCustomSkin")
  1274.                 if skinEnabled == "true" then
  1275.                         skinID = loadPlayerData(source,"skin")
  1276.                         setElementModel(source,skinID)
  1277.                 end
  1278.         end
  1279. end
  1280. addEventHandler("onNotifyPlayerReady",getRootElement(),setSkinOnMapStart)
  1281.  
  1282.  
  1283.  
  1284. function checkSkinLevel(thePlayer)
  1285.         local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
  1286.         if playerLevel >= skinLevel then
  1287.                 callClientFunction(thePlayer,"openSkinsWindow")
  1288.         else
  1289.                 outputChatBox("#0095FF* #FFFFFFERROR! You need to be level #ABCDEF"..skinLevel.."#FFFFFF or more to change skins!",thePlayer,255,255,255,true)
  1290.         end
  1291. end
  1292.  
  1293.  
  1294.  
  1295. ---------------------
  1296. -- Rims handler
  1297. ---------------------
  1298. function buyjant(thePlayer,buyjant)
  1299.         if (tonumber(loadPlayerData(thePlayer,"cash")) >= buyjant) then
  1300.                 savePlayerData(thePlayer,"rim",buyjant)
  1301.                 savePlayerData(thePlayer,"cash",tonumber(loadPlayerData(thePlayer,"cash"))-buyjant)
  1302.                 --skinEnabled = loadPlayerData(thePlayer,"useCustomSkin")
  1303.                 --if skinEnabled == "true" then
  1304.                         --setElementModel(thePlayer,skinID)
  1305.                 end
  1306.                 outputChatBox("#0095FF* #FFFFFFYou have sucessfuly purchased the Rim!",thePlayer,255,255,255,true)
  1307.                 setTimer(outputChatBox,700,1,"#0095FF* #FFFFFFThe rim has been saved to your account.",thePlayer,255,255,255,true)
  1308.                 --savePlayerData(thePlayer,"everPurchasedSkin",1)
  1309.                 --setElementData(thePlayer,"everPurchasedSkin",1)
  1310.                 scoreboardRefresh(thePlayer)
  1311.         else
  1312.                 outputChatBox("#0095FF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
  1313.         end
  1314. end
  1315.  
  1316. --[[function setSkinOnMapStart()
  1317.         if tonumber(getElementData(source,"everPurchasedSkin")) == 1 then
  1318.                 skinEnabled = loadPlayerData(source,"useCustomSkin")
  1319.                 if skinEnabled == "true" then
  1320.                         skinID = loadPlayerData(source,"skin")
  1321.                         setElementModel(source,skinID)
  1322.                 end
  1323.         end
  1324. end
  1325. addEventHandler("onNotifyPlayerReady",getRootElement(),setSkinOnMapStart)
  1326.  
  1327.  
  1328.  
  1329. function checkSkinLevel(thePlayer)
  1330.         local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
  1331.         if playerLevel >= skinLevel then
  1332.                 callClientFunction(thePlayer,"openSkinsWindow")
  1333.         else
  1334.                 outputChatBox("#0095FF* #FFFFFFERROR! You need to be level #ABCDEF"..skinLevel.."#FFFFFF or more to change skins!",thePlayer,255,255,255,true)
  1335.         end
  1336. end]]--
  1337.  
  1338.  
  1339. --------------------------
  1340. -- Options handler
  1341. --------------------------
  1342. function saveClientSettings(thePlayer,a,b,c,d,e,f,g,h,i,j)
  1343.         outputChatBox("#0095FF* #FFFFFFYour settings have been saved!",thePlayer,255,255,255,true)
  1344.         savePlayerData(thePlayer,"useCustomNametag",c)
  1345.         savePlayerData(thePlayer,"useCustomSkin",d)
  1346.         savePlayerData(thePlayer,"useCustomVehicleColor",e)
  1347.         savePlayerData(thePlayer,"useHunterSkin",i)
  1348. end
  1349.  
  1350. function getClientSettings(thePlayer)
  1351.         c = loadPlayerData(thePlayer,"useCustomNametag")
  1352.         d = loadPlayerData(thePlayer,"useCustomSkin")
  1353.         e = loadPlayerData(thePlayer,"useCustomVehicleColor")
  1354.         i = loadPlayerData(thePlayer,"useHunterSkin")
  1355.         callClientFunction(thePlayer,"configureOptions",true,a,b,c,d,e,f,g,h,i,j)
  1356. end
  1357.  
  1358. function showUserpanelOnDeath()
  1359.         if (loadPlayerData(source,"showOnDeath") == "true") then
  1360.                 callClientFunction(source,"displayUserpanel")
  1361.         end
  1362. end
  1363. addEventHandler("onPlayerWasted",getRootElement(),showUserpanelOnDeath)
  1364.  
  1365.  
  1366.  
  1367. -- Nametag color
  1368. function saveNametagColor(thePlayer,r,g,b)
  1369.         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  1370.         savePlayerData(thePlayer,"cash",playerCash-nametagPrice)
  1371.         savePlayerData(thePlayer,"nametagRed",r)
  1372.         savePlayerData(thePlayer,"nametagGreen",g)
  1373.         savePlayerData(thePlayer,"nametagBlue",b)
  1374.         setNametagColor(thePlayer)
  1375.         outputChatBox("#0095FF* #FFFFFFYou have purchased a new nametag color for #ABCDEF$"..nametagPrice.."#FFFFFF!",thePlayer,255,255,255,true)
  1376.         savePlayerData(thePlayer,"everPurchasedNametagColor",1)
  1377.         setElementData(thePlayer,"everPurchasedNametagColor",1)
  1378.         scoreboardRefresh(thePlayer)
  1379. end
  1380.  
  1381. function getNametagLevel(thePlayer)
  1382.         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  1383.         local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
  1384.         if playerLevel >= nametagLevel then
  1385.                 if playerCash >= nametagPrice then
  1386.                         callClientFunction(thePlayer,"showNametagWindow")
  1387.                 else
  1388.                         outputChatBox("#0095FF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
  1389.                 end
  1390.         else
  1391.                 outputChatBox("#0095FF* #FFFFFFERROR! You need to be level #ABCDEF"..nametagLevel.."#FFFFFF or higher to change your nametag color!",thePlayer,255,255,255,true)
  1392.         end
  1393. end
  1394.  
  1395.  
  1396. function setNametagColor(thePlayer)
  1397.         local ifSet = tonumber(getElementData(thePlayer,"everPurchasedNametagColor"))
  1398.         if ifSet == 1 then
  1399.                 local useColor = loadPlayerData(thePlayer,"useCustomNametag")
  1400.                 if useColor == "true" then
  1401.                         local r = tonumber(loadPlayerData(thePlayer,"nametagRed"))
  1402.                         local g = tonumber(loadPlayerData(thePlayer,"nametagGreen"))
  1403.                         local b = tonumber(loadPlayerData(thePlayer,"nametagBlue"))
  1404.                         callClientFunction(thePlayer,"setCustomNametagColor",true,r,g,b)
  1405.                 end
  1406.         end
  1407. end
  1408. addEventHandler("onPlayerJoin",getRootElement(),setNametagColor)
  1409.  
  1410.  
  1411.  
  1412. -- Horns
  1413. function getPurchasedHorns(thePlayer)
  1414.         local airhorn = tonumber(loadPlayerData(thePlayer,"horn1"))
  1415.         local clown = tonumber(loadPlayerData(thePlayer,"horn2"))
  1416.         local train = tonumber(loadPlayerData(thePlayer,"horn3"))
  1417.         local ship = tonumber(loadPlayerData(thePlayer,"horn4"))
  1418.         local submarine = tonumber(loadPlayerData(thePlayer,"horn5"))
  1419.         local military = tonumber(loadPlayerData(thePlayer,"horn6"))
  1420.         local whoopie = tonumber(loadPlayerData(thePlayer,"horn7"))
  1421.         callClientFunction(thePlayer,"updateHorns",thePlayer,airhorn,clown,train,ship,submarine,military,whoopie)
  1422. end
  1423.  
  1424. function purchaseHorn(thePlayer,horn,hornName)
  1425.         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  1426.         local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
  1427.         local checkOwnership = tonumber(loadPlayerData(thePlayer,"horn"..horn))
  1428.         if checkOwnership == 0 then
  1429.                 if playerLevel >= hornLevel then
  1430.                         if playerCash >= hornPrice[horn] then
  1431.                                 savePlayerData(thePlayer,"cash",playerCash-hornPrice[horn])
  1432.                                 savePlayerData(thePlayer,tostring("horn"..horn),1)
  1433.                                 getPurchasedHorns(thePlayer)
  1434.                                 scoreboardRefresh(thePlayer)
  1435.                                 achievement39(thePlayer)
  1436.                                 outputChatBox("#0095FF* #FFFFFFYou have purchased the #ABCDEF"..hornName.."#FFFFFF horn for #ABCDEF$"..hornPrice[horn].."#FFFFFF!",thePlayer,255,255,255,true)
  1437.                         else
  1438.                                 outputChatBox("#0095FF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
  1439.                         end
  1440.                 else
  1441.                         outputChatBox("#0095FF* #FFFFFFERROR! You need to be level #ABCDEF"..hornLevel.."#FFFFFF or higher to purchase new horns!",thePlayer,255,255,255,true)
  1442.                 end
  1443.         else
  1444.                 outputChatBox("#0095FF* #FFFFFFERROR! You already own this horn!",thePlayer,255,255,255,true)
  1445.         end
  1446. end
  1447.  
  1448. function checkForPurchasedHorn(thePlayer,horn)
  1449.         local hornStatus = tonumber(loadPlayerData(thePlayer,"horn"..horn))
  1450.         if hornStatus == 1 then
  1451.                 callClientFunction(thePlayer,"setHorn",horn)
  1452.         else
  1453.                 outputChatBox("#0095FF* #FFFFFFERROR! You do not own this horn!",thePlayer,255,255,255,true)
  1454.         end
  1455. end
  1456.  
  1457. function getLastSetHorn(thePlayer)
  1458.         local horn = tonumber(loadPlayerData(thePlayer,"lastSetHorn"))
  1459.         callClientFunction(thePlayer,"setLastUsedHorn",horn)
  1460. end
  1461.  
  1462. function setLastSetHorn(thePlayer,horn)
  1463.         savePlayerData(thePlayer,"lastSetHorn",horn)
  1464. end
  1465.  
  1466. function toggleHornControl()
  1467.         for _,player in ipairs(getElementsByType("player")) do
  1468.                 if loadPlayerData(player,"lastSetHorn") == 0 then
  1469.                         setTimer(toggleControl,2000,1,player,"horn",true)
  1470.                 else
  1471.                         setTimer(toggleControl,2000,1,player,"horn",false)
  1472.                 end
  1473.         end
  1474. end
  1475. addEvent("onMapStarting",true)
  1476. addEventHandler("onMapStarting",getRootElement(),toggleHornControl)
  1477.  
  1478. function toggleControlOnReady()
  1479.         if loadPlayerData(source,"lastSetHorn") == 0 then
  1480.                 toggleControl(source,"horn",true)
  1481.         else
  1482.                 toggleControl(source,"horn",false)
  1483.         end
  1484. end
  1485. addEventHandler("onNotifyPlayerReady",getRootElement(),toggleControlOnReady)
  1486.  
  1487.  
  1488. function playHornForAllClients(horningPlayer,hornSoundPath,cSetHornSound) -- This function passes on the horn to all players.
  1489.         triggerClientEvent(getRootElement(),"onRecieveHorn",horningPlayer,horningPlayer,hornSoundPath,cSetHornSound)
  1490. end
  1491.  
  1492.  
  1493.  
  1494.  
  1495. -- Buy water color and time change
  1496. function buyChangeWaterColor(thePlayer,r,g,b)
  1497.         if type(r) == "number" and r >= 0 and r <= 255 then
  1498.                 if type(g) == "number" and g >= 0 and g <= 255 then
  1499.                         if type(b) == "number" and g >= 0 and g <= 255 then
  1500.                                 local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  1501.                                 if playerCash >= 400 then
  1502.                                         callClientFunction(getRootElement(),"cSetWaterColor",r,g,b)
  1503.                                         savePlayerData(thePlayer,"cash",playerCash-400)
  1504.                                         outputChatBox("#0095FF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the water color!",getRootElement(),255,255,255,true)
  1505.                                         scoreboardRefresh(thePlayer)
  1506.                                 else
  1507.                                         outputChatBox("#0095FF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
  1508.                                 end
  1509.                         else
  1510.                                 outputChatBox("#0095FF* #FFFFFFInvalid BLUE value - Please use a number from 0 to 255.",thePlayer,255,255,255,true)
  1511.                         end
  1512.                 else
  1513.                         outputChatBox("#0095FF* #FFFFFFInvalid GREEN value - Please use a number from 0 to 255.",thePlayer,255,255,255,true)
  1514.                 end
  1515.         else
  1516.                 outputChatBox("#0095FF* #FFFFFFInvalid RED value - Please use a number from 0 to 255.",thePlayer,255,255,255,true)
  1517.         end
  1518. end
  1519.  
  1520.  
  1521. function buyChangeTime(thePlayer,h,m)
  1522.         if type(h) == "number" and h >= 0 and h <= 23 then
  1523.                 if type(m) == "number" and m >= 0 and m <= 59 then
  1524.                         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  1525.                         if playerCash >= 400 then
  1526.                                 setTime(h,m)
  1527.                                 savePlayerData(thePlayer,"cash",playerCash-250)
  1528.                                 if h < 10 and m < 10 then
  1529.                                         outputChatBox("#0095FF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the time to #ABCDEF0"..h..":0"..m.."#FFFFFF!",getRootElement(),255,255,255,true)
  1530.                                 elseif h < 10 then
  1531.                                         outputChatBox("#0095FF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the time to #ABCDEF0"..h..":"..m.."#FFFFFF!",getRootElement(),255,255,255,true)
  1532.                                 elseif m < 10 then
  1533.                                         outputChatBox("#0095FF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the time to #ABCDEF"..h..":0"..m.."#FFFFFF!",getRootElement(),255,255,255,true)
  1534.                                 end
  1535.                                 scoreboardRefresh(thePlayer)
  1536.                         else
  1537.                                 outputChatBox("#0095FF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
  1538.                         end
  1539.                 else
  1540.                         outputChatBox("#0095FF* #FFFFFFInvalid MINUTES - Please use a number from 0 to 59.",thePlayer,255,255,255,true)
  1541.                 end
  1542.         else
  1543.                 outputChatBox("#0095FF* #FFFFFFInvalid HOURS - Please use a number from 0 to 23.",thePlayer,255,255,255,true)
  1544.         end
  1545. end
  1546.  
  1547.  
  1548.  
  1549. ------------------------------------------
  1550. -- giveMoney
  1551. ------------------------------------------
  1552. function giveMoney(thePlayer,CMD,targetPlayer,amount)
  1553.         if not (targetPlayer == "") then
  1554.                 if tonumber(amount) then
  1555.                         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  1556.                         if tonumber(amount) > 0 then
  1557.                                 if tonumber(amount) <= playerCash then
  1558.                                         if (findPlayerByName(targetPlayer)) then
  1559.                                                 local target = findPlayerByName(targetPlayer)
  1560.                                                 if target ~= thePlayer then
  1561.                                                         local amount = math.ceil(amount)
  1562.                                                         local playerCash = loadPlayerData(thePlayer,"cash")
  1563.                                                         local targetCash = loadPlayerData(target,"cash")
  1564.                                                         savePlayerData(thePlayer,"cash",playerCash-tonumber(amount))
  1565.                                                         CheckAchievement(thePlayer,15)
  1566. CheckAchievement(thePlayer,16)
  1567. CheckAchievement(thePlayer,20)
  1568. CheckAchievement(thePlayer,21)
  1569.                                                         savePlayerData(target,"cash",targetCash+tonumber(amount))
  1570.                                                         CheckAchievement(target,15)
  1571. CheckAchievement(target,16)
  1572. CheckAchievement(thePlayer,20)
  1573. CheckAchievement(thePlayer,21)
  1574.                                                 local playerCash = loadPlayerData(thePlayer,"cash")
  1575.                                                         local targetCash = loadPlayerData(target,"cash")
  1576.                                                         scoreboardRefresh(thePlayer)
  1577.                                                         scoreboardRefresh(target)
  1578.                                                         outputChatBox("#FFFFFFYou Have Sent #00AAFF$"..amount.."#FFFFFF to "..getPlayerName(target).."#FFFFFF!",thePlayer,255,255,255,true)
  1579.                                                         outputChatBox("#FFFFFF"..getPlayerName(thePlayer).." #FFFFFFHas Sent You #00AAFF$"..amount.."#FFFFFF!",target,255,255,255,true)
  1580.                                                 else
  1581.                                                         outputChatBox("#00AAFF# #FFFFFFERROR! You cannot send money to yourself!",thePlayer,255,255,255,true)
  1582.                                                         return false
  1583.                                                 end
  1584.                                         else
  1585.                                                 outputChatBox("#00AAFF# #FFFFFFERROR! The Player You Specified Does Not Exist!",thePlayer,255,255,255,true)
  1586.                                                 return false
  1587.                                         end
  1588.                                 else
  1589.                                         outputChatBox("#00AAFF# #FFFFFFERROR! You Don't Have Enough Money!",thePlayer,255,255,255,true)
  1590.                                         return false
  1591.                                 end
  1592.                         else
  1593.                                 outputChatBox("#00AAFF# #FFFFFFERROR! Invalid amount! [#00AAFF"..amount.."#FFFFFF]",thePlayer,255,255,255,true)
  1594.                                 return false
  1595.                         end
  1596.                 else
  1597.                         outputChatBox("#00AAFF# #FFFFFFERROR! Please specify the amount to send!",thePlayer,255,255,255,true)
  1598.                         return false
  1599.                 end
  1600.         else
  1601.                 outputChatBox("#00AAFF# #FFFFFFERROR! Please select a player!",thePlayer,255,255,255,true)
  1602.                 return false
  1603.         end
  1604. end
  1605. addCommandHandler("givecash", giveMoney)
  1606.  
  1607.  
  1608. ------------------------------------------
  1609. -- givePoints
  1610. ------------------------------------------
  1611. function givePoint(thePlayer,CMD,targetPlayer,amount)
  1612.         if not (targetPlayer == "") then
  1613.                 if tonumber(amount) then
  1614.                         local playerPoint = tonumber(loadPlayerData(thePlayer,"point"))
  1615.                         if tonumber(amount) > 0 then
  1616.                                 if tonumber(amount) <= playerPoint then
  1617.                                         if (findPlayerByName(targetPlayer)) then
  1618.                                                 local target = findPlayerByName(targetPlayer)
  1619.                                                 if target ~= thePlayer then
  1620.                                                         local amount = math.ceil(amount)       
  1621.                                                         local playerPoint = loadPlayerData(thePlayer,"point")
  1622.                                                         local targetPoint = loadPlayerData(target,"point")
  1623.                                                        
  1624. savePlayerData(thePlayer,"point",playerPoint-tonumber(amount))
  1625.                                                         CheckAchievement(thePlayer,15)
  1626. CheckAchievement(thePlayer,16)
  1627. CheckAchievement(thePlayer,20)
  1628. CheckAchievement(thePlayer,21)
  1629.                                                        
  1630. savePlayerData(target,"point",targetPoint+tonumber(amount))
  1631.                                                         CheckAchievement(target,15)
  1632. CheckAchievement(target,16)
  1633. CheckAchievement(thePlayer,20)
  1634. CheckAchievement(thePlayer,21)
  1635.                                                 local playerPoint = loadPlayerData(thePlayer,"point")
  1636.                                                         local targetPoint = loadPlayerData(target,"point")
  1637.                                                         scoreboardRefresh(thePlayer)
  1638.                                                         scoreboardRefresh(target)
  1639.                                                         outputChatBox("#FFFFFFYou Have Sent #00AAFF"..amount.."#FFFFFF Points to "..getPlayerName(target).."#FFFFFF!",thePlayer,255,255,255,true)
  1640.                                                         outputChatBox("#FFFFFF"..getPlayerName(thePlayer).." #FFFFFFHas Sent You #00AAFF"..amount.."#FFFFFF Points!",target,255,255,255,true)
  1641.                                                 else
  1642.                                                         outputChatBox("#00AAFF# #FFFFFFERROR! You cannot send points to yourself!",thePlayer,255,255,255,true)
  1643.                                                         return false
  1644.                                                 end
  1645.                                         else
  1646.                                                 outputChatBox("#00AAFF# #FFFFFFERROR! The Player You Specified Does Not Exist!",thePlayer,255,255,255,true)
  1647.                                                 return false
  1648.                                         end
  1649.                                 else
  1650.                                         outputChatBox("#00AAFF# #FFFFFFERROR! You Don't Have Enough Point!",thePlayer,255,255,255,true)
  1651.                                         return false
  1652.                                 end
  1653.                         else
  1654.                                 outputChatBox("#00AAFF# #FFFFFFERROR! Invalid amount! [#00AAFF"..amount.."#FFFFFF]",thePlayer,255,255,255,true)
  1655.                                 return false
  1656.                         end
  1657.                 else
  1658.                         outputChatBox("#00AAFF# #FFFFFFERROR! Please specify the amount to send!",thePlayer,255,255,255,true)
  1659.                         return false
  1660.                 end
  1661.         else
  1662.                 outputChatBox("#00AAFF# #FFFFFFERROR! Please select a player!",thePlayer,255,255,255,true)
  1663.                 return false
  1664.         end
  1665. end
  1666. addCommandHandler("givepoint", givePoint)
  1667.  
  1668.  
  1669. -- Total bets
  1670. function totalBetsAdd(thePlayer)
  1671.         local totalBets = tonumber(loadPlayerData(thePlayer,"totalBets"))
  1672.         savePlayerData(thePlayer,"totalBets",totalBets+1)
  1673. end
  1674.  
  1675.  
  1676. -- Total bets won
  1677. function totalBetsWonAdd(thePlayer)
  1678.         local totalBetsWon = tonumber(loadPlayerData(thePlayer,"totalBetsWon"))
  1679.         savePlayerData(thePlayer,"totalBetsWon",totalBetsWon+1)
  1680. end
  1681.  
  1682.  
  1683. -- Total bets earned
  1684. function totalBetsEarnedAdd(thePlayer,addAmount)
  1685.         local totalBetsEarned = tonumber(loadPlayerData(thePlayer,"totalBetsEarned"))
  1686.         savePlayerData(thePlayer,"totalBetsEarned",totalBetsEarned+addAmount)
  1687. end
  1688.  
  1689.  
  1690. -----------------
  1691. -- Betting system
  1692. -----------------
  1693.  
  1694. function createNewBet(thePlayer,toPlayer,newAmount,oldAmount,betState)
  1695.         if getPlayerCount() >= minPlayers then
  1696.                 if bettingEnabled == true then
  1697.                         if (betState == 0) then
  1698.                                 if (toPlayer) then
  1699.                                         if (newAmount) then
  1700.                                                 local newAmount = tonumber(math.ceil(newAmount))
  1701.                                                 if (newAmount >= 1) then
  1702.  
  1703.                                                         local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
  1704.                                                         local maxBet = playerCash
  1705.                                                         if (findPlayerByName(toPlayer)) then
  1706.                                                                 local toPlayerName = findPlayerByName(toPlayer)
  1707.                                                                 if (newAmount <= playerCash) then
  1708.                                                                         if newAmount <= maxBet then
  1709.                                                                                 callClientFunction(thePlayer,"addNewBet",toPlayerName,newAmount)
  1710.                                                                                 savePlayerData(thePlayer,"cash",playerCash-newAmount)
  1711.                                                                                 scoreboardRefresh(thePlayer)
  1712.                                                                                 totalBetsAdd(thePlayer)
  1713.                                                                
  1714.                                                                                 --outputChatBox("#00FF00* #FFFFFFYou have placed your bet on "..getPlayerName(toPlayerName).."#FFFFFF for #ABCDEF$"..newAmount.."#FFFFFF!",thePlayer,255,255,255,true)
  1715.                                                                                 outputChatBox("#0095FF* #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF has placed a bet on "..getPlayerName(toPlayerName).."#FFFFFF for #ABCDEF$"..newAmount.."#FFFFFF!",getRootElement(),255,255,255,true)
  1716.                                                                         elseif newAmount > maxBet then
  1717.                                                                                 --outputChatBox("#FF0000* #FFFFFFYou are allowed to bet a maximum of #ABCDEF$"..maxBet.."#FFFFFF! Levelling up will increase this number.",thePlayer,255,255,255,true)
  1718.                                                                                 return false
  1719.                                                                         end
  1720.                                                                 else
  1721.                                                                         outputChatBox("#FF0000* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
  1722.                                                                 end
  1723.                                                         else
  1724.                                                                 outputChatBox("#FF0000* #FFFFFFERROR! The player you specified has not been found! (#FFFF00"..toPlayer.."#FFFFFF)",thePlayer,255,255,255,true)
  1725.                                                                 return false
  1726.                                                         end
  1727.                                                 else
  1728.                                                         outputChatBox("#FF0000* #FFFFFFERROR! Invalid amount! [#ABCDEF$"..newAmount.."#FFFFFF]",thePlayer,255,255,255,true)
  1729.                                                 end
  1730.                                         else
  1731.                                                 outputChatBox("#FF0000* #FFFFFFERROR! Please specify an amount to bet! Correct syntax: #ABCDEF/bet [player] [amount]",thePlayer,255,255,255,true)
  1732.                                                 return false
  1733.                                         end
  1734.                                 else
  1735.                                         outputChatBox("#FF0000* #FFFFFFERROR! Please specify a player! Correct syntax: #ABCDEF/bet [player] [amount]",thePlayer,255,255,255,true)
  1736.                                         return false
  1737.                                 end
  1738.                         else
  1739.                                 outputChatBox("#FF0000* #FFFFFFYou have already placed your bet on "..betState.." #FFFFFFfor #ABCDEF$"..oldAmount.."#FFFFFF!",thePlayer,255,255,255,true)
  1740.                                 return false
  1741.                         end
  1742.                 else
  1743.                         outputChatBox("#FF0000* #FFFFFFBetting time is over! You can place your bet on the next map.",thePlayer,255,255,255,true)
  1744.                 end
  1745.         else
  1746.                 --outputChatBox("#FF0000* #FFFFFFBetting #FF0000disabled.#FFFFFF Minimum required players on server: #ABCDEF" ..minPlayers.."#FF0000 | #FFFFFFConnected: #ABCDEF"..getPlayerCount(),thePlayer,255,255,255,true)
  1747.         end
  1748. end
  1749.  
  1750.  
  1751. function onPlayerBetWin(self,betAmount)
  1752.         outputChatBox("#0095FF* #FFFFFF"..getPlayerName(self).."#FFFFFF has won his bet and has recieved #ABCDEF$".. betAmount*2 .."#FFFFFF!",getRootElement(),255,255,255,true)
  1753.         local playerCash = loadPlayerData(self,"cash")
  1754.         savePlayerData(self,"cash",playerCash+betAmount+betAmount*2)
  1755.         local thePlayer = self
  1756.         scoreboardRefresh(thePlayer)
  1757.         local addAmount = betAmount*2
  1758.         totalMoneyEarnedAdd(thePlayer,addAmount)
  1759.         totalBetsWonAdd(thePlayer)
  1760.         totalBetsEarnedAdd(thePlayer,addAmount)
  1761.         progressBarUpdate(thePlayer)
  1762.         --totalMoneyAchievements(thePlayer)
  1763. end
  1764.  
  1765.  
  1766.  
  1767. function bettingTimer()
  1768.         if isTimer(chatTimer) then killTimer(chatTimer) end
  1769.         if isTimer(disableTimer) then killTimer(disableTimer) end
  1770.         if getPlayerCount() >= minPlayers then
  1771.                 chatTimer = setTimer(outputChatBox,3500,1,"#0095FF* #FFFFFFPlace your bets!     #FFFFFF[#ABCDEF/bet#FFFFFF]",getRootElement(),255,255,255,true)
  1772.                 bettingEnabled = true
  1773.                 disableTimer = setTimer(disableBetting,betTimeLimit*1000+2000,1)
  1774.         end
  1775. end
  1776. addEvent("onMapStarting",true)
  1777. addEventHandler("onMapStarting",getRootElement(),bettingTimer)
  1778.  
  1779.  
  1780. function disableBetting()
  1781.         outputChatBox("#0095FF* #FFFFFFBetting time is over#FF0000!",getRootElement(),255,255,255,true)
  1782.         bettingEnabled = false
  1783. end
  1784.  
  1785.  
  1786. function checkWin(winner)
  1787.         callClientFunction( getRootElement(), "compareResult", winner )
  1788. end
  1789. addEvent("onPlayerDestructionDerbyWin",true)
  1790. addEventHandler( "onPlayerDestructionDerbyWin", getRootElement(), checkWin )
  1791.  
  1792.  
  1793.  
  1794. function retrieveData(thePlayer,commandName,toPlayer,newAmount)
  1795.         callClientFunction(thePlayer,"triggerBettingSystem",thePlayer,toPlayer,newAmount)
  1796. end
  1797. addCommandHandler("bet",retrieveData)
  1798.  
  1799.  
  1800.  
  1801.  
  1802.  
  1803. -----------------
  1804. -- Hunter handler
  1805. -----------------
  1806.  
  1807. function hunterBonus(thePlayer)
  1808.         if getElementData(thePlayer,"playerGotHunter") == false then
  1809.                 setElementData(thePlayer,"playerGotHunter",true)
  1810.                 local cashToWin = 500
  1811.                 if (tonumber(loadPlayerData(thePlayer,"point")) >= 1000) then
  1812.                         cashToWin = cashToWin*1.1
  1813.                 end
  1814.                 outputChatBox("#0095FF* #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF has got the #ABCDEFHunter#FFFFFF! #ABCDEF[#FFFFFF$"..cashToWin.."#ABCDEF]",getRootElement(),255,255,255,true)
  1815.                 playerCash = loadPlayerData(thePlayer,"cash")
  1816.                 savePlayerData(thePlayer,"cash",playerCash+cashToWin)
  1817.                 scoreboardRefresh(thePlayer)
  1818.                 totalHuntersAdd(thePlayer)
  1819.                 totalMoneyAchievements(thePlayer)
  1820.                 local newAmount = cashToWin
  1821.                 totalMoneyEarnedAdd(thePlayer,newAmount)
  1822.         end
  1823. end
  1824.  
  1825. function checkForHunter(number,sort,model)
  1826.         if sort == "vehiclechange" then
  1827.                 if model == 425 then
  1828.                         setTimer(hunterBonus,200,1,source)
  1829.                 end
  1830.         end
  1831. end
  1832. addEventHandler("onPlayerPickUpRacePickup",getRootElement(),checkForHunter)
  1833.  
  1834.  
  1835.  
  1836. addEvent("onPlayerToptimeImprovement",true)
  1837. addEventHandler("onPlayerToptimeImprovement",getRootElement(),
  1838. function (player,newPos,newTime,oldPos,oldTime,random1,random2)
  1839.         if getElementData(source,"playerGotHunter") == false then
  1840.                 if newPos <= 10 then
  1841.                         local cashToWin = 600
  1842.                         if (tonumber(loadPlayerData(source,"point")) >= 1000) then
  1843.                                 cashToWin = cashToWin*1.1
  1844.                         end
  1845.                         local playerCash = loadPlayerData(source,"cash")
  1846.                         savePlayerData(player,"cash",playerCash +cashToWin)
  1847.                         local playerCash = loadPlayerData(source,"cash")
  1848.                         outputChatBox ("#0095FF* #FFFFFF" .. getPlayerName(source) .." #FFFFFFhas set a new top time - Place: #0095FF"..newPos.." #ABCDEF[#FFFFFF$"..cashToWin.."#ABCDEF]",getRootElement(),255,255,255,true)
  1849.                         setElementData(source, "playerGotHunter",true)
  1850.                         local newAmount = cashToWin
  1851.                         local thePlayer = source
  1852.                         totalMoneyEarnedAdd(thePlayer,newAmount)
  1853.                         totalHuntersAdd(thePlayer)
  1854.                         scoreboardRefresh(thePlayer)
  1855.                         totalMoneyAchievements(thePlayer)
  1856.                 end
  1857.         end
  1858. end)
  1859.  
  1860. function resetHunterData()
  1861.         setElementData(source,"playerGotHunter",false)
  1862. end
  1863. addEventHandler("onNotifyPlayerReady",getRootElement(),resetHunterData)
  1864.  
  1865.  
  1866.  
  1867.  
  1868.  
  1869. ------------------------------------------
  1870. -- Tops
  1871. ------------------------------------------
  1872. function getDataFromServerAndSendToClient ( thePlayer , argument)
  1873.         if ( thePlayer ) then
  1874.                 if argument then
  1875.                         if string.lower(argument) == "cash" then
  1876.                                 local tablica = loadAllData ("cash")
  1877.                                 callClientFunction(thePlayer,"SortTops","Top Cash!",tablica,thePlayer,"$","")
  1878.                         elseif string.lower(argument) == "achievements" or string.lower(argument) == "ac" then
  1879.                                 local tablica = loadAllData ("achievements")
  1880.                                 callClientFunction(thePlayer,"SortTops","Top Achievements!",tablica,thePlayer,"","")
  1881.                         elseif string.lower(argument) == "ddwins" then
  1882.                                 local tablica = loadAllData ("mapsWonDD")
  1883.                                 callClientFunction(thePlayer,"SortTops","Top DD wins!",tablica,thePlayer,"","")
  1884.                         elseif string.lower(argument) == "dmwins" then
  1885.                                 local tablica = loadAllData ("mapsWonDM")
  1886.                                 callClientFunction(thePlayer,"SortTops","Top DM wins!",tablica,thePlayer,"","")
  1887.                         elseif string.lower(argument) == "dds" then
  1888.                                 local tablica = loadAllData ("mapsPlayedDD")
  1889.                                 callClientFunction(thePlayer,"SortTops","Top Played DDs!",tablica,thePlayer,"","")
  1890.                         elseif string.lower(argument) == "dms" then
  1891.                                 local tablica = loadAllData ("mapsPlayedDM")
  1892.                                 callClientFunction(thePlayer,"SortTops","Top Played DMs!",tablica,thePlayer,"","")
  1893.                         elseif string.lower(argument) == "playedtime" or string.lower(argument) == "pt" then
  1894.                                 local tablica = loadAllData ("playedTime")
  1895.                                 callClientFunction(thePlayer,"SortTops","Top Played Time!",tablica,thePlayer," "," ")
  1896.                         elseif string.lower(argument) == "hunters" then
  1897.                                 local tablica = loadAllData ("hunters")
  1898.                                 callClientFunction(thePlayer,"SortTops","Top Hunters!",tablica,thePlayer,"","")
  1899.                         elseif string.lower(argument) == "mapbuys" or string.lower(argument) == "mb" then
  1900.                                 local tablica = loadAllData ("mapBuys")
  1901.                                 callClientFunction(thePlayer,"SortTops","Top Map Buys!",tablica,thePlayer,"","")
  1902.                         elseif string.lower(argument) == "toptimes" or string.lower(argument) == "tt" then
  1903.                                 local tablica = loadAllData ("TopTimes")
  1904.                                 callClientFunction(thePlayer,"SortTops","Top TopTimes!",tablica,thePlayer,"","")
  1905.                         elseif string.lower(argument) == "ddratio" then
  1906.                                 local tablica = loadAllData ("ddratio")
  1907.                                 callClientFunction(thePlayer,"SortTops","Top DD Ratio!",tablica,thePlayer,"","%")
  1908.                         elseif string.lower(argument) == "dmratio" then
  1909.                                 local tablica = loadAllData ("dmratio")
  1910.                                 callClientFunction(thePlayer,"SortTops","Top DM Ratio!",tablica,thePlayer,"","%")
  1911.                         elseif string.lower(argument) == "ddmap" then
  1912.                                 local allMaps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode" , getResourceFromName("race"))
  1913.                                 tablicaMap = {}
  1914.                                 for i,map in ipairs(allMaps) do
  1915.                                         if checkMapType(getResourceInfo(map, "name")) == 2 then
  1916.                                                 local mapinfo = getMapInfo(map)                                
  1917.                                                 table.insert(tablicaMap,{pName = getResourceInfo(map, "name") or "???",dType = tonumber(mapinfo.playedCount) or 0})
  1918.                                         end
  1919.                                 end
  1920.                                 callClientFunction(thePlayer,"SortTopsMaps","Top DD Map!",tablicaMap,thePlayer,"","")
  1921.                         elseif string.lower(argument) == "dmmap" then
  1922.                                 local allMaps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode" , getResourceFromName("race"))
  1923.                                 tablicaMap = {}
  1924.                                 for i,map in ipairs(allMaps) do
  1925.                                         if checkMapType(getResourceInfo(map, "name")) == 1 then
  1926.                                                 local mapinfo = getMapInfo(map)                                
  1927.                                                 table.insert(tablicaMap,{pName = getResourceInfo(map, "name") or "???",dType = tonumber(mapinfo.playedCount) or 0})
  1928.                                         end
  1929.                                 end
  1930.                                 callClientFunction(thePlayer,"SortTopsMaps","Top DM Map!",tablicaMap,thePlayer,"","")
  1931.                         elseif string.lower(argument) == "point" then
  1932.                                 local tablica = loadAllData ("point")
  1933.                                 callClientFunction(thePlayer,"SortTops","Top Points!",tablica,thePlayer,"","")
  1934.                         else
  1935.                                 outputChatBox("#00AAFF# #FFFFFFERROR! Invalid argument!",thePlayer,255,255,255,true)
  1936.                                 outputChatBox("[cash,point,achievements,ddwins,dmwins,dds,dms,playedtime]",thePlayer,255,255,255,true)
  1937.                                 outputChatBox("[hunters,mapbuys,toptimes,ddratio,dmratio,ddmap,dmmap]",thePlayer,255,255,255,true)
  1938.                         end
  1939.                 else
  1940.                         outputChatBox ("#00AAFF# #FF0000ERROR!#FFFFFF Syntax: /top [datatype]",thePlayer,255,255,255,true)
  1941.                 end
  1942.         end
  1943. end
  1944.  
  1945. function loadMapInfoAll()
  1946.         local rows = executeSQLQuery( 'SELECT * FROM ' .. getTableName() )
  1947.         g_MapInfoList = {}
  1948.         for i,row in ipairs(rows) do
  1949.                 local map = getResourceFromName( row.resName )
  1950.                 if map then
  1951.                         local mapInfo = getMapInfo( map )
  1952.                         mapInfo.playedCount = row.playedCount
  1953.                         mapInfo.lastTimePlayed = row.lastTimePlayed
  1954.                 end
  1955.         end
  1956. end
  1957. function getTableName(value)
  1958.         return sqlString( 'race_mapmanager_maps' )
  1959. end
  1960. function sqlString(value)
  1961.         value = tostring(value) or ''
  1962.         return "'" .. value:gsub( "(['])", "''" ) .. "'"
  1963. end
  1964. function getMapInfo( map )
  1965.         if not g_MapInfoList then
  1966.                 loadMapInfoAll()
  1967.         end
  1968.         if not g_MapInfoList[map] then
  1969.                 g_MapInfoList[map] = {}
  1970.         end
  1971.         local mapInfo = g_MapInfoList[map]
  1972.         if mapInfo.loadTime ~= getResourceLoadTime(map) then
  1973.                 -- Reset or clear data that may change between loads
  1974.                 mapInfo.loadTime = getResourceLoadTime( map )
  1975.                 mapInfo.spawnPointCount = false
  1976.         end
  1977.         return mapInfo
  1978. end
  1979.  
  1980. function loadAllData (datatype)
  1981.         local root = xmlLoadFile ("DataBase.xml")
  1982.         if (root) then
  1983.                 local usersNode = xmlFindChild (root,"user",0)
  1984.                 if (usersNode) then
  1985.                         local allPlayers = xmlNodeGetChildren(usersNode)
  1986.                         allPlayersData = {}
  1987.                         nrDD = 0
  1988.                         nrDM = 0
  1989.                         for i,data in ipairs(allPlayers) do
  1990.                                 if datatype == "achievements" then
  1991.                                         AchCount = 0
  1992.                                         for j=1,#AchievementsName do
  1993.                                                 local ac = tonumber(xmlNodeGetAttribute (data,"ac"..j..""))
  1994.                                                 if ac == 1 then
  1995.                                                         AchCount = AchCount + 1
  1996.                                                 end
  1997.                                         end
  1998.                                         local playerName = xmlNodeGetAttribute (data,"playerName")
  1999.                                         allPlayersData[i] = {pName = playerName or "???",dType = AchCount or 0}
  2000.                                 elseif datatype == "ddratio" then
  2001.                                         local played = tonumber(xmlNodeGetAttribute (data,"mapsPlayedDD")) or 0
  2002.                                         local wins = tonumber(xmlNodeGetAttribute (data,"mapsWonDD")) or 0
  2003.                                         local ratio = 0
  2004.                                         if played == 0 and wins == 0 then
  2005.                                                 ratio = 0
  2006.                                         elseif played ~= 0 and wins == 0 then
  2007.                                                 ratio = 0
  2008.                                         elseif played ~= 0 and wins ~= 0 then
  2009.                                                 ratio = (100/played)*wins
  2010.                                         elseif wins > played then
  2011.                                                 ratio = 0
  2012.                                         end
  2013.                                         if played >= 100 then
  2014.                                                 nrDD = nrDD + 1
  2015.                                                 local playerName = xmlNodeGetAttribute (data,"playerName")
  2016.                                                 allPlayersData[nrDD] = {pName = playerName or "???",dType = ratio or 0}
  2017.                                         end
  2018.                                 elseif datatype == "dmratio" then
  2019.                                         local played = tonumber(xmlNodeGetAttribute (data,"mapsPlayedDM")) or 0
  2020.                                         local wins = tonumber(xmlNodeGetAttribute (data,"mapsWonDM")) or 0
  2021.                                         local ratio = 0
  2022.                                         if played == 0 and wins == 0 then
  2023.                                                 ratio = 0
  2024.                                         elseif played ~= 0 and wins == 0 then
  2025.                                                 ratio = 0
  2026.                                         elseif played ~= 0 and wins ~= 0 then
  2027.                                                 ratio = (100/played)*wins
  2028.                                         elseif wins > played then
  2029.                                                 ratio = 0
  2030.                                         end
  2031.                                         if played >= 100 then
  2032.                                                 nrDM = nrDM + 1
  2033.                                                 local playerName = xmlNodeGetAttribute (data,"playerName")
  2034.                                                 allPlayersData[nrDM] = {pName = playerName or "???",dType = ratio or 0}
  2035.                                         end
  2036.                                 else
  2037.                                         local playerData = tonumber(xmlNodeGetAttribute (data,datatype))
  2038.                                         local playerName = xmlNodeGetAttribute (data,"playerName")
  2039.                                         allPlayersData[i] = {pName = playerName or "???",dType = playerData or 0}
  2040.                                 end
  2041.                         end            
  2042.                         xmlUnloadFile (root)   
  2043.                         return allPlayersData
  2044.                 end
  2045.         end
  2046. end
  2047.  
  2048. ------------------------------------------
  2049. -- Kick All
  2050. ------------------------------------------
  2051. function kickAllPlayers ( sourcePlayer, commandname )
  2052.         if ( hasObjectPermissionTo ( sourcePlayer, "function.kickPlayer" ) ) then
  2053.                 outputChatBox("#00AAFF# #FFFFFFScript restarting... Auto-Reconnecting in 5 seconds!", gRoot, 255,255,255,true)
  2054.                 setTimer(function()
  2055.                         for i,pla in ipairs(getElementsByType("player")) do
  2056.                                 redirectPlayer (  pla, "213.189.52.40",22069)
  2057.                         end
  2058.                 end, 5000,1)
  2059.         end
  2060. end
  2061. addCommandHandler ( "kickAllPlayers", kickAllPlayers )
  2062.  
  2063.  
  2064.  
  2065.  
  2066.  
  2067. --------------------------
  2068. -- Retrieve player's point's
  2069. --------------------------
  2070.  
  2071. function retrievePoint(thePlayer)
  2072.         local playerPoint = loadPlayerData(thePlayer,"point")
  2073.         callClientFunction(thePlayer,"checkPoint",playerPoint)
  2074. end
  2075.  
  2076.  
  2077. function retrievePointVeh(thePlayer)
  2078.         local playerPoint = loadPlayerData(thePlayer,"point")
  2079.         callClientFunction(thePlayer,"checkPointVeh",playerPoint)
  2080. end
  2081.  
  2082.  
  2083.  
  2084.  
  2085.  
  2086.  
  2087. ------------------------------------------
  2088. -- Triggering
  2089. ------------------------------------------
  2090. function callClientFunction(client, funcname, ...)
  2091.     local arg = { ... }
  2092.     if (arg[1]) then
  2093.         for key, value in next, arg do
  2094.             if (type(value) == "number") then arg[key] = tostring(value) end
  2095.         end
  2096.     end
  2097.     triggerClientEvent(client, "onServerCallsClientFunction", getResourceRootElement(getThisResource()), funcname, unpack(arg or {}))
  2098. end
  2099. function callServerFunction(funcname, ...)
  2100.     local arg = { ... }
  2101.     if (arg[1]) then
  2102.         for key, value in next, arg do arg[key] = tonumber(value) or value end
  2103.     end
  2104.     loadstring("return "..funcname)()(unpack(arg))
  2105. end
  2106. addEvent("onClientCallsServerFunction", true)
  2107. addEventHandler("onClientCallsServerFunction", getResourceRootElement(getThisResource()) , callServerFunction)
  2108.  
  2109. function math.round(number, decimals, method)
  2110.     decimals = decimals or 0
  2111.     local factor = 10 ^ decimals
  2112.     if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
  2113.     else return tonumber(("%."..decimals.."f"):format(number)) end
  2114.                             end
  2115.        
  2116.  
  2117. --------------------------------------------
  2118. -- Get alive and dead players by their STATE
  2119. --------------------------------------------
  2120. function getAliveRacePlayers()
  2121.     local alivePlayers = 0
  2122.         for index,player in ipairs(getElementsByType("player")) do
  2123.                 if getElementData(player,"state") == "alive" then
  2124.                         alivePlayers = alivePlayers + 1
  2125.                 end
  2126.         end
  2127.     return alivePlayers
  2128. end
  2129.  
  2130.  
  2131. function getDeadRacePlayers()
  2132.         local deadPlayers = 0
  2133.         for index,player in ipairs(getElementsByType("player")) do
  2134.                 if getElementData(player,"state") == "dead" then
  2135.                         deadPlayers = deadPlayers + 1
  2136.                 end
  2137.         end
  2138.         return deadPlayers
  2139. end
  2140.  
  2141.  
  2142. ------------------------------------------
  2143. -- Nick
  2144. ------------------------------------------
  2145. addEventHandler ("onPlayerJoin",getRootElement(),
  2146. function()
  2147.         local playerName = getPlayerName(source)
  2148.         savePlayerData(source,"playerName",string.gsub(playerName,"#%x%x%x%x%x%x", ""))
  2149. end)
  2150. addEventHandler("onPlayerChangeNick",getRootElement(),
  2151. function (olnick,newnick)
  2152.        
  2153.         savePlayerData(source,"playerName",string.gsub(newnick,"#%x%x%x%x%x%x", ""))
  2154. end)
  2155.  
  2156. --------------------
  2157. --Team Colors Nick--
  2158. --------------------
  2159.  
  2160. function addTeamColor(player)
  2161.         local playerTeam = getPlayerTeam ( player )
  2162.         if ( playerTeam ) then
  2163.                 local r,g,b = getTeamColor ( playerTeam )
  2164.                 local n1 = toHex(r)
  2165.                 local n2 = toHex(g)
  2166.                 local n3 = toHex(b)
  2167.                 if r <= 16 then n1 = "0"..n1 end
  2168.                 if g <= 16 then n2 = "0"..n2 end
  2169.                 if b <= 16 then n3 = "0"..n3 end
  2170.                 return "#"..n1..""..n2..""..n3..""..getPlayerNametagText(player)
  2171.         else
  2172.                 return getPlayerNametagText(player)
  2173.         end
  2174. end
  2175.  
  2176. function toHex ( n )
  2177.     local hexnums = {"0","1","2","3","4","5","6","7",
  2178.                      "8","9","A","B","C","D","E","F"}
  2179.     local str,r = "",n%16
  2180.     if n-r == 0 then str = hexnums[r+1]
  2181.     else str = toHex((n-r)/16)..hexnums[r+1] end
  2182.     return str
  2183. end
  2184.  
  2185. ------------------------------------------
  2186. -- PlayerNameFunctions
  2187. ------------------------------------------
  2188. function getPlayerNameWithoutColorCode (who)
  2189.         local name = getPlayerName(who)
  2190.         local name = string.gsub(name,'#%x%x%x%x%x%x',"")
  2191.         return name
  2192. end
  2193.  
  2194. function getPlayerFromNameWithoutColorCode (name)
  2195.         for i,pla in ipairs(getElementsByType("player")) do
  2196.                 if getPlayerNameWithoutColorCode (pla) == name then
  2197.                         return pla
  2198.                 end
  2199.         end
  2200. end
  2201.  
  2202. function findPlayerByName (name)
  2203.         local player = getPlayerFromName(name)
  2204.         if player then return player end
  2205.         for i, player in ipairs(getElementsByType("player")) do
  2206.                 if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then
  2207.                         return player
  2208.                 end
  2209.         end
  2210. return false
  2211. end
  2212.  
  2213. ------------------
  2214. -- Reaction
  2215. ------------------
  2216. function generateRandomString( charsCount )
  2217.     local str = ""
  2218.     for i = 1, charsCount do
  2219.         local c = string.char( math.random( 100, 122 ) )
  2220.         if i % 2 == 1 then c = string.upper( c ); end
  2221.         str = str .. c
  2222.     end
  2223.     return str
  2224. end
  2225.     function Starter( _, _, count )
  2226.         WIN_WORD = generateRandomString( tonumber( count ) or 10 )
  2227.  outputChatBox("#ffffffType #ABCDEF'".. WIN_WORD .."' #ffffffto win money#abcdef!",getRootElement(),0,255,0,true)
  2228. end
  2229.  setTimer(Starter,300000,0)
  2230.  
  2231. addEventHandler( "onPlayerChat", getRootElement(),
  2232.     function( msg, msgType )
  2233.         if msgType == 0 then
  2234.             if WIN_WORD and msg == WIN_WORD then
  2235.                 WIN_WORD = nil;
  2236.                                 local test_random = math.random(100,500)
  2237.                setTimer(outputChatBox,1000,1,"[Reaction] #FFFFFF".. getPlayerName( source ) .. "#ffffff has won [#abcdef"..tostring(test_random).."$#FFFFFF] for reaction!", getRootElement(), 0, 255, 0, true )
  2238.                savePlayerData (source,"cash",loadPlayerData(source,"cash") +test_random)
  2239.             end
  2240.         end
  2241.     end
  2242. )