Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --~~~~~~~~~~~~~~~~~~~~~
- -- Levels
- --~~~~~~~~~~~~~~~~~~~~~
- -- Set prices
- level1 = 0
- level2 = 1000
- level3 = 2000
- level4 = 3000
- level5 = 4000
- level6 = 5000
- level7 = 6000
- level8 = 7000
- level9 = 8000
- level10 = 9000
- level11 = 10000
- level12 = 11000
- level13 = 12000
- level14 = 13000
- level15 = 14000
- level16 = 15000
- level17 = 16000
- level18 = 17000
- level19 = 18000
- level20 = 19000
- level21 = 20000
- level22 = 21000
- level23 = 22000
- level24 = 23000
- level25 = 24000
- level26 = 25000 -- Level 10 ELITE
- level27 = 28000
- level28 = 31000
- level29 = 34000
- level30 = 37000
- level31 = 40000
- level32 = 43000
- level33 = 46000
- level34 = 49000
- level35 = 52000
- level36 = 55000
- level37 = 58000
- level38 = 61000
- level39 = 64000
- level40 = 67000
- level41 = 70000 -- Level 25 ELITE
- -- Prices for levels again [new version of level system requires this]
- levelPrices = {0,1000,2000,3000,4000,5000,6000,7000,8000,9000,10000,11000,12000,13000,14000,15000,16000,17000,18000,19000,20000,21000,22000,23000,24000,25000,28000,31000,34000,37000,40000,43000,46000,49000,52000,55000,58000,61000,64000,67000,70000}
- -- String.random characters
- chars = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","r","s","t","u","v","w","x","y","z","1","2","3","4","5","6","7","8","9","0"}
- specialLevelNames = {
- "10 ELITE",
- "11 ELITE",
- "12 ELITE",
- "13 ELITE",
- "14 ELITE",
- "15 ELITE",
- "16 ELITE",
- "17 ELITE",
- "18 ELITE",
- "19 ELITE",
- "20 ELITE",
- "21 ELITE",
- "22 ELITE",
- "23 ELITE",
- "24 ELITE",
- "25 ELITE"}
- -- Set special names - display
- nlevel26 = "10 ELITE"
- nlevel27 = "11 ELITE"
- nlevel28 = "12 ELITE"
- nlevel29 = "13 ELITE"
- nlevel30 = "14 ELITE"
- nlevel31 = "15 ELITE"
- nlevel32 = "16 ELITE"
- nlevel33 = "17 ELITE"
- nlevel34 = "18 ELITE"
- nlevel35 = "19 ELITE"
- nlevel36 = "20 ELITE"
- nlevel37 = "21 ELITE"
- nlevel38 = "22 ELITE"
- nlevel39 = "23 ELITE"
- nlevel40 = "24 ELITE"
- nlevel41 = "25 ELITE"
- -- Set special names - image
- ilevel1 = "levels/LEVEL1.png"
- ilevel2 = "levels/LEVEL2.png"
- ilevel3 = "levels/LEVEL3.png"
- ilevel4 = "levels/LEVEL4.png"
- ilevel5 = "levels/LEVEL5.png"
- ilevel6 = "levels/LEVEL6.png"
- ilevel7 = "levels/LEVEL7.png"
- ilevel8 = "levels/LEVEL8.png"
- ilevel9 = "levels/LEVEL9.png"
- ilevel10 = "levels/LEVEL10.png"
- ilevel11 = "levels/LEVEL11.png"
- ilevel12 = "levels/LEVEL12.png"
- ilevel13 = "levels/LEVEL13.png"
- ilevel14 = "levels/LEVEL14.png"
- ilevel15 = "levels/LEVEL15.png"
- ilevel16 = "levels/LEVEL16.png"
- ilevel17 = "levels/LEVEL17.png"
- ilevel18 = "levels/LEVEL18.png"
- ilevel19 = "levels/LEVEL19.png"
- ilevel20 = "levels/LEVEL20.png"
- ilevel21 = "levels/LEVEL21.png"
- ilevel22 = "levels/LEVEL22.png"
- ilevel23 = "levels/LEVEL23.png"
- ilevel24 = "levels/LEVEL24.png"
- ilevel25 = "levels/LEVEL25.png"
- ilevel26 = "levels/LEVEL10ELITE.png"
- ilevel27 = "levels/LEVEL11ELITE.png"
- ilevel28 = "levels/LEVEL12ELITE.png"
- ilevel29 = "levels/LEVEL13ELITE.png"
- ilevel30 = "levels/LEVEL14ELITE.png"
- ilevel31 = "levels/LEVEL15ELITE.png"
- ilevel32 = "levels/LEVEL16ELITE.png"
- ilevel33 = "levels/LEVEL17ELITE.png"
- ilevel34 = "levels/LEVEL18ELITE.png"
- ilevel35 = "levels/LEVEL19ELITE.png"
- ilevel36 = "levels/LEVEL20ELITE.png"
- ilevel37 = "levels/LEVEL21ELITE.png"
- ilevel38 = "levels/LEVEL22ELITE.png"
- ilevel39 = "levels/LEVEL23ELITE.png"
- ilevel40 = "levels/LEVEL24ELITE.png"
- ilevel41 = "levels/LEVEL25ELITE.png"
- --~~~~~~~~~~~~~~
- -- max 41 levels
- --~~~~~~~~~~~~~~
- -----------
- -- Settings
- -----------
- betPerLevel = 30 -- Limits the amount of money you can bet. (PlayerLevel*betPerLevel = maxBet).
- betTimeLimit = 40 -- Duration of the betting period in seconds.
- minPlayers = 1 -- Minimum required players to bet.
- mapLevel = 10 -- Minimum level required to set maps.
- mapCost = 4000 -- The price for setting maps.
- skinLevel = 13 -- Minimum level required to buy skins.
- skinCost = 1300 -- The price of skins.
- nametagLevel = 15 -- Minimum level to buy a nametag color.
- nametagPrice = 2000 -- Price for buying a nametag color.
- hornLevel = 10 -- Minimum level to buy different horn styles.
- moneyEarnPart = 30 -- The amount of money to calculate with to get the final money to give to the player.
- reactionMin = 320 -- Minimum money for the reaction test
- reactionMax = 660 -- Maximum money for the reaction test
- reactionDuration = 20 -- Duration of the reaction test in seconds
- reactionMinRedo = 100 -- Minimum amount of time to pass before a new reaction test is started in seconds
- reactionMaxRedo = 200 -- Maximum amount of time to pass before a new reaction test is started in seconds
- reactionLength = 6 -- Number of characters to use in the reaction test
- function onResourceStart()
- mapIsAlreadySet = false
- reactionString = ""
- reactionMoney = 0
- setTimer(newReactionTest,math.random(reactionMinRedo*1000,reactionMaxRedo*1000),1)
- outputDebugString("Resource is restarting, please stand by...")
- setTimer(outputDebugString,700,1,"Resource sucessfully started: ~AG~ Script [Author: NeXTreme] ")
- end
- addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),onResourceStart)
- -- Prices for each horn
- hornPrice={2000,4000,6000,8000,10000,15000,20000}
- ---------------
- -- Level system
- ---------------
- function newLevelSystem(thePlayer)
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- if not (playerLevel == 41) then
- if (playerCash >= levelPrices[playerLevel+1]) then
- savePlayerData(thePlayer,"cash",playerCash-levelPrices[playerLevel+1])
- savePlayerData(thePlayer,"level",playerLevel+1)
- if (playerLevel+1 > 25) then
- outputChatBox("#00BFFF* #FFFFFFCongratulations#00BFFF!#FFFFFF You are now level #ABCDEF"..specialLevelNames[playerLevel-24].."#FFFFFF!",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF has levelled up! He/She is now level#FF0000 "..specialLevelNames[playerLevel-24].."#FFFFFF!",getRootElement(),255,255,255,true)
- else
- outputChatBox("#00BFFF* #FFFFFFCongratulations#00BFFF!#FFFFFF You are now level #ABCDEF"..playerLevel+1 .."#FFFFFF!",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF has levelled up! He/She is now level#FF0000 "..playerLevel+1 .."#FFFFFF!",getRootElement(),255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFYou need another #ABCDEF$"..levelPrices[playerLevel+1]-playerCash.."#FFFFFF to advance to the next level!",thePlayer,255,255,255,true)
- levelAchievements(thePlayer)
- return false
- end
- else
- outputChatBox("#00BFFF* #FFFFFFYou have reached the maximum possible level! #00BFFF[#FFFFFF Level 25 #FFFF00ELITE #00BFFF]",thePlayer,255,255,255,true)
- return false
- end
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- if (playerLevel == 25) then
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#FF0000-------------------------------------",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFFYou have reached level #FF000025#FFFFFF!",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFFYou can now start again from level 10 in #FFFF00ELITE #FFFFFFmode!",thePlayer,255,255,255,true)
- outputChatBox("#FF0000-------------------------------------",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- elseif (playerLevel == 26) then
- outputChatBox("#00BFFF* #FFFFFFYou now earn more money from winning and setting new top hunter times!",thePlayer,255,255,255,true)
- elseif (playerLevel == 41) then
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF---------------------------------------",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF* Congratulations on reaching level #FFFF0025 ELITE#00BFFF!",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF* You have reached the maximum level!",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF---------------------------------------",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF",thePlayer,255,255,255,true)
- end
- scoreboardRefresh(thePlayer)
- refreshStats(thePlayer)
- progressBarUpdate(thePlayer)
- levelAchievements(thePlayer)
- end
- -- Disable voting
- function disableVote()
- cancelEvent()
- end
- addCommandHandler("voteredo",disableVote)
- addCommandHandler("new",disableVote)
- -----------------------------------------------------------------------------------
- -----------------------------------| USERPANEL |-----------------------------------
- -----------------------------------------------------------------------------------
- ----------------------------
- -- Userpanel - Refresh stats
- ----------------------------
- function refreshStats(thePlayer)
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local unlockedAchievements = tonumber(loadPlayerData(thePlayer,"unlockedAchievements"))
- local totalTimesJoined = tonumber(loadPlayerData(thePlayer,"totalTimesJoined"))
- local mapsWon = tonumber(loadPlayerData(thePlayer,"mapsWon"))
- local mapsPlayed = tonumber(loadPlayerData(thePlayer,"mapsPlayed"))
- local totalHunters = tonumber(loadPlayerData(thePlayer,"totalHunters"))
- local totalToptimes = tonumber(loadPlayerData(thePlayer,"totalToptimes"))
- local totalMoneyEarned = tonumber(loadPlayerData(thePlayer,"totalMoneyEarned"))
- local totalMoneySent = tonumber(loadPlayerData(thePlayer,"totalMoneySent"))
- local totalBets = tonumber(loadPlayerData(thePlayer,"totalBets"))
- local totalBetsEarned = tonumber(loadPlayerData(thePlayer,"totalBetsEarned"))
- local totalBetsWon = tonumber(loadPlayerData(thePlayer,"totalBetsWon"))
- local totalDeaths = tonumber(loadPlayerData(thePlayer,"totalDeaths"))
- local totalPlayingTimeMinutes = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeMinutes"))
- local totalPlayingTimeHours = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeHours"))
- local totalReactionTests = tonumber(loadPlayerData(thePlayer,"totalReactionTests"))
- local bestReactionTime = tonumber(loadPlayerData(thePlayer,"bestReactionTime"))
- levelImage = getRankingImage(playerLevel)
- levelDisplay = getEliteName(playerLevel)
- local winRatio = 0
- if mapsPlayed == 0 and mapsWon == 0 then
- winRatio = 0
- elseif mapsPlayed ~= 0 and mapsWon == 0 then
- winRatio = 0
- elseif mapsPlayed ~= 0 and mapsWon ~= 0 then
- winRatio = math.round(((100/mapsPlayed)*mapsWon),2)
- elseif mapsWon > mapsPlayed then
- winRatio = 0
- end
- callClientFunction(thePlayer,"refreshStats",levelDisplay,levelImage,playerCash,unlockedAchievements,totalTimesJoined,mapsWon,mapsPlayed,winRatio,totalHunters,totalToptimes,totalMoneyEarned,totalMoneySent,totalBets,totalBetsEarned,totalBetsWon,totalDeaths,totalPlayingTimeMinutes,totalPlayingTimeHours,totalReactionTests,bestReactionTime)
- end
- function getEliteName(playerLevel)
- local levelDisplay = ""
- if playerLevel == 26 then
- levelDisplay = nlevel26
- elseif playerLevel == 27 then
- levelDisplay = nlevel27
- elseif playerLevel == 28 then
- levelDisplay = nlevel28
- elseif playerLevel == 29 then
- levelDisplay = nlevel29
- elseif playerLevel == 30 then
- levelDisplay = nlevel30
- elseif playerLevel == 31 then
- levelDisplay = nlevel31
- elseif playerLevel == 32 then
- levelDisplay = nlevel32
- elseif playerLevel == 33 then
- levelDisplay = nlevel33
- elseif playerLevel == 34 then
- levelDisplay = nlevel34
- elseif playerLevel == 35 then
- levelDisplay = nlevel35
- elseif playerLevel == 36 then
- levelDisplay = nlevel36
- elseif playerLevel == 37 then
- levelDisplay = nlevel37
- elseif playerLevel == 38 then
- levelDisplay = nlevel38
- elseif playerLevel == 39 then
- levelDisplay = nlevel39
- elseif playerLevel == 40 then
- levelDisplay = nlevel40
- elseif playerLevel == 41 then
- levelDisplay = nlevel41
- else
- levelDisplay = playerLevel
- end
- return levelDisplay
- end
- function getRankingImage(playerLevel)
- local levelImage = ""
- if playerLevel == 1 then
- levelImage = ilevel1
- elseif playerLevel == 2 then
- levelImage = ilevel2
- elseif playerLevel == 3 then
- levelImage = ilevel3
- elseif playerLevel == 4 then
- levelImage = ilevel4
- elseif playerLevel == 5 then
- levelImage = ilevel5
- elseif playerLevel == 6 then
- levelImage = ilevel6
- elseif playerLevel == 7 then
- levelImage = ilevel7
- elseif playerLevel == 8 then
- levelImage = ilevel8
- elseif playerLevel == 9 then
- levelImage = ilevel9
- elseif playerLevel == 10 then
- levelImage = ilevel10
- elseif playerLevel == 11 then
- levelImage = ilevel11
- elseif playerLevel == 12 then
- levelImage = ilevel12
- elseif playerLevel == 13 then
- levelImage = ilevel13
- elseif playerLevel == 14 then
- levelImage = ilevel14
- elseif playerLevel == 15 then
- levelImage = ilevel15
- elseif playerLevel == 16 then
- levelImage = ilevel16
- elseif playerLevel == 17 then
- levelImage = ilevel17
- elseif playerLevel == 18 then
- levelImage = ilevel18
- elseif playerLevel == 19 then
- levelImage = ilevel19
- elseif playerLevel == 20 then
- levelImage = ilevel20
- elseif playerLevel == 21 then
- levelImage = ilevel21
- elseif playerLevel == 22 then
- levelImage = ilevel22
- elseif playerLevel == 23 then
- levelImage = ilevel23
- elseif playerLevel == 24 then
- levelImage = ilevel24
- elseif playerLevel == 25 then
- levelImage = ilevel25
- elseif playerLevel == 26 then
- levelImage = ilevel26
- elseif playerLevel == 27 then
- levelImage = ilevel27
- elseif playerLevel == 28 then
- levelImage = ilevel28
- elseif playerLevel == 29 then
- levelImage = ilevel29
- elseif playerLevel == 30 then
- levelImage = ilevel30
- elseif playerLevel == 31 then
- levelImage = ilevel31
- elseif playerLevel == 32 then
- levelImage = ilevel32
- elseif playerLevel == 33 then
- levelImage = ilevel33
- elseif playerLevel == 34 then
- levelImage = ilevel34
- elseif playerLevel == 35 then
- levelImage = ilevel35
- elseif playerLevel == 36 then
- levelImage = ilevel36
- elseif playerLevel == 37 then
- levelImage = ilevel37
- elseif playerLevel == 38 then
- levelImage = ilevel38
- elseif playerLevel == 39 then
- levelImage = ilevel39
- elseif playerLevel == 40 then
- levelImage = ilevel40
- elseif playerLevel == 41 then
- levelImage = ilevel41
- else
- levelImage = ""
- end
- return levelImage
- end
- function refreshStatsCall()
- local thePlayer = source
- refreshStats(thePlayer)
- end
- addEventHandler("onPlayerJoin",getRootElement(),refreshStatsCall)
- addEventHandler("onPlayerWasted",getRootElement(),refreshStatsCall)
- function triggerRebuildPlayerGridlist()
- setTimer(callClientFunction,1000,1,getRootElement(),"refreshConnectedPlayers")
- end
- addEventHandler("onPlayerChangeNick",getRootElement(),triggerRebuildPlayerGridlist)
- addEventHandler("onPlayerJoin",getRootElement(),triggerRebuildPlayerGridlist)
- addEventHandler("onPlayerQuit",getRootElement(),triggerRebuildPlayerGridlist)
- -------------------------------------------
- -- Userpanel - handle requests from clients
- -------------------------------------------
- function checkForFirstTimeJoined(thePlayer)
- local joinedBefore = tonumber(loadPlayerData(thePlayer,"joinedBefore"))
- if joinedBefore == 0 then
- callClientFunction(thePlayer,"welcomeProcedureHandler","openWindow")
- setTimer(callClientFunction,1000,1,thePlayer,"performSettingsUpdate")
- savePlayerData(thePlayer,"joinedBefore",1)
- outputChatBox("#00BFFF* #FFFFFFWelcome to AG Race DD/DM server, "..getPlayerName(thePlayer.."#FFFFFF!",thePlayer,255,255,255,true))
- end
- end
- function getDataOnStart(thePlayer)
- local pName = loadPlayerData(thePlayer,"pName")
- local pAge = loadPlayerData(thePlayer,"pAge")
- local pEmail = loadPlayerData(thePlayer,"pEmail")
- local pMsn = loadPlayerData(thePlayer,"pMsn")
- local pSkype = loadPlayerData(thePlayer,"pSkype")
- local pXfire = loadPlayerData(thePlayer,"pXfire")
- local pICQ = loadPlayerData(thePlayer,"pICQ")
- local pXBL = loadPlayerData(thePlayer,"pXBL")
- callClientFunction(thePlayer,"setDataOnStart",pName,pAge,pEmail,pMsn,pSkype,pXfire,pICQ,pXBL)
- end
- function getPersonalDetails(requestingPlayer,thePlayerName)
- local thePlayer = findPlayerByName(thePlayerName)
- local allowPersonalDetails = loadPlayerData(thePlayer,"allowPersonalDetails")
- if allowPersonalDetails == tostring(true) or tonumber(allowPersonalDetails) == 0 then
- local pName = loadPlayerData(thePlayer,"pName")
- local pAge = loadPlayerData(thePlayer,"pAge")
- local pEmail = loadPlayerData(thePlayer,"pEmail")
- local pMsn = loadPlayerData(thePlayer,"pMsn")
- local pSkype = loadPlayerData(thePlayer,"pSkype")
- local pXfire = loadPlayerData(thePlayer,"pXfire")
- local pICQ = loadPlayerData(thePlayer,"pICQ")
- local pXBL = loadPlayerData(thePlayer,"pXBL")
- callClientFunction(requestingPlayer,"displayPersonalDetails",pName,pAge,pEmail,pMsn,pSkype,pXfire,pICQ,pXBL)
- else
- outputChatBox("#00BFFF* #FFFFFFThe other player has disabled viewing his personal details!",requestingPlayer,255,255,255,true)
- end
- end
- function getPlayerRaceStats(requestingPlayer,thePlayerName)
- local thePlayer = findPlayerByName(thePlayerName)
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local unlockedAchievements = tonumber(loadPlayerData(thePlayer,"unlockedAchievements"))
- local totalTimesJoined = tonumber(loadPlayerData(thePlayer,"totalTimesJoined"))
- local mapsWon = tonumber(loadPlayerData(thePlayer,"mapsWon"))
- local mapsPlayed = tonumber(loadPlayerData(thePlayer,"mapsPlayed"))
- local totalHunters = tonumber(loadPlayerData(thePlayer,"totalHunters"))
- local totalToptimes = tonumber(loadPlayerData(thePlayer,"totalToptimes"))
- local totalMoneyEarned = tonumber(loadPlayerData(thePlayer,"totalMoneyEarned"))
- local totalMoneySent = tonumber(loadPlayerData(thePlayer,"totalMoneySent"))
- local totalBets = tonumber(loadPlayerData(thePlayer,"totalBets"))
- local totalBetsEarned = tonumber(loadPlayerData(thePlayer,"totalBetsEarned"))
- local totalBetsWon = tonumber(loadPlayerData(thePlayer,"totalBetsWon"))
- local totalDeaths = tonumber(loadPlayerData(thePlayer,"totalDeaths"))
- local totalPlayingTimeMinutes = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeMinutes"))
- local totalPlayingTimeHours = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeHours"))
- end
- -- Chat system
- function playerChatHandler(sendingPlayer,sendToPlayer,message)
- sendingPlayer = (string.gsub(getPlayerName(sendingPlayer),"#%x%x%x%x%x%x", ""))
- callClientFunction(findPlayerByName(sendingPlayer),"addPlayerChatText",sendingPlayer,message)
- callClientFunction(sendToPlayer,"addPlayerChatText",sendingPlayer,message)
- callClientFunction(findPlayerByName(sendingPlayer),"resetInputField")
- end
- function chatModeHandler(requestingPlayer,targetPlayer)
- local currentChatRequestingPlayer = getElementData(requestingPlayer,"isPlayerInChat")
- local currentChatTargetPlayer = getElementData(targetPlayer,"isPlayerInChat")
- if not (currentChatRequestingPlayer == true) then
- if not (currentChatTargetPlayer == true) then
- callClientFunction(targetPlayer,"showChatWindows",1,requestingPlayer,targetPlayer)
- callClientFunction(requestingPlayer,"showChatWindows",2,requestingPlayer,targetPlayer)
- else
- outputChatBox("#00BFFF* #FFFFFFThat player is already in a chat! You cannot chat with him/her.",requestingPlayer,255,255,255,true)
- end
- else
- chatModeDisable(requestingPlayer,targetPlayer)
- end
- end
- function chatErrorResponse(keyCode,requestingPlayer,targetPlayer)
- if keyCode == 1 then
- outputChatBox("#00BFFF* #FFFFFFERROR! Somebody else has requested to chat with that player!",targetPlayer,255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFFPlease try again later!",targetPlayer,255,255,255,true)
- end
- end
- function chatModeEnable(requestingPlayer,targetPlayer)
- setElementData(requestingPlayer,"isPlayerInChat",true)
- setElementData(targetPlayer,"isPlayerInChat",true)
- callClientFunction(requestingPlayer,"setChatMode",1,targetPlayer)
- callClientFunction(targetPlayer,"setChatMode",1,requestingPlayer)
- end
- function chatModeDisable(requestingPlayer,targetPlayer)
- setElementData(requestingPlayer,"isPlayerInChat",false)
- setElementData(targetPlayer,"isPlayerInChat",false)
- callClientFunction(requestingPlayer,"setChatMode",0,targetPlayer)
- callClientFunction(targetPlayer,"setChatMode",0,requestingPlayer)
- end
- function chatModeForceDisable(requestingPlayer,targetPlayer)
- setElementData(targetPlayer,"isPlayerInChat",false)
- callClientFunction(targetPlayer,"setChatMode",0,requestingPlayer)
- end
- function acceptChatInvite(requestingPlayer,targetPlayer)
- chatModeEnable(requestingPlayer,targetPlayer)
- callClientFunction(targetPlayer,"setBusyStatus",2)
- callClientFunction(requestingPlayer,"setBusyStatus",2)
- callClientFunction(targetPlayer,"showChatWindows",1,requestingPlayer,targetPlayer)
- callClientFunction(requestingPlayer,"showChatWindows",2,requestingPlayer,targetPlayer)
- end
- function declineChatInvite(requestingPlayer,targetPlayer)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(targetPlayer).." #FFFFFFhas declined your chat invitation!",requestingPlayer,255,255,255,true)
- callClientFunction(targetPlayer,"setBusyStatus",2)
- callClientFunction(requestingPlayer,"setBusyStatus",2)
- callClientFunction(targetPlayer,"showChatWindows",1,requestingPlayer,targetPlayer)
- callClientFunction(requestingPlayer,"showChatWindows",2,requestingPlayer,targetPlayer)
- end
- function cancelChatInvite(requestingPlayer,targetPlayer)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(targetPlayer).."#FFFFFF has cancelled their chat invititation.",requestingPlayer,255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFFYou've cancelled your chat invititation.",targetPlayer,255,255,255,true)
- callClientFunction(targetPlayer,"setBusyStatus",2)
- callClientFunction(requestingPlayer,"setBusyStatus",2)
- callClientFunction(targetPlayer,"showChatWindows",2,requestingPlayer,targetPlayer)
- callClientFunction(requestingPlayer,"showChatWindows",1,requestingPlayer,targetPlayer)
- end
- function resetElementData()
- setElementData(source,"isPlayerInChat",false)
- end
- addEventHandler("onPlayerJoin",getRootElement(),resetElementData)
- function quitChatHandler(quitType)
- callClientFunction(getRootElement(),"quitChatHandler",source,quitType)
- end
- addEventHandler("onPlayerQuit",getRootElement(),quitChatHandler)
- -- Stats view
- function getPlayerStats(triggeringPlayer,thePlayer)
- local allowStats = loadPlayerData(thePlayer,"allowStats")
- if allowStats == tostring(true) or tonumber(allowStats) == 0 then
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local unlockedAchievements = tonumber(loadPlayerData(thePlayer,"unlockedAchievements"))
- local totalTimesJoined = tonumber(loadPlayerData(thePlayer,"totalTimesJoined"))
- local mapsWon = tonumber(loadPlayerData(thePlayer,"mapsWon"))
- local mapsPlayed = tonumber(loadPlayerData(thePlayer,"mapsPlayed"))
- local totalHunters = tonumber(loadPlayerData(thePlayer,"totalHunters"))
- local totalToptimes = tonumber(loadPlayerData(thePlayer,"totalToptimes"))
- local totalMoneyEarned = tonumber(loadPlayerData(thePlayer,"totalMoneyEarned"))
- local totalMoneySent = tonumber(loadPlayerData(thePlayer,"totalMoneySent"))
- local totalBets = tonumber(loadPlayerData(thePlayer,"totalBets"))
- local totalBetsEarned = tonumber(loadPlayerData(thePlayer,"totalBetsEarned"))
- local totalBetsWon = tonumber(loadPlayerData(thePlayer,"totalBetsWon"))
- local totalDeaths = tonumber(loadPlayerData(thePlayer,"totalDeaths"))
- local totalPlayingTimeMinutes = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeMinutes"))
- local totalPlayingTimeHours = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeHours"))
- local totalReactionTests = tonumber(loadPlayerData(thePlayer,"totalReactionTests"))
- local bestReactionTime = tonumber(loadPlayerData(thePlayer,"bestReactionTime"))
- levelImage = getRankingImage(playerLevel)
- levelDisplay = getEliteName(playerLevel)
- local winRatio = 0
- if mapsPlayed == 0 and mapsWon == 0 then
- winRatio = 0
- elseif mapsPlayed ~= 0 and mapsWon == 0 then
- winRatio = 0
- elseif mapsPlayed ~= 0 and mapsWon ~= 0 then
- winRatio = math.round(((100/mapsPlayed)*mapsWon),2)
- elseif mapsWon > mapsPlayed then
- winRatio = 0
- end
- callClientFunction(triggeringPlayer,"displayPersonalStats",thePlayer,levelDisplay,levelImage,playerCash,unlockedAchievements,totalTimesJoined,mapsWon,mapsPlayed,winRatio,totalHunters,totalToptimes,totalMoneyEarned,totalMoneySent,totalBets,totalBetsEarned,totalBetsWon,totalDeaths,totalPlayingTimeMinutes,totalPlayingTimeHours,totalReactionTests,bestReactionTime)
- else
- outputChatBox("#00BFFF* #FFFFFFThe other player has disabled viewing his stats!",triggeringPlayer,255,255,255,true)
- end
- end
- -- Maps
- function getServerMaps (loadList)
- local tableOut
- if loadList then
- tableOut = {}
- -- local deletedMaps = {}
- local gamemodes = {}
- gamemodes = call(getResourceFromName("mapmanager"), "getGamemodes")
- for id,gamemode in ipairs (gamemodes) do
- tableOut[id] = {}
- tableOut[id].name = getResourceInfo(gamemode, "name") or getResourceName(gamemode)
- tableOut[id].resname = getResourceName(gamemode)
- tableOut[id].maps = {}
- local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode" , gamemode)
- for _,map in ipairs (maps) do
- table.insert(tableOut[id]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)})
- end
- table.sort(tableOut[id]["maps"], sortCompareFunction)
- end
- table.sort((tableOut), sortCompareFunction)
- table.insert(tableOut, {name = "no gamemode", resname = "no gamemode", maps = {}})
- local countGmodes = #tableOut
- local maps = call(getResourceFromName("mapmanager"), "getMapsCompatibleWithGamemode")
- for id,map in ipairs (maps) do
- -- if fileOpen(":"..getResourceName(map).."/deleted") then
- -- table.insert(deletedMaps ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)})
- -- else
- table.insert(tableOut[countGmodes]["maps"] ,{name = getResourceInfo(map, "name") or getResourceName(map), resname = getResourceName(map)})
- -- end
- end
- -- table.sort(deletedMaps, sortCompareFunction)
- table.sort(tableOut[countGmodes]["maps"], sortCompareFunction)
- -- table.insert(tableOut, {name = "deleted maps", resname = "deleted maps", maps = {}})
- -- local countGmodes = countGmodes + 1
- -- tableOut[countGmodes]["maps"] = deletedMaps
- end
- local map = call(getResourceFromName("mapmanager"), "getRunningGamemodeMap")
- local gamemode = call(getResourceFromName("mapmanager"), "getRunningGamemode")
- gamemode = gamemode and getResourceName(gamemode) or "N/A"
- map = map and getResourceName(map) or "N/A"
- callClientFunction(loadList,"loadMaps", tableOut, gamemode, map)
- end
- function sortCompareFunction(s1, s2)
- if type(s1) == "table" and type(s2) == "table" then
- s1, s2 = s1.name, s2.name
- end
- s1, s2 = s1:lower(), s2:lower()
- if s1 == s2 then
- return false
- end
- local byte1, byte2 = string.byte(s1:sub(1,1)), string.byte(s2:sub(1,1))
- if not byte1 then
- return true
- elseif not byte2 then
- return false
- elseif byte1 < byte2 then
- return true
- elseif byte1 == byte2 then
- return sortCompareFunction(s1:sub(2), s2:sub(2))
- else
- return false
- end
- end
- function callGetMaps()
- for i,player in ipairs(getElementsByType("player")) do
- callClientFunction(player,"getMaps")
- end
- end
- addCommandHandler("rebuildMaps",callGetMaps)
- -- Buy a next map
- -- function buyMap(thePlayer,mapName)
- -- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- -- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- -- if mapIsAlreadySet == false then
- -- if not (mapName == "") then
- -- if playerLevel >= mapLevel then
- -- if playerCash >= mapCost then
- -- triggerEvent("onExternalNextmapRequest",thePlayer,thePlayer,mapName)
- -- else
- -- outputChatBox("#FF6600* #FFFFFFYou don't have enough money to set a map!",thePlayer,255,255,255,true)
- -- end
- -- else--
- -- outputChatBox("#FF6600* #FFFFFFYou need to be level #ABCDEF"..mapLevel.." #FFFFFFor higher to set maps!",thePlayer,255,255,255,true)
- -- end
- -- else
- -- outputChatBox("#FF6600* #FFFFFFPlease select a map from the list first!",thePlayer,255,255,255,true)
- -- end
- -- else
- -- outputChatBox("#FF6600* #FFFFFFA map is already set at the moment! Please try again later.",thePlayer,255,255,255,true)
- -- end
- -- end
- function resetMapSetStatus()
- mapIsAlreadySet = false
- end
- addEventHandler("onMapStarting",getRootElement(),resetMapSetStatus)
- g_Root = getRootElement()
- g_Tick = {}
- g_MapInfo = nil
- lastmap_B = nil
- addEvent('onMapStarting')
- addEventHandler('onMapStarting', g_Root,
- function(mapInfo)
- g_MapInfo = mapInfo
- mapIsAlreadySet = false
- end
- )
- function findMap( query )
- local maps = findMaps( query )
- -- Make status string
- local status = "Found " .. #maps .. " match" .. ( #maps==1 and "" or "es" )
- for i=1,math.min(5,#maps) do
- status = status .. ( i==1 and ": " or ", " ) .. "'" .. getMapName( maps[i] ) .. "'"
- end
- if #maps > 5 then
- status = status .. " (" .. #maps - 5 .. " more)"
- end
- if #maps == 0 then
- return nil, status .. " for '" .. query .. "'"
- end
- if #maps == 1 then
- return maps[1], status
- end
- if #maps > 1 then
- return nil, status
- end
- end
- -- Find all maps which match the query string
- function findMaps( query )
- local results = {}
- --escape all meta chars
- query = string.gsub(query, "([%*%+%?%.%(%)%[%]%{%}%\%/%|%^%$%-])","%%%1")
- -- Loop through and find matching maps
- for i,resource in ipairs(exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource())) do
- local resName = getResourceName( resource )
- local infoName = getMapName( resource )
- -- Look for exact match first
- if query == resName or query == infoName then
- return {resource}
- end
- -- Find match for query within infoName
- if string.find( infoName:lower(), query:lower() ) then
- table.insert( results, resource )
- end
- end
- return results
- end
- addEvent('buyMapFromPanel', true)
- function buyMFP(mapname)
- -- if g_ForcedNextMap then
- -- outputChatBox('Next map is ' ..getMapName(g_ForcedNextMap), source)
- -- return
- -- end
- -- local query = #{mapname}>0 and table.concat({mapname},' ') or nil
- -- if not query then
- -- if g_ForcedNextMap then
- -- outputChatBox('Next map is ' ..getMapName(g_ForcedNextMap), source)
- -- else
- -- outputChatBox('Next map is not set', source, 255, 0, 0)
- -- end
- -- return
- -- end
- -- local map, errormsg = findMap(query)
- -- if not map then
- -- outputChatBox(errormsg, source)
- -- return
- -- end
- -- local playerLevel = tonumber(loadPlayerData(source,"level"))
- -- local playerCash = tonumber(loadPlayerData(source,"cash"))
- -- if playerLevel >= mapLevel then
- -- if playerCash >= mapCost then
- -- if lastmap_B == map then
- -- outputChatBox('That map has been played too much recently.', source, 255, 0, 0)
- -- else
- -- local TotalPlayerCash = playerCash - mapCost
- -- g_ForcedNextMap = map
- -- outputChatBox(getPlayerName(source).. " bought map '" ..getMapName(g_ForcedNextMap).. "' for "..mapCost.."$.", g_Root, 0, 240, 0)
- -- savePlayerData(source,"cash", TotalPlayerCash)
- -- lastmap_B = g_ForcedNextMap
- -- achievement31(source)
- -- scoreboardRefresh(source)
- -- end
- -- else
- -- outputChatBox("#FF6600* #FFFFFFYou don't have enough money to set a map!",source,255,255,255,true)
- -- end
- -- else
- -- outputChatBox("#FF6600* #FFFFFFYou need to be level #ABCDEF"..mapLevel.." #FFFFFFor higher to set maps!",source,255,255,255,true)
- -- end
- buyMap(source, command, mapname)
- end
- addEventHandler('buyMapFromPanel', g_Root, buyMFP)
- function buyMap(player, command, ...)
- if g_ForcedNextMap then
- outputChatBox( 'Next map is ' .. getMapName( g_ForcedNextMap ), player )
- return
- end
- local query = #{...}>0 and table.concat({...},' ') or nil
- if not query then
- if g_ForcedNextMap then
- outputChatBox( 'Next map is ' .. getMapName( g_ForcedNextMap ), player )
- else
- outputChatBox( 'Next map is not set', player, 255, 0, 0 )
- end
- return
- end
- local map, errormsg = findMap(query)
- if not map then
- outputChatBox(errormsg, player)
- return
- end
- local playerLevel = tonumber(loadPlayerData(player,"level"))
- local playerCash = tonumber(loadPlayerData(player,"cash"))
- if playerLevel >= mapLevel then
- if playerCash >= mapCost then
- if lastmap_B == map then
- outputChatBox( 'That map has been played too much recently.', player, 255, 0, 0 )
- else
- g_ForcedNextMap = map
- local TotalPlayerCash = playerCash - mapCost
- outputChatBox("#007FFF[Map]#FFFFFF" ..getPlayerName(player).. "#FFFFFF set '#007FFF" ..getMapName(g_ForcedNextMap).."#FFFFFF' as nextmap.", getRootElement(), 0, 240, 0, true)
- savePlayerData(player,"cash", TotalPlayerCash)
- lastmap_B = g_ForcedNextMap
- achievement31(player)
- scoreboardRefresh(player)
- end
- else
- outputChatBox("#FF6600* #FFFFFFYou don't have enough money to set a map!",source,255,255,255,true)
- end
- else
- outputChatBox("#FF6600* #FFFFFFYou need to be level #ABCDEF"..mapLevel.." #FFFFFFor higher to set maps!",source,255,255,255,true)
- end
- end
- addCommandHandler('bm', buyMap)
- addCommandHandler('buymap', buyMap)
- addCommandHandler("mapcount",
- function(source)
- local resourceTable = getResources()
- local mapcount = 0
- for resourceKey, resourceValue in ipairs(resourceTable) do
- local type = getResourceInfo(resourceValue, "type")
- local game = getResourceInfo(resourceValue, "gamemodes")
- if type == "map" and game == "race" then
- mapcount = mapcount+1
- else
- cancelEvent()
- end
- end
- outputChatBox("There are " ..tostring(mapcount).. " maps on the server.", source, 46, 154, 254)
- end
- )
- addEvent("onScriptSetNextMap",true)
- addEventHandler("onScriptSetNextMap",getRootElement(),
- function (mapName)
- thePlayer = source
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- savePlayerData(thePlayer,"cash",playerCash-mapCost)
- outputChatBox("#FFFFFFNextmap: "..getPlayerName(thePlayer).."#FFFFFF has bought a next map!",getRootElement(),255,255,255,true)
- outputChatBox("#FFFFFFNextmap: #FF8800"..mapName,getRootElement(),255,255,255,true)
- mapIsAlreadySet = true
- scoreboardRefresh(thePlayer)
- achievement31(thePlayer)
- end)
- addEvent("onRaceSetNextMap",true)
- addEventHandler("onRaceSetNextMap",getRootElement(),
- function ()
- mapIsAlreadySet = true
- end)
- -- Skin handler
- function saveSkin(thePlayer,skinID)
- if (tonumber(loadPlayerData(thePlayer,"cash")) >= skinCost) then
- savePlayerData(thePlayer,"skin",skinID)
- savePlayerData(thePlayer,"cash",tonumber(loadPlayerData(thePlayer,"cash"))-skinCost)
- skinEnabled = loadPlayerData(thePlayer,"useCustomSkin")
- if skinEnabled == "true" then
- setElementModel(thePlayer,skinID)
- end
- outputChatBox("#00BFFF* #FFFFFFYou have sucessfuly purchased the skin! #FFFF00[#FFFFFFID:"..skinID.."#FFFF00]",thePlayer,255,255,255,true)
- setTimer(outputChatBox,700,1,"#00BFFF* #FFFFFFThe skin has been saved to your account.",thePlayer,255,255,255,true)
- savePlayerData(thePlayer,"everPurchasedSkin",1)
- setElementData(thePlayer,"everPurchasedSkin",1)
- scoreboardRefresh(thePlayer)
- achievement38(thePlayer)
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
- end
- end
- function setSkinOnMapStart()
- if tonumber(getElementData(source,"everPurchasedSkin")) == 1 then
- skinEnabled = loadPlayerData(source,"useCustomSkin")
- if skinEnabled == "true" then
- skinID = loadPlayerData(source,"skin")
- setElementModel(source,skinID)
- end
- end
- end
- addEventHandler("onNotifyPlayerReady",getRootElement(),setSkinOnMapStart)
- function checkSkinLevel(thePlayer)
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- if playerLevel >= skinLevel then
- callClientFunction(thePlayer,"openSkinsWindow")
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You need to be level #ABCDEF"..skinLevel.."#FFFFFF or more to change skins!",thePlayer,255,255,255,true)
- end
- end
- -- Options handler
- function saveClientSettings(thePlayer,a,b,c,d,e,f,g,h,i,j)
- outputChatBox("#00BFFF* #FFFFFFYour settings have been saved!",thePlayer,255,255,255,true)
- savePlayerData(thePlayer,"allowPersonalDetails",a)
- savePlayerData(thePlayer,"allowStats",b)
- savePlayerData(thePlayer,"useCustomNametag",c)
- savePlayerData(thePlayer,"useCustomSkin",d)
- savePlayerData(thePlayer,"useCustomVehicleColor",e)
- savePlayerData(thePlayer,"soundMessage",f)
- savePlayerData(thePlayer,"soundRequest",g)
- savePlayerData(thePlayer,"showOnDeath",h)
- savePlayerData(thePlayer,"useHunterSkin",i)
- savePlayerData(thePlayer,"chatAcceptMode",j)
- end
- function getClientSettings(thePlayer)
- a = loadPlayerData(thePlayer,"allowPersonalDetails")
- b = loadPlayerData(thePlayer,"allowStats")
- c = loadPlayerData(thePlayer,"useCustomNametag")
- d = loadPlayerData(thePlayer,"useCustomSkin")
- e = loadPlayerData(thePlayer,"useCustomVehicleColor")
- f = loadPlayerData(thePlayer,"soundMessage")
- g = loadPlayerData(thePlayer,"soundRequest")
- h = loadPlayerData(thePlayer,"showOnDeath")
- i = loadPlayerData(thePlayer,"useHunterSkin")
- j = loadPlayerData(thePlayer,"chatAcceptMode")
- callClientFunction(thePlayer,"configureOptions",true,a,b,c,d,e,f,g,h,i,j)
- end
- function showUserpanelOnDeath()
- if (loadPlayerData(source,"showOnDeath") == "true") then
- callClientFunction(source,"displayUserpanel")
- end
- end
- addEventHandler("onPlayerWasted",getRootElement(),showUserpanelOnDeath)
- -- Nametag color
- function saveNametagColor(thePlayer,r,g,b)
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- savePlayerData(thePlayer,"cash",playerCash-nametagPrice)
- savePlayerData(thePlayer,"nametagRed",r)
- savePlayerData(thePlayer,"nametagGreen",g)
- savePlayerData(thePlayer,"nametagBlue",b)
- setNametagColor(thePlayer)
- outputChatBox("#00BFFF* #FFFFFFYou have purchased a new nametag color for #ABCDEF$"..nametagPrice.."#FFFFFF!",thePlayer,255,255,255,true)
- savePlayerData(thePlayer,"everPurchasedNametagColor",1)
- setElementData(thePlayer,"everPurchasedNametagColor",1)
- scoreboardRefresh(thePlayer)
- end
- function getNametagLevel(thePlayer)
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- if playerLevel >= nametagLevel then
- callClientFunction(thePlayer,"showNametagWindow")
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You need to be level #ABCDEF"..nametagLevel.."#FFFFFF or higher to change your nametag color!",thePlayer,255,255,255,true)
- end
- end
- function setNametagColor(thePlayer)
- local ifSet = tonumber(getElementData(thePlayer,"everPurchasedNametagColor"))
- if ifSet == 1 then
- local useColor = loadPlayerData(thePlayer,"useCustomNametag")
- if useColor == "true" then
- local r = tonumber(loadPlayerData(thePlayer,"nametagRed"))
- local g = tonumber(loadPlayerData(thePlayer,"nametagGreen"))
- local b = tonumber(loadPlayerData(thePlayer,"nametagBlue"))
- callClientFunction(thePlayer,"setCustomNametagColor",true,r,g,b)
- end
- end
- end
- addEventHandler("onPlayerJoin",getRootElement(),setNametagColor)
- -- Horns
- function getPurchasedHorns(thePlayer)
- local airhorn = tonumber(loadPlayerData(thePlayer,"horn1"))
- local clown = tonumber(loadPlayerData(thePlayer,"horn2"))
- local train = tonumber(loadPlayerData(thePlayer,"horn3"))
- local ship = tonumber(loadPlayerData(thePlayer,"horn4"))
- local submarine = tonumber(loadPlayerData(thePlayer,"horn5"))
- local military = tonumber(loadPlayerData(thePlayer,"horn6"))
- local whoopie = tonumber(loadPlayerData(thePlayer,"horn7"))
- callClientFunction(thePlayer,"updateHorns",thePlayer,airhorn,clown,train,ship,submarine,military,whoopie)
- end
- function purchaseHorn(thePlayer,horn,hornName)
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- local checkOwnership = tonumber(loadPlayerData(thePlayer,"horn"..horn))
- if checkOwnership == 0 then
- if playerLevel >= hornLevel then
- if playerCash >= hornPrice[horn] then
- savePlayerData(thePlayer,"cash",playerCash-hornPrice[horn])
- savePlayerData(thePlayer,tostring("horn"..horn),1)
- getPurchasedHorns(thePlayer)
- scoreboardRefresh(thePlayer)
- achievement39(thePlayer)
- outputChatBox("#00BFFF* #FFFFFFYou have purchased the #ABCDEF"..hornName.."#FFFFFF horn for #ABCDEF$"..hornPrice[horn].."#FFFFFF!",thePlayer,255,255,255,true)
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You need to be level #ABCDEF"..hornLevel.."#FFFFFF or higher to purchase new horns!",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You already own this horn!",thePlayer,255,255,255,true)
- end
- end
- function checkForPurchasedHorn(thePlayer,horn)
- local hornStatus = tonumber(loadPlayerData(thePlayer,"horn"..horn))
- if hornStatus == 1 then
- callClientFunction(thePlayer,"setHorn",horn)
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You do not own this horn!",thePlayer,255,255,255,true)
- end
- end
- function getLastSetHorn(thePlayer)
- local horn = tonumber(loadPlayerData(thePlayer,"lastSetHorn"))
- callClientFunction(thePlayer,"setLastUsedHorn",horn)
- end
- function setLastSetHorn(thePlayer,horn)
- savePlayerData(thePlayer,"lastSetHorn",horn)
- end
- function toggleHornControl()
- for _,player in ipairs(getElementsByType("player")) do
- if loadPlayerData(player,"lastSetHorn") == 0 then
- setTimer(toggleControl,2000,1,player,"horn",true)
- else
- setTimer(toggleControl,2000,1,player,"horn",false)
- end
- end
- end
- addEvent("onMapStarting",true)
- addEventHandler("onMapStarting",getRootElement(),toggleHornControl)
- function toggleControlOnReady()
- if loadPlayerData(source,"lastSetHorn") == 0 then
- toggleControl(source,"horn",true)
- else
- toggleControl(source,"horn",false)
- end
- end
- addEventHandler("onNotifyPlayerReady",getRootElement(),toggleControlOnReady)
- function playHornForAllClients(horningPlayer,hornSoundPath,cSetHornSound) -- This function passes on the horn to all players.
- triggerClientEvent(getRootElement(),"onRecieveHorn",horningPlayer,horningPlayer,hornSoundPath,cSetHornSound)
- end
- -- Buy water color and time change
- function buyChangeWaterColor(thePlayer,r,g,b)
- if type(r) == "number" and r >= 0 and r <= 255 then
- if type(g) == "number" and g >= 0 and g <= 255 then
- if type(b) == "number" and g >= 0 and g <= 255 then
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- if playerCash >= 400 then
- callClientFunction(getRootElement(),"cSetWaterColor",r,g,b)
- savePlayerData(thePlayer,"cash",playerCash-400)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the water color!",getRootElement(),255,255,255,true)
- scoreboardRefresh(thePlayer)
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFInvalid BLUE value - Please use a number from 0 to 255.",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFInvalid GREEN value - Please use a number from 0 to 255.",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFInvalid RED value - Please use a number from 0 to 255.",thePlayer,255,255,255,true)
- end
- end
- function buyChangeTime(thePlayer,h,m)
- if type(h) == "number" and h >= 0 and h <= 23 then
- if type(m) == "number" and m >= 0 and m <= 59 then
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- if playerCash >= 400 then
- setTime(h,m)
- savePlayerData(thePlayer,"cash",playerCash-250)
- if h < 10 and m < 10 then
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the time to #ABCDEF0"..h..":0"..m.."#FFFFFF!",getRootElement(),255,255,255,true)
- elseif h < 10 then
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the time to #ABCDEF0"..h..":"..m.."#FFFFFF!",getRootElement(),255,255,255,true)
- elseif m < 10 then
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the time to #ABCDEF"..h..":0"..m.."#FFFFFF!",getRootElement(),255,255,255,true)
- elseif m > 10 and h > 10 then
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas changed the time to #ABCDEF"..h..":"..m.."#FFFFFF!",getRootElement(),255,255,255,true)
- end
- scoreboardRefresh(thePlayer)
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFInvalid MINUTES - Please use a number from 0 to 59.",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFInvalid HOURS - Please use a number from 0 to 23.",thePlayer,255,255,255,true)
- end
- end
- ---------------------------
- -- Userpanel - Record stats
- ---------------------------
- -- Personal Details
- function savePersonalDetails(thePlayer,pName,pAge,pEmail,pMsn,pSkype,pXfire,pICQ,pXBL)
- savePlayerData(thePlayer,"pName",pName)
- savePlayerData(thePlayer,"pAge",pAge)
- savePlayerData(thePlayer,"pEmail",pEmail)
- savePlayerData(thePlayer,"pMsn",pMsn)
- savePlayerData(thePlayer,"pSkype",pSkype)
- savePlayerData(thePlayer,"pXfire",pXfire)
- savePlayerData(thePlayer,"pICQ",pICQ)
- savePlayerData(thePlayer,"pXBL",pXBL)
- outputChatBox("#00BFFF* #FFFFFFYour personal details have been saved!",thePlayer,255,255,255,true)
- if (pName == "" or pAge == "" or pEmail == "" or pMsn == "" or pSkype == "" or pXfire == "" or pICQ == "" or pXBL == "") then
- return
- else
- achievement35(thePlayer)
- end
- end
- -- Playing time
- function playingTimeAdd(thePlayer)
- local totalPlayingTimeMinutes = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeMinutes"))
- local totalPlayingTimeHours = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeHours"))
- if totalPlayingTimeMinutes == 59 then
- savePlayerData(thePlayer,"totalPlayingTimeMinutes",0)
- savePlayerData(thePlayer,"totalPlayingTimeHours",totalPlayingTimeHours+1)
- else
- savePlayerData(thePlayer,"totalPlayingTimeMinutes",totalPlayingTimeMinutes+1)
- end
- local totalPlayingTimeMinutes = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeMinutes"))
- local totalPlayingTimeHours = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeHours"))
- callClientFunction(thePlayer,"refreshTimePlaying",totalPlayingTimeMinutes,totalPlayingTimeHours)
- achievement21(thePlayer)
- achievement22(thePlayer)
- end
- -- Times joined the server
- function timesJoinedAdd()
- local totalTimesJoined = tonumber(loadPlayerData(source,"totalTimesJoined"))
- savePlayerData(source,"totalTimesJoined",totalTimesJoined+1)
- end
- addEventHandler("onPlayerJoin",getRootElement(),timesJoinedAdd)
- -- Total maps played
- function totalMapsPlayedAdd()
- local mapsPlayed = tonumber(loadPlayerData(source,"mapsPlayed"))
- savePlayerData(source,"mapsPlayed",mapsPlayed+1)
- end
- addEvent("onNotifyPlayerReady",true)
- addEventHandler("onNotifyPlayerReady",getRootElement(),totalMapsPlayedAdd)
- -- Total hunters reached
- function totalHuntersAdd(thePlayer)
- local totalHunters = tonumber(loadPlayerData(thePlayer,"totalHunters"))
- savePlayerData(thePlayer,"totalHunters",totalHunters+1)
- end
- -- Total toptimes set
- addEvent("onPlayerToptimeImprovement",true)
- addEventHandler("onPlayerToptimeImprovement",getRootElement(),
- function (player)
- local totalToptimes = tonumber(loadPlayerData(source,"totalToptimes"))
- savePlayerData(source,"totalToptimes",totalToptimes+1)
- end)
- -- Total money earned
- function totalMoneyEarnedAdd(thePlayer,addValue)
- outputDebugString(tostring(addValue))
- addValue = tonumber(addValue)
- local totalMoneyEarned = tonumber(loadPlayerData(thePlayer,"totalMoneyEarned"))
- savePlayerData(thePlayer,"totalMoneyEarned",totalMoneyEarned + addValue)
- end
- -- Total maps won
- function mapsWonAdd(winner)
- local mapsWon = tonumber(loadPlayerData(winner,"mapsWon"))
- savePlayerData(winner,"mapsWon",mapsWon+1)
- end
- addEvent("onPlayerDestructionDerbyWin",true)
- addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),mapsWonAdd)
- -- Total money sent
- function totalMoneySentAdd(thePlayer,amount)
- local totalMoneySent = tonumber(loadPlayerData(thePlayer,"totalMoneySent"))
- savePlayerData(thePlayer,"totalMoneySent",totalMoneySent+amount)
- end
- -- Total bets
- function totalBetsAdd(thePlayer)
- local totalBets = tonumber(loadPlayerData(thePlayer,"totalBets"))
- savePlayerData(thePlayer,"totalBets",totalBets+1)
- end
- -- Total bets won
- function totalBetsWonAdd(thePlayer)
- local totalBetsWon = tonumber(loadPlayerData(thePlayer,"totalBetsWon"))
- savePlayerData(thePlayer,"totalBetsWon",totalBetsWon+1)
- end
- -- Total bets earned
- function totalBetsEarnedAdd(thePlayer,addAmount)
- local totalBetsEarned = tonumber(loadPlayerData(thePlayer,"totalBetsEarned"))
- savePlayerData(thePlayer,"totalBetsEarned",totalBetsEarned+addAmount)
- end
- -- Total deaths
- function totalDeathsAdd()
- local totalDeaths = tonumber(loadPlayerData(source,"totalDeaths"))
- savePlayerData(source,"totalDeaths",totalDeaths+1)
- end
- addEventHandler("onPlayerWasted",getRootElement(),totalDeathsAdd)
- -- Unlocked Achievements
- function unlockedAchievementsAdd(thePlayer)
- local unlockedAchievements = tonumber(loadPlayerData(thePlayer,"unlockedAchievements"))
- savePlayerData(thePlayer,"unlockedAchievements",unlockedAchievements+1)
- local unlockedAchievements = tonumber(loadPlayerData(thePlayer,"unlockedAchievements"))
- callClientFunction(thePlayer,"updateUnlockedAchievementsNumberLabel",unlockedAchievements)
- end
- function unlockedAchievementsSet(thePlayer,amount)
- savePlayerData(thePlayer,"unlockedAchievements",amount)
- end
- -- Progress bar
- function progressBarUpdate(thePlayer)
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local progressBarValue = 0
- local maxValue = 0
- if playerLevel == 1 then
- maxValue = level2
- elseif playerLevel == 2 then
- maxValue = level3
- elseif playerLevel == 3 then
- maxValue = level4
- elseif playerLevel == 4 then
- maxValue = level5
- elseif playerLevel == 5 then
- maxValue = level6
- elseif playerLevel == 6 then
- maxValue = level7
- elseif playerLevel == 7 then
- maxValue = level8
- elseif playerLevel == 8 then
- maxValue = level9
- elseif playerLevel == 9 then
- maxValue = level10
- elseif playerLevel == 10 then
- maxValue = level11
- elseif playerLevel == 11 then
- maxValue = level12
- elseif playerLevel == 12 then
- maxValue = level13
- elseif playerLevel == 13 then
- maxValue = level14
- elseif playerLevel == 14 then
- maxValue = level15
- elseif playerLevel == 15 then
- maxValue = level16
- elseif playerLevel == 16 then
- maxValue = level17
- elseif playerLevel == 17 then
- maxValue = level18
- elseif playerLevel == 18 then
- maxValue = level19
- elseif playerLevel == 19 then
- maxValue = level20
- elseif playerLevel == 20 then
- maxValue = level21
- elseif playerLevel == 21 then
- maxValue = level22
- elseif playerLevel == 22 then
- maxValue = level23
- elseif playerLevel == 23 then
- maxValue = level24
- elseif playerLevel == 24 then
- maxValue = level25
- elseif playerLevel == 25 then
- maxValue = level26
- elseif playerLevel == 26 then
- maxValue = level27
- elseif playerLevel == 27 then
- maxValue = level28
- elseif playerLevel == 28 then
- maxValue = level29
- elseif playerLevel == 29 then
- maxValue = level30
- elseif playerLevel == 30 then
- maxValue = level31
- elseif playerLevel == 31 then
- maxValue = level32
- elseif playerLevel == 32 then
- maxValue = level33
- elseif playerLevel == 33 then
- maxValue = level34
- elseif playerLevel == 34 then
- maxValue = level35
- elseif playerLevel == 35 then
- maxValue = level36
- elseif playerLevel == 36 then
- maxValue = level37
- elseif playerLevel == 37 then
- maxValue = level38
- elseif playerLevel == 38 then
- maxValue = level39
- elseif playerLevel == 39 then
- maxValue = level40
- elseif playerLevel == 40 then
- maxValue = level41
- elseif playerLevel == 41 then
- return false
- end
- if playerCash >= maxValue then
- progressBarValue = 100
- elseif playerCash == 0 then
- progressBarValue = 0
- elseif (playerCash > 0) and (playerCash < maxValue) then
- progressBarValue = math.round(((100/maxValue)*playerCash),6)
- end
- callClientFunction(thePlayer,"updateProgressBar",progressBarValue)
- end
- -- Check if we "converted" the levels to the total money
- function checkConvertedMoney(thePlayer)
- local convertedTotal = tonumber(loadPlayerData(thePlayer,"convertedTotal"))
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- if convertedTotal == 0 then
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- local tempMoney = 0
- local levelMoney = 0
- if playerLevel == 1 then
- levelMoney = 0
- elseif playerLevel > 26 then
- for i=1,26 do
- levelMoney = levelMoney+((i-1)*1000)
- tempMoney = 25000
- end
- for i=27,playerLevel do
- tempMoney = tempMoney + 3000
- levelMoney = levelMoney+tempMoney
- end
- elseif playerLevel <= 26 then
- for i=1,playerLevel do
- levelMoney = levelMoney+((i-1)*1000)
- end
- end
- savePlayerData(thePlayer,"totalMoneyEarned",levelMoney+playerCash)
- savePlayerData(thePlayer,"convertedTotal",1)
- scoreboardRefresh(thePlayer)
- end
- end
- ---------------------------
- -- Userpanel - Achievements
- ---------------------------
- function checkAchievementsOnStart(thePlayer)
- local ach1 = tonumber(loadPlayerData(thePlayer,"ach1"))
- local ach2 = tonumber(loadPlayerData(thePlayer,"ach2"))
- local ach3 = tonumber(loadPlayerData(thePlayer,"ach3"))
- local ach4 = tonumber(loadPlayerData(thePlayer,"ach4"))
- local ach5 = tonumber(loadPlayerData(thePlayer,"ach5"))
- local ach6 = tonumber(loadPlayerData(thePlayer,"ach6"))
- local ach7 = tonumber(loadPlayerData(thePlayer,"ach7"))
- local ach8 = tonumber(loadPlayerData(thePlayer,"ach8"))
- local ach9 = tonumber(loadPlayerData(thePlayer,"ach9"))
- local ach10 = tonumber(loadPlayerData(thePlayer,"ach10"))
- local ach11 = tonumber(loadPlayerData(thePlayer,"ach11"))
- local ach12 = tonumber(loadPlayerData(thePlayer,"ach12"))
- local ach13 = tonumber(loadPlayerData(thePlayer,"ach13"))
- local ach14 = tonumber(loadPlayerData(thePlayer,"ach14"))
- local ach15 = tonumber(loadPlayerData(thePlayer,"ach15"))
- local ach16 = tonumber(loadPlayerData(thePlayer,"ach16"))
- local ach17 = tonumber(loadPlayerData(thePlayer,"ach17"))
- local ach18 = tonumber(loadPlayerData(thePlayer,"ach18"))
- local ach19 = tonumber(loadPlayerData(thePlayer,"ach19"))
- local ach20 = tonumber(loadPlayerData(thePlayer,"ach20"))
- local ach21 = tonumber(loadPlayerData(thePlayer,"ach21"))
- local ach22 = tonumber(loadPlayerData(thePlayer,"ach22"))
- local ach23 = tonumber(loadPlayerData(thePlayer,"ach23"))
- local ach24 = tonumber(loadPlayerData(thePlayer,"ach24"))
- local ach25 = tonumber(loadPlayerData(thePlayer,"ach25"))
- local ach26 = tonumber(loadPlayerData(thePlayer,"ach26"))
- local ach27 = tonumber(loadPlayerData(thePlayer,"ach27"))
- local ach28 = tonumber(loadPlayerData(thePlayer,"ach28"))
- local ach29 = tonumber(loadPlayerData(thePlayer,"ach29"))
- local ach30 = tonumber(loadPlayerData(thePlayer,"ach30"))
- local ach31 = tonumber(loadPlayerData(thePlayer,"ach31"))
- local ach32 = tonumber(loadPlayerData(thePlayer,"ach32"))
- local ach33 = tonumber(loadPlayerData(thePlayer,"ach33"))
- local ach34 = tonumber(loadPlayerData(thePlayer,"ach34"))
- local ach35 = tonumber(loadPlayerData(thePlayer,"ach35"))
- local ach36 = tonumber(loadPlayerData(thePlayer,"ach36"))
- local ach37 = tonumber(loadPlayerData(thePlayer,"ach37"))
- local ach38 = tonumber(loadPlayerData(thePlayer,"ach38"))
- local ach39 = tonumber(loadPlayerData(thePlayer,"ach39"))
- local ach40 = tonumber(loadPlayerData(thePlayer,"ach40"))
- callClientFunction(thePlayer,"checkAchievementsOnStart",ach1,ach2,ach3,ach4,ach5,ach6,ach7,ach8,ach9,ach10,ach11,ach12,ach13,ach14,ach15,ach16,ach17,ach18,ach19,ach20,ach21,ach22,ach23,ach24,ach25,ach26,ach27,ach28,ach29,ach30,ach31,ach32,ach33,ach34,ach35,ach36,ach37,ach38,ach39,ach40)
- end
- -- Achievement 1
- function achievement1(source)
- local unlocked = tonumber(loadPlayerData(source,"ach1"))
- if unlocked == 0 then
- callClientFunction(source,"unlockAchievement",1)
- savePlayerData(source,"ach1",1)
- local thePlayer = source
- unlockedAchievementsAdd(thePlayer)
- end
- end
- -- Achievement 2
- function achievement2(winner)
- local unlocked = tonumber(loadPlayerData(winner,"ach2"))
- local mapsWon = tonumber(loadPlayerData(winner,"mapsWon"))
- if unlocked == 0 then
- if mapsWon >= 10 then
- callClientFunction(winner,"unlockAchievement",2)
- savePlayerData(winner,"ach2",1)
- local thePlayer = winner
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),achievement2)
- -- Achievement 3
- function achievement3(winner)
- local unlocked = tonumber(loadPlayerData(winner,"ach3"))
- local mapsWon = tonumber(loadPlayerData(winner,"mapsWon"))
- if unlocked == 0 then
- if mapsWon >= 50 then
- callClientFunction(winner,"unlockAchievement",3)
- savePlayerData(winner,"ach3",1)
- local thePlayer = winner
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),achievement3)
- -- Achievement 4
- function achievement4(winner)
- local unlocked = tonumber(loadPlayerData(winner,"ach4"))
- local mapsWon = tonumber(loadPlayerData(winner,"mapsWon"))
- if unlocked == 0 then
- if mapsWon >= 100 then
- callClientFunction(winner,"unlockAchievement",4)
- savePlayerData(winner,"ach4",1)
- local thePlayer = winner
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),achievement4)
- -- Achievement 5
- function achievement5(winner)
- local unlocked = tonumber(loadPlayerData(winner,"ach5"))
- local mapsWon = tonumber(loadPlayerData(winner,"mapsWon"))
- if unlocked == 0 then
- if mapsWon >= 200 then
- callClientFunction(winner,"unlockAchievement",5)
- savePlayerData(winner,"ach5",1)
- local thePlayer = winner
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),achievement5)
- -- Achievement 6
- function achievement6()
- local unlocked = tonumber(loadPlayerData(source,"ach6"))
- local totalDeaths = tonumber(loadPlayerData(source,"totalDeaths"))
- if unlocked == 0 then
- if totalDeaths >= 300 then
- callClientFunction(source,"unlockAchievement",6)
- savePlayerData(source,"ach6",1)
- local thePlayer = source
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- addEventHandler("onPlayerWasted",getRootElement(),achievement6)
- -- Achievement 7,8,9,10,11,12,13,14,15
- function levelAchievements(thePlayer)
- local unlocked7 = tonumber(loadPlayerData(thePlayer,"ach7"))
- local unlocked8 = tonumber(loadPlayerData(thePlayer,"ach8"))
- local unlocked9 = tonumber(loadPlayerData(thePlayer,"ach9"))
- local unlocked10 = tonumber(loadPlayerData(thePlayer,"ach10"))
- local unlocked11 = tonumber(loadPlayerData(thePlayer,"ach11"))
- local unlocked12 = tonumber(loadPlayerData(thePlayer,"ach12"))
- local unlocked13 = tonumber(loadPlayerData(thePlayer,"ach13"))
- local unlocked14 = tonumber(loadPlayerData(thePlayer,"ach14"))
- local unlocked15 = tonumber(loadPlayerData(thePlayer,"ach15"))
- local level = tonumber(loadPlayerData(thePlayer,"level"))
- if unlocked7 == 0 then
- if level >= 5 then
- callClientFunction(thePlayer,"unlockAchievement",7)
- savePlayerData(thePlayer,"ach7",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked8 == 0 then
- if level >= 10 then
- callClientFunction(thePlayer,"unlockAchievement",8)
- savePlayerData(thePlayer,"ach8",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked9 == 0 then
- if level >= 15 then
- callClientFunction(thePlayer,"unlockAchievement",9)
- savePlayerData(thePlayer,"ach9",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked10 == 0 then
- if level >= 20 then
- callClientFunction(thePlayer,"unlockAchievement",10)
- savePlayerData(thePlayer,"ach10",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked11 == 0 then
- if level >= 25 then
- callClientFunction(thePlayer,"unlockAchievement",11)
- savePlayerData(thePlayer,"ach11",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked12 == 0 then
- if level >= 26 then
- callClientFunction(thePlayer,"unlockAchievement",12)
- savePlayerData(thePlayer,"ach12",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked13 == 0 then
- if level >= 31 then
- callClientFunction(thePlayer,"unlockAchievement",13)
- savePlayerData(thePlayer,"ach13",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked14 == 0 then
- if level >= 36 then
- callClientFunction(thePlayer,"unlockAchievement",14)
- savePlayerData(thePlayer,"ach14",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked15 == 0 then
- if level >= 41 then
- callClientFunction(thePlayer,"unlockAchievement",15)
- savePlayerData(thePlayer,"ach15",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- -- Achievement 16
- function achievement16(thePlayer)
- local totalHunters = tonumber(loadPlayerData(thePlayer,"totalHunters"))
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach16"))
- if unlocked == 0 then
- if totalHunters >= 10 then
- callClientFunction(thePlayer,"unlockAchievement",16)
- savePlayerData(thePlayer,"ach16",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- -- Achievement 17
- function achievement17(thePlayer)
- local totalHunters = tonumber(loadPlayerData(thePlayer,"totalHunters"))
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach17"))
- if unlocked == 0 then
- if totalHunters >= 50 then
- callClientFunction(thePlayer,"unlockAchievement",17)
- savePlayerData(thePlayer,"ach17",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- -- Achievement 18
- function achievement18(thePlayer)
- local totalHunters = tonumber(loadPlayerData(thePlayer,"totalHunters"))
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach18"))
- if unlocked == 0 then
- if totalHunters >= 100 then
- callClientFunction(thePlayer,"unlockAchievement",18)
- savePlayerData(thePlayer,"ach18",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- -- Achievement 19,20
- function toptimeAchievements(thePlayer)
- local totalToptimes = tonumber(loadPlayerData(thePlayer,"totalToptimes"))
- local unlocked1 = tonumber(loadPlayerData(thePlayer,"ach19"))
- local unlocked2 = tonumber(loadPlayerData(thePlayer,"ach20"))
- if unlocked1 == 0 then
- if totalToptimes >= 1 then
- callClientFunction(thePlayer,"unlockAchievement",19)
- savePlayerData(thePlayer,"ach19",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked2 == 0 then
- if totalToptimes >= 10 then
- callClientFunction(thePlayer,"unlockAchievement",20)
- savePlayerData(thePlayer,"ach20",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- addEventHandler("onPlayerToptimeImprovement",getRootElement(),toptimeAchievements)
- -- Achievement 21
- function achievement21(thePlayer)
- local totalPlayingTimeHours = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeHours"))
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach21"))
- if unlocked == 0 then
- if totalPlayingTimeHours >= 20 then
- callClientFunction(thePlayer,"unlockAchievement",21)
- savePlayerData(thePlayer,"ach21",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- -- Achievement 22
- function achievement22(thePlayer)
- local totalPlayingTimeHours = tonumber(loadPlayerData(thePlayer,"totalPlayingTimeHours"))
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach22"))
- if unlocked == 0 then
- if totalPlayingTimeHours >= 50 then
- callClientFunction(thePlayer,"unlockAchievement",22)
- savePlayerData(thePlayer,"ach22",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- -- Achievement 23
- function achievement23(thePlayer)
- local totalTimesJoined = tonumber(loadPlayerData(thePlayer,"totalTimesJoined"))
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach23"))
- if unlocked == 0 then
- if totalTimesJoined >= 40 then
- callClientFunction(thePlayer,"unlockAchievement",23)
- savePlayerData(thePlayer,"ach23",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- -- Achievement 24,25,26
- function totalMoneyAchievements(thePlayer)
- local totalMoneyEarned = tonumber(loadPlayerData(thePlayer,"totalMoneyEarned"))
- local unlocked1 = tonumber(loadPlayerData(thePlayer,"ach24"))
- local unlocked2 = tonumber(loadPlayerData(thePlayer,"ach25"))
- local unlocked3 = tonumber(loadPlayerData(thePlayer,"ach26"))
- if unlocked1 == 0 then
- if totalMoneyEarned >= 10000 then
- callClientFunction(thePlayer,"unlockAchievement",24)
- savePlayerData(thePlayer,"ach24",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked2 == 0 then
- if totalMoneyEarned >= 100000 then
- callClientFunction(thePlayer,"unlockAchievement",25)
- savePlayerData(thePlayer,"ach25",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked3 == 0 then
- if totalMoneyEarned >= 1000000 then
- callClientFunction(thePlayer,"unlockAchievement",26)
- savePlayerData(thePlayer,"ach26",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- -- Achievement 27
- function achievement27(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach27"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",27)
- savePlayerData(thePlayer,"ach27",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- -- Achievement 28
- function achievement28(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach28"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",28)
- savePlayerData(thePlayer,"ach28",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- -- Achievement 29
- function achievement29(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach29"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",29)
- savePlayerData(thePlayer,"ach29",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- -- Achievement 30
- function achievement30(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach30"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",30)
- savePlayerData(thePlayer,"ach30",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- -- Achievement 31
- function achievement31(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach31"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",31)
- savePlayerData(thePlayer,"ach31",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- -- Achievements 32,33,34 -- Maps played
- function mapsPlayedAchievements()
- local unlocked1 = tonumber(loadPlayerData(source,"ach32"))
- local unlocked2 = tonumber(loadPlayerData(source,"ach33"))
- local unlocked3 = tonumber(loadPlayerData(source,"ach34"))
- local totalMapsPlayed = tonumber(loadPlayerData(source,"mapsPlayed"))
- if unlocked1 == 0 then
- if totalMapsPlayed >= 100 then
- callClientFunction(source,"unlockAchievement",32)
- savePlayerData(source,"ach32",1)
- local thePlayer = source
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked2 == 0 then
- if totalMapsPlayed >= 500 then
- callClientFunction(source,"unlockAchievement",33)
- savePlayerData(source,"ach33",1)
- local thePlayer = source
- unlockedAchievementsAdd(thePlayer)
- end
- end
- if unlocked3 == 0 then
- if totalMapsPlayed >= 1000 then
- callClientFunction(source,"unlockAchievement",34)
- savePlayerData(source,"ach34",1)
- local thePlayer = source
- unlockedAchievementsAdd(thePlayer)
- end
- end
- end
- addEvent("onNotifyPlayerReady",true)
- addEventHandler("onNotifyPlayerReady",getRootElement(),mapsPlayedAchievements)
- -- Achievement 35 -- Socializer
- function achievement35(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach35"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",35)
- savePlayerData(thePlayer,"ach35",1)
- unlockedAchievementsAdd(thePlayer)
- end
- end
- -- Achievement 36 -- Reaction tests
- function achievement36(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach36"))
- local totalReactionTests = tonumber(loadPlayerData(thePlayer,"totalReactionTests"))
- if unlocked == 0 then
- if totalReactionTests >= 15 then
- callClientFunction(thePlayer,"unlockAchievement",36)
- savePlayerData(thePlayer,"ach36",1)
- end
- end
- end
- -- Achievement 37 -- Reaction time
- function achievement37(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach37"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",37)
- savePlayerData(thePlayer,"ach37",1)
- end
- end
- -- Achievement 38 -- Buy skin
- function achievement38(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach38"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",38)
- savePlayerData(thePlayer,"ach38",1)
- end
- end
- -- Achievement 39 -- Buy horn
- function achievement39(thePlayer)
- local unlocked = tonumber(loadPlayerData(thePlayer,"ach39"))
- if unlocked == 0 then
- callClientFunction(thePlayer,"unlockAchievement",39)
- savePlayerData(thePlayer,"ach39",1)
- end
- end
- -- Achievement 40 - Unlock all achievements
- function achievement40(thePlayer)
- local ach1 = tonumber(loadPlayerData(thePlayer,"ach1"))
- local ach2 = tonumber(loadPlayerData(thePlayer,"ach2"))
- local ach3 = tonumber(loadPlayerData(thePlayer,"ach3"))
- local ach4 = tonumber(loadPlayerData(thePlayer,"ach4"))
- local ach5 = tonumber(loadPlayerData(thePlayer,"ach5"))
- local ach6 = tonumber(loadPlayerData(thePlayer,"ach6"))
- local ach7 = tonumber(loadPlayerData(thePlayer,"ach7"))
- local ach8 = tonumber(loadPlayerData(thePlayer,"ach8"))
- local ach9 = tonumber(loadPlayerData(thePlayer,"ach9"))
- local ach10 = tonumber(loadPlayerData(thePlayer,"ach10"))
- local ach11 = tonumber(loadPlayerData(thePlayer,"ach11"))
- local ach12 = tonumber(loadPlayerData(thePlayer,"ach12"))
- local ach13 = tonumber(loadPlayerData(thePlayer,"ach13"))
- local ach14 = tonumber(loadPlayerData(thePlayer,"ach14"))
- local ach15 = tonumber(loadPlayerData(thePlayer,"ach15"))
- local ach16 = tonumber(loadPlayerData(thePlayer,"ach16"))
- local ach17 = tonumber(loadPlayerData(thePlayer,"ach17"))
- local ach18 = tonumber(loadPlayerData(thePlayer,"ach18"))
- local ach19 = tonumber(loadPlayerData(thePlayer,"ach19"))
- local ach20 = tonumber(loadPlayerData(thePlayer,"ach20"))
- local ach21 = tonumber(loadPlayerData(thePlayer,"ach21"))
- local ach22 = tonumber(loadPlayerData(thePlayer,"ach22"))
- local ach23 = tonumber(loadPlayerData(thePlayer,"ach23"))
- local ach24 = tonumber(loadPlayerData(thePlayer,"ach24"))
- local ach25 = tonumber(loadPlayerData(thePlayer,"ach25"))
- local ach26 = tonumber(loadPlayerData(thePlayer,"ach26"))
- local ach27 = tonumber(loadPlayerData(thePlayer,"ach27"))
- local ach28 = tonumber(loadPlayerData(thePlayer,"ach28"))
- local ach29 = tonumber(loadPlayerData(thePlayer,"ach29"))
- local ach30 = tonumber(loadPlayerData(thePlayer,"ach30"))
- local ach31 = tonumber(loadPlayerData(thePlayer,"ach31"))
- local ach32 = tonumber(loadPlayerData(thePlayer,"ach32"))
- local ach33 = tonumber(loadPlayerData(thePlayer,"ach33"))
- local ach34 = tonumber(loadPlayerData(thePlayer,"ach34"))
- local ach35 = tonumber(loadPlayerData(thePlayer,"ach35"))
- local ach36 = tonumber(loadPlayerData(thePlayer,"ach36"))
- local ach37 = tonumber(loadPlayerData(thePlayer,"ach37"))
- local ach38 = tonumber(loadPlayerData(thePlayer,"ach38"))
- local ach39 = tonumber(loadPlayerData(thePlayer,"ach39"))
- local ach40 = tonumber(loadPlayerData(thePlayer,"ach40"))
- if ach1 == 1 and ach2 == 1 and ach3 == 1 and ach4 == 1 and ach5 == 1 and ach6 == 1 and ach7 == 1 and ach8 == 1 and ach9 == 1 and ach10 == 1 and ach11 == 1 and ach12 == 1 and ach13 == 1 and ach14 == 1 and ach15 == 1 and ach16 == 1 and ach17 == 1 and ach18 == 1 and ach19 == 1 and ach20 == 1 and ach21 == 1 and ach22 == 1 and ach23 == 1 and ach24 == 1 and ach25 == 1 and ach26 == 1 and ach27 == 1 and ach28 == 1 and ach29 == 1 and ach30 == 1 and ach31 == 1 and ach32 == 1 and ach33 == 1 and ach34 == 1 and ach35 == 1 and ach36 == 1 and ach37 == 1 and ach38 == 1 and ach39 == 1 and ach40 == 1 then
- if ach36 == 0 then
- callClientFunction(thePlayer,"unlockAchievement",36)
- savePlayerData(thePlayer,"ach36",1)
- unlockedAchievementsAdd(thePlayer)
- ach36 = 1
- else
- outputChatBox("#00BFFF* #FFFFFFCongratulations! You have unlocked all achievements!",thePlayer,255,255,255,true)
- end
- end
- end
- function displayFancyUnlockText(thePlayer,achievementName)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF has unlocked the achievement: #01b0f0"..achievementName,getRootElement(),255,255,255,true)
- end
- ------------------------------
- -- Set new player's level to 1
- ------------------------------
- function checkIfLevelNotOne()
- local playerLevel = tonumber(loadPlayerData(source,"level"))
- if (playerLevel >= 1) then
- else
- savePlayerData(source,"level",1)
- local thePlayer = source
- refreshStats(thePlayer)
- progressBarUpdate(thePlayer)
- end
- end
- addEventHandler("onPlayerJoin",getRootElement(),checkIfLevelNotOne)
- --------------------------------------------
- -- Get alive and dead players by their STATE
- --------------------------------------------
- function getAliveRacePlayers()
- local alivePlayers = 0
- for index,player in ipairs(getElementsByType("player")) do
- if getElementData(player,"state") == "alive" then
- alivePlayers = alivePlayers + 1
- end
- end
- return alivePlayers
- end
- function getDeadRacePlayers()
- local deadPlayers = 0
- for index,player in ipairs(getElementsByType("player")) do
- if getElementData(player,"state") == "dead" then
- deadPlayers = deadPlayers + 1
- end
- end
- return deadPlayers
- end
- ------------------
- -- Get Player Data
- ------------------
- addCommandHandler("gpd",
- function(player,command,toplayername,datatype)
- if hasObjectPermissionTo ( player, "function.kickPlayer", false ) then
- if (toplayername) and (datatype) then
- if (findPlayerByName (toplayername)) then
- toplayer = findPlayerByName (toplayername)
- local amount = loadPlayerData(toplayer,datatype)
- outputChatBox ("#00BFFF* #FFFFFFgetPlayerData: " .. getPlayerName(toplayer) .. " #FF0000|#FFFFFF " .. datatype .."#FFFFFF: #ABCDEF" .. amount,player,255,255,255,true)
- end
- else
- outputChatBox ("#00BFFF* #FF0000ERROR!#FFFFFF Syntax: /getPlayerData [playername] [datatype]",player,255,255,255,true)
- end
- end
- end)
- ------------------
- -- Set Player Data
- ------------------
- addCommandHandler("spd",
- function(player,command,toplayername,datatype,amount)
- if hasObjectPermissionTo ( player, "function.kickPlayer", false ) then
- if (toplayername) and (datatype) and (amount) then
- if (findPlayerByName (toplayername)) then
- toplayer = findPlayerByName (toplayername)
- savePlayerData(toplayer,datatype,amount)
- outputChatBox ("#00BFFF* #FFFFFFsetPlayerData: " .. getPlayerName(toplayer) .. " #FF0000|#FFFFFF Player's #ABCDEF" .. datatype .. "#FFFFFF has been set to: #ABCDEF" .. amount, player,255,0,0,true)
- outputChatBox ("#00BFFF* #FFFFFF" .. getPlayerName (player) .. " #FFFFFFhas set your #ABCDEF" .. datatype .."#FFFFFF to: #ABCDEF" .. amount, toplayer,255,0,0,true)
- local playerCash = loadPlayerData(toplayer,"cash")
- local playerLevel = loadPlayerData(toplayer,"level")
- local thePlayer = toplayer
- scoreboardRefresh(thePlayer)
- refreshStats(thePlayer)
- progressBarUpdate(thePlayer)
- end
- else
- outputChatBox ("#00BFFF* #FF0000ERROR!#FFFFFF Syntax: /setPlayerData [playername] [datatype] [new_amount]",player,255,255,255,true)
- end
- else
- end
- end)
- --------------
- -- Race winner
- --------------
- addEvent("onPlayerDestructionDerbyWin",true)
- addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),
- function (winner)
- if getPlayerCount() >= 3 then
- local cashToWin = moneyEarnPart*getPlayerCount()
- if (tonumber(loadPlayerData(winner,"level")) >= 26) then
- cashToWin = cashToWin*3.1
- end
- local playerCash = loadPlayerData(winner,"cash")
- savePlayerData(winner,"cash",playerCash +cashToWin)
- local playerCash = loadPlayerData(winner,"cash")
- outputChatBox ("#00BFFF* #FFFFFF" .. getPlayerName(winner) .." #FFFFFFhas won! He/She gets $" .. tostring(cashToWin) .."#00BFFF!",getRootElement(),255,255,255,true)
- return
- else
- outputChatBox("#00BFFF* #FFFFFFNot enough players to earn money - #ABCDEF3 #FFFFFFrequired.",winner,255,255,255,true)
- end
- callClientFunction(winner,"deathReset")
- callClientFunction(winner,"playWinSound")
- local thePlayer = winner
- local newAmount = cashToWin
- totalMoneyEarnedAdd(thePlayer,cashToWin)
- scoreboardRefresh(thePlayer)
- refreshStats(thePlayer)
- progressBarUpdate(thePlayer)
- totalMoneyAchievements(thePlayer)
- end)
- -------------------
- -- Other race ranks
- -------------------
- function earnMoney(thePlayer)
- local position = getAliveRacePlayers()
- if not (position <= 0) then
- if getPlayerCount() >= 3 then
- local pAlive = getAliveRacePlayers()
- local pDead = getDeadRacePlayers()
- local maxCash = 21*(pAlive+pDead) -- Total cash available to earn.
- local portion = 0
- local finalCash = 0
- if not (position == 1) then
- portion = math.ceil(maxCash/(pAlive+pDead-1)) -- The amount to multiply by the number of dead players to later return the money value.
- finalCash = math.ceil(portion*(pDead)) -- Calculate the final money value.
- else
- finalCash = maxCash
- end
- local playerCash = loadPlayerData(thePlayer,"cash")
- outputChatBox("#00BFFF* #FFFFFFYou have recieved $" .. finalCash .. "!",thePlayer,255,255,255,true)
- savePlayerData(thePlayer,"cash",playerCash +finalCash)
- outputDebugString("Final cash for player "..getPlayerName(thePlayer)..": "..finalCash)
- totalMoneyEarnedAdd(thePlayer,finalCash,finalCash)
- else
- outputChatBox("#00BFFF* #FFFFFFNot enough players to earn money - #ABCDEF3 #FFFFFFrequired.",thePlayer,255,255,255,true)
- return
- end
- scoreboardRefresh(thePlayer)
- refreshStats(thePlayer)
- progressBarUpdate(thePlayer)
- totalMoneyAchievements(thePlayer)
- end
- end
- function checkKBA()
- callClientFunction(source,"getKBA")
- end
- addEventHandler ("onPlayerWasted",getRootElement(),checkKBA)
- function resetKBA()
- callClientFunction(source,"resetKBA")
- end
- addEventHandler("onNotifyPlayerReady",getRootElement(),resetKBA)
- -----------------
- -- Hunter handler
- -----------------
- function hunterBonus(thePlayer)
- if getElementData(thePlayer,"playerGotHunter") == false then
- setElementData(thePlayer,"playerGotHunter",true)
- local cashToWin = 1000
- if (tonumber(loadPlayerData(thePlayer,"level")) >= 26) then
- cashToWin = cashToWin*1.1
- end
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF has got the #ABCDEFHunter#FFFFFF! #ABCDEF[#FFFFFF$"..cashToWin.."#ABCDEF]",getRootElement(),255,255,255,true)
- playerCash = loadPlayerData(thePlayer,"cash")
- savePlayerData(thePlayer,"cash",playerCash+cashToWin)
- scoreboardRefresh(thePlayer)
- totalHuntersAdd(thePlayer)
- progressBarUpdate(thePlayer)
- achievement16(thePlayer)
- achievement17(thePlayer)
- achievement18(thePlayer)
- totalMoneyAchievements(thePlayer)
- local newAmount = cashToWin
- totalMoneyEarnedAdd(thePlayer,newAmount)
- end
- end
- function checkForHunter(number,sort,model)
- if sort == "vehiclechange" then
- if model == 425 then
- setTimer(hunterBonus,200,1,source)
- end
- end
- end
- addEventHandler("onPlayerPickUpRacePickup",getRootElement(),checkForHunter)
- addEvent("onPlayerToptimeImprovement",true)
- addEventHandler("onPlayerToptimeImprovement",getRootElement(),
- function (player,newPos,newTime,oldPos,oldTime,random1,random2)
- if getElementData(source,"playerGotHunter") == false then
- if newPos <= 10 then
- local cashToWin = 600
- if (tonumber(loadPlayerData(source,"level")) >= 26) then
- cashToWin = cashToWin*1.1
- end
- local playerCash = loadPlayerData(source,"cash")
- savePlayerData(player,"cash",playerCash +cashToWin)
- local playerCash = loadPlayerData(source,"cash")
- outputChatBox ("#00BFFF* #FFFFFF" .. getPlayerName(source) .." #FFFFFFhas set a new top time - Place: #00BFFF"..newPos.." #ABCDEF[#FFFFFF$"..cashToWin.."#ABCDEF]",getRootElement(),255,255,255,true)
- setElementData(source, "playerGotHunter",true)
- local newAmount = cashToWin
- local thePlayer = source
- totalMoneyEarnedAdd(thePlayer,newAmount)
- totalHuntersAdd(thePlayer)
- progressBarUpdate(thePlayer)
- scoreboardRefresh(thePlayer)
- totalMoneyAchievements(thePlayer)
- achievement18(thePlayer)
- end
- end
- end)
- function resetHunterData()
- setElementData(source,"playerGotHunter",false)
- end
- addEventHandler("onNotifyPlayerReady",getRootElement(),resetHunterData)
- -----------------
- -- Reaction tests
- -----------------
- function newReactionTest()
- reactionString = string.random(reactionLength)
- reactionMoney = math.random(reactionMin,reactionMax)
- outputChatBox("#00BFFF* #FFFFFFSay #ABCDEF"..reactionString.."#FFFFFF to win #ABCDEF$"..reactionMoney.."#FFFFFF!",getRootElement(),255,255,255,true)
- addEventHandler("onPlayerChat",getRootElement(),checkForOpenConsole)
- reactionTimer = setTimer(
- function()
- removeEventHandler("onPlayerChat",getRootElement(),checkForOpenConsole)
- end,reactionDuration*1000,1)
- if isTimer(newReactionTimer) then
- killTimer(newReactionTimer)
- end
- themath = math.random(reactionMinRedo*1000,reactionMaxRedo*1000)
- newReactionTimer = setTimer(newReactionTest,themath )
- setTimer(checktimereaction,19850,1)
- end
- function checkForOpenConsole(message,type)
- callClientFunction(source,"checkForOpenConsole",message,type)
- end
- function checktimereaction()
- local timeLeft,leftExec,totalExec = getTimerDetails(reactionTimer)
- if timeLeft > 0 then
- outputChatBox("#00BFFF* #FFFFFFTime's up! An other reaction test will be made soon!",getRootElement(),255,255,255,true)
- end
- end
- function checkReactionTest(thePlayer,message,type,isOpen)
- if (isOpen == true) then
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF attempted to cheat at the reaction test!",getRootElement(),255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFFMoney decreased by #ABCDEF$1,000#FFFFFF! Do not cheat!",getRootElement(),255,255,255,true)
- local playerCash = loadPlayerData(thePlayer,"cash")
- savePlayerData(thePlayer,"cash",playerCash - 1000)
- scoreboardRefresh(thePlayer)
- end
- message = tostring(message)
- if message == "..." then
- return
- end
- if (message == reactionString) then
- local timeLeft,leftExec,totalExec = getTimerDetails(reactionTimer)
- killTimer(reactionTimer)
- removeEventHandler("onPlayerChat",getRootElement(),checkForOpenConsole)
- setTimer(outputChatBox,200,1,"#00BFFF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas won the reaction test in #ABCDEF"..math.round((reactionDuration*1000 - timeLeft)/1000,2,floor) .." #FFFFFFseconds and wins #ABCDEF$"..reactionMoney,getRootElement(),255,255,255,true)
- setTimer(outputChatBox,200,1,"#00BFFF* #FFFFFFAn other reaction test will be made soon!",getRootElement(),255,255,255,true)
- local playerCash = loadPlayerData(thePlayer,"cash")
- local totalReactionTests = tonumber(loadPlayerData(thePlayer,"totalReactionTests"))
- local bestReactionTime = tonumber(loadPlayerData(thePlayer,"bestReactionTime"))
- savePlayerData(thePlayer,"cash",playerCash + reactionMoney)
- savePlayerData(thePlayer,"totalReactionTests",totalReactionTests + 1)
- totalMoneyEarnedAdd(thePlayer,reactionMoney)
- if (math.round((reactionDuration*1000 - timeLeft)/1000)) < bestReactionTime or (bestReactionTime == 0) then
- savePlayerData(thePlayer,"bestReactionTime",math.round((reactionDuration*1000 - timeLeft)/1000,2,floor))
- end
- scoreboardRefresh(thePlayer)
- setTimer(achievement36,200,1,thePlayer)
- setTimer(achievement36,200,1,thePlayer)
- -- Check for achievement here
- if math.round((reactionDuration*1000 - timeLeft)/1000,2,floor) <= 5 then
- achievement37(thePlayer)
- end
- reactionString = ""
- reactionMoney = 0
- end
- end
- function string.random(len)
- local str = ""
- for i=1,len do
- local getChar = math.random(1,35)
- if getChar <= 25 then
- local caps = math.random(1,2)
- if caps == 1 then
- str = str..string.upper(chars[getChar])
- else
- str = str..string.lower(chars[getChar])
- end
- else
- str = str..chars[getChar]
- end
- end
- return str
- end
- -----------------
- -- Betting system
- -----------------
- function createNewBet(thePlayer,toPlayer,newAmount,oldAmount,betState)
- if getPlayerCount() >= minPlayers then
- if bettingEnabled == true then
- if (betState == 0) then
- if (toPlayer) then
- if (newAmount) then
- local newAmount = tonumber(math.ceil(newAmount))
- if (newAmount >= 1) then
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local maxBet = playerLevel*betPerLevel
- if (findPlayerByName(toPlayer)) then
- local toPlayerName = findPlayerByName(toPlayer)
- if (newAmount <= playerCash) then
- if newAmount <= maxBet then
- callClientFunction(thePlayer,"addNewBet",toPlayerName,newAmount)
- savePlayerData(thePlayer,"cash",playerCash-newAmount)
- scoreboardRefresh(thePlayer)
- totalBetsAdd(thePlayer)
- progressBarUpdate(thePlayer)
- --outputChatBox("#00FF00* #FFFFFFYou have placed your bet on "..getPlayerName(toPlayerName).."#FFFFFF for #ABCDEF$"..newAmount.."#FFFFFF!",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).."#FFFFFF has placed a bet on "..getPlayerName(toPlayerName).."#FFFFFF for #ABCDEF$"..newAmount.."#FFFFFF!",getRootElement(),255,255,255,true)
- elseif newAmount > maxBet then
- outputChatBox("#FF0000* #FFFFFFYou are allowed to bet a maximum of #ABCDEF$"..maxBet.."#FFFFFF! Levelling up will increase this number.",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#FF0000* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#FF0000* #FFFFFFERROR! The player you specified has not been found! (#FFFF00"..toPlayer.."#FFFFFF)",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#FF0000* #FFFFFFERROR! Invalid amount! [#ABCDEF$"..newAmount.."#FFFFFF]",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#FF0000* #FFFFFFERROR! Please specify an amount to bet! Correct syntax: #ABCDEF/bet [player] [amount]",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#FF0000* #FFFFFFERROR! Please specify a player! Correct syntax: #ABCDEF/bet [player] [amount]",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#FF0000* #FFFFFFYou have already placed your bet on "..betState.." #FFFFFFfor #ABCDEF$"..oldAmount.."#FFFFFF!",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#FF0000* #FFFFFFBetting time is over! You can place your bet on the next map.",thePlayer,255,255,255,true)
- end
- else
- outputChatBox("#FF0000* #FFFFFFBetting #FF0000disabled.#FFFFFF Minimum required players on server: #ABCDEF" ..minPlayers.."#FF0000 | #FFFFFFConnected: #ABCDEF"..getPlayerCount(),thePlayer,255,255,255,true)
- end
- end
- function onPlayerBetWin(self,betAmount)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(self).."#FFFFFF has won his bet and has recieved #ABCDEF$".. betAmount*2 .."#FFFFFF!",getRootElement(),255,255,255,true)
- local playerCash = loadPlayerData(self,"cash")
- savePlayerData(self,"cash",playerCash+betAmount+betAmount*2)
- local thePlayer = self
- scoreboardRefresh(thePlayer)
- local addAmount = betAmount*2
- totalMoneyEarnedAdd(thePlayer,addAmount)
- totalBetsWonAdd(thePlayer)
- totalBetsEarnedAdd(thePlayer,addAmount)
- progressBarUpdate(thePlayer)
- totalMoneyAchievements(thePlayer)
- end
- function bettingTimer()
- if isTimer(chatTimer) then killTimer(chatTimer) end
- if isTimer(disableTimer) then killTimer(disableTimer) end
- if getPlayerCount() >= minPlayers then
- chatTimer = setTimer(outputChatBox,3500,1,"#00BFFF* #FFFFFFPlace your bets! #FFFFFF[#ABCDEF/bet#FFFFFF]",getRootElement(),255,255,255,true)
- bettingEnabled = true
- disableTimer = setTimer(disableBetting,betTimeLimit*1000+2000,1)
- end
- end
- addEvent("onMapStarting",true)
- addEventHandler("onMapStarting",getRootElement(),bettingTimer)
- function disableBetting()
- outputChatBox("#00BFFF* #FFFFFFBetting time is over#FF0000!",getRootElement(),255,255,255,true)
- bettingEnabled = false
- end
- function checkWin(winner)
- callClientFunction(getRootElement(),"compareResult",winner)
- end
- addEvent("onPlayerDestructionDerbyWin",true)
- addEventHandler("onPlayerDestructionDerbyWin",getRootElement(),checkWin)
- function retrieveData(thePlayer,commandName,toPlayer,newAmount)
- callClientFunction(thePlayer,"triggerBettingSystem",thePlayer,toPlayer,newAmount)
- end
- addCommandHandler("bet",retrieveData)
- -------------
- -- Give money
- -------------
- function giveMoney(thePlayer,targetPlayer,amount)
- if not (targetPlayer == "") then
- if tonumber(amount) then
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- if tonumber(amount) > 0 then
- if tonumber(amount) <= playerCash then
- if (findPlayerByName(targetPlayer)) then
- local target = findPlayerByName(targetPlayer)
- if target ~= thePlayer then
- local amount = math.ceil(amount)
- local playerCash = loadPlayerData(thePlayer,"cash")
- local targetCash = loadPlayerData(target,"cash")
- savePlayerData(thePlayer,"cash",playerCash-tonumber(amount))
- savePlayerData(target,"cash",targetCash+tonumber(amount))
- progressBarUpdate(thePlayer)
- progressBarUpdate(target)
- totalMoneyAchievements(thePlayer)
- local playerCash = loadPlayerData(thePlayer,"cash")
- local targetCash = loadPlayerData(target,"cash")
- scoreboardRefresh(thePlayer)
- scoreboardRefresh(target)
- achievement30(thePlayer)
- totalMoneyEarnedAdd(target,amount)
- totalMoneySentAdd(thePlayer,amount)
- outputChatBox("#00BFFF* #FFFFFFYou have sent #ABCDEF$"..amount.."#FFFFFF to "..getPlayerName(target).."#FFFFFF!",thePlayer,255,255,255,true)
- outputChatBox("#00BFFF* #FFFFFF"..getPlayerName(thePlayer).." #FFFFFFhas sent you #ABCDEF$"..amount.."#FFFFFF!",target,255,255,255,true)
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You cannot send money to yourself!",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! The player you specified does not exist! (#FFFF00.."..targetPlayer.."#FFFFFF)",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! You don't have enough money!",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! Invalid amount! [#ABCDEF"..amount.."#FFFFFF]",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! Please specify the amount to send!",thePlayer,255,255,255,true)
- return false
- end
- else
- outputChatBox("#00BFFF* #FFFFFFERROR! Please select a player!",thePlayer,255,255,255,true)
- return false
- end
- end
- ------------
- -- PM system
- ------------
- function privateMessage(player, command, toplayername, ...)
- local words = { ... }
- local message = table.concat(words," ")
- if toplayername then
- if (findPlayerByName (toplayername)) then
- toplayer = (findPlayerByName (toplayername))
- if not (toplayer == player) then
- if message then
- outputChatBox("#FFFF00[PM]#00BFFF Message to #FFFFFF" .. getPlayerName(toplayer) .. "#FFFFFF: " .. message, player, 255, 255, 255, true)
- outputChatBox("#FFFF00[PM]#00BFFF Message from #FFFFFF" .. getPlayerName(player) .. "#FFFFFF: " .. message, toplayer, 255, 255, 255, true)
- else
- outputChatBox("#FFFF00[PM]#00BFFF Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true)
- return false
- end
- else
- outputChatBox("#FFFF00[PM]#00BFFF You cannot PM yourself#FFFFFF!", player, 255, 255, 255, true)
- return false
- end
- else
- outputChatBox("#FFFF00[PM]#00BFFF Player not found! #FFFFFF("..toplayername..").", player, 255, 255, 255, true)
- return false
- end
- else
- outputChatBox("#FFFF00[PM]#00BFFF Invalid syntax! Usage:#FFFFFF /pm [partical player name] [message]", player, 255, 255, 255, true)
- return false
- end
- end
- addCommandHandler("pm", privateMessage)
- --------------------------------------
- -- Find player by a part of their name
- --------------------------------------
- function findPlayerByName (name)
- local player = getPlayerFromName(name)
- if player then return player end
- for i, player in ipairs(getElementsByType("player")) do
- if string.find(string.gsub(getPlayerName(player):lower(),"#%x%x%x%x%x%x", ""), name:lower(), 1, true) then
- return player
- end
- end
- return false
- end
- ----------------------------------------------
- -- AFK killer - extended from clienside script
- ----------------------------------------------
- local raceState = ""
- local enableMessages = true
- local messageColor = "#FF5555"
- function afkMsg(mtype,afkCount)
- if(mtype == 1) then
- outputChatBox("#00BFFF* #FFFFFF".. getPlayerName(source).. "#00BFFF has been killed by the #FFFFFFAFK killer#00BFFF #00BFFF[#ABCDEF"..afkCount.."/3#00BFFF]",getRootElement(),255,255,255,true)
- elseif(mtype == 2) then
- outputChatBox("#00BFFF* #FFFFFF".. getPlayerName(source).. "#00BFFF has been kicked for staying #FFFFFFAFK#00BFFF for 3 rounds!",getRootElement(),255,255,255,true)
- end
- end
- addEvent( "afkWarn", true )
- addEventHandler( "afkWarn", getRootElement(), afkMsg)
- function afkKill()
- local thePlayer = source
- callClientFunction(thePlayer,"setKBA",thePlayer)
- setElementHealth(source, 0)
- end
- addEvent( "afkSlap", true )
- addEventHandler( "afkSlap", getRootElement(), afkKill)
- function changeRaceState(newStateName)
- raceState = newStateName
- end
- addEvent("onRaceStateChanging", true)
- addEventHandler( "onRaceStateChanging", getRootElement(), changeRaceState)
- function afkKick(player)
- kickPlayer(player,"AFK")
- end
- addEvent( "afkKick", true)
- addEventHandler( "afkKick", getRootElement(), afkKick)
- function clientLoaded()
- local msgenable = get( "msgenable" )
- local msgcol = get( "msgcolor" )
- if(msgenable) then
- if(msgenable == "true") then
- enableMessages = true
- else
- enableMessages = false
- end
- if(msgcol) then
- messageColor = msgcol
- end
- end
- local maxtime = get( "maxafktime" )
- local wtime = get( "warnTime" )
- triggerClientEvent ( "onSettingsReady", getRootElement(), maxtime, wtime)
- end
- addEvent("onClientLoaded", true)
- addEventHandler( "onClientLoaded", getRootElement(), clientLoaded)
- ----------------------
- -- Automated Ghostmode
- ----------------------
- addEvent("onMapStarting")
- addEventHandler("onMapStarting", getRootElement(),
- function(mapInfo, mapOptions, gameOptions)
- if (ismapDM(mapInfo.name) == 1) then
- outputChatBox("#00BFFF* #FFFFFFPlaying a #ABCDEF[DM]#FFFFFF map, ghostmode #00FF00ENABLED",getRootElement(),255,255,255,true)
- for theKey,thePlayer in ipairs(getElementsByType("player")) do
- setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false )
- end
- elseif (ismapDM(mapInfo.name) == 2) then
- outputChatBox("#00BFFF* #FFFFFFPlaying a #ABCDEF[DD]#FFFFFF map, ghostmode #FF0000DISABLED",getRootElement(),255,255,255,true)
- for theKey,thePlayer in ipairs(getElementsByType("player")) do
- setElementData(thePlayer, "overrideCollide.uniqueblah", nil, false )
- end
- elseif (ismapDM(mapInfo.name) == 3) then
- outputChatBox("#00BFFF* #FFFFFFPlaying a #ABCDEF[FUN]#FFFFFF map, ghostmode #FF0000DISABLED",getRootElement(),255,255,255,true)
- for theKey,thePlayer in ipairs(getElementsByType("player")) do
- setElementData(thePlayer, "overrideCollide.uniqueblah", nil, false )
- end
- end
- end)
- function ismapDM(isim)
- if string.find(isim, "[DM]", 1, true) then
- return 1
- elseif string.find(isim, "[DD]", 1,true) then
- return 2
- elseif string.find(isim, "[FUN]", 1,true) then
- return 3
- end
- end
- ------------------------------------------------
- -- Set headlights on map start and on veh-change
- ------------------------------------------------
- function setPlayerHeadlightColor(number, sort, model)
- if sort == "vehiclechange" then
- local hlcRed = getElementData(source,"hlcRed")
- local hlcGreen = getElementData(source,"hlcGreen")
- local hlcBlue = getElementData(source,"hlcBlue")
- if (hlcRed) and (hlcGreen) and (hlcBlue) then
- local car = getPedOccupiedVehicle(source)
- setVehicleHeadLightColor(car,hlcRed,hlcGreen,hlcBlue)
- --outputChatBox("Data sucessfully retrieved, headlights color has been set!",getRootElement(),0,255,0)
- else
- end
- end
- end
- function setPlayerHeadlightColor2()
- local hlcRed = getElementData(source,"hlcRed")
- local hlcGreen = getElementData(source,"hlcGreen")
- local hlcBlue = getElementData(source,"hlcBlue")
- if (hlcRed) and (hlcGreen) and (hlcBlue) then
- local car = getPedOccupiedVehicle(source)
- setVehicleHeadLightColor(car,hlcRed,hlcGreen,hlcBlue)
- --outputChatBox("Data sucessfully retrieved, headlights color has been set!",getRootElement(),0,255,0)
- else
- end
- end
- addEvent("onNotifyPlayerReady", true)
- addEventHandler("onNotifyPlayerReady", getRootElement(), setPlayerHeadlightColor2)
- addEventHandler("onPlayerPickUpRacePickup",getRootElement(),setPlayerHeadlightColor)
- ------------------
- -- Save headlights
- ------------------
- function saveHeadlights(thePlayer,colorRed,colorGreen,colorBlue)
- --outputChatBox("SERVER: Event triggered! Saving headlights...")
- local red = colorRed
- local green = colorGreen
- local blue = colorBlue
- local car = getPedOccupiedVehicle(thePlayer)
- setVehicleHeadLightColor(car,red,green,blue)
- savePlayerData(thePlayer,"hlcRed",red)
- savePlayerData(thePlayer,"hlcGreen",green)
- savePlayerData(thePlayer,"hlcBlue",blue)
- setElementData(thePlayer,"hlcRed",red)
- setElementData(thePlayer,"hlcGreen",green)
- setElementData(thePlayer,"hlcBlue",blue)
- outputChatBox("#00BFFF* #FFFFFFYour data has been saved!",thePlayer,255,255,255,true)
- --outputChatBox("SERVER: Account found! Data has been saved.")
- end
- addEvent("saveHeadlights", true)
- addEventHandler("saveHeadlights", getRootElement(), saveHeadlights)
- ---------------------
- -- Save vehicle color
- ---------------------
- function saveVehColor(player,c1,c2,c3,c4)
- savePlayerData(player,"c1",c1)
- savePlayerData(player,"c2",c2)
- savePlayerData(player,"c3",c3)
- savePlayerData(player,"c4",c4)
- setElementData(player,"c1",c1)
- setElementData(player,"c2",c2)
- setElementData(player,"c3",c3)
- setElementData(player,"c4",c4)
- end
- root = getRootElement()
- function executecolor(c1,c2,c3,c4)
- carcolor(source,true,c1,c2,c3,c4)
- end
- function executealpha(player,_,alpha)
- alpha = alpha or 255
- setElementAlpha(getPedOccupiedVehicle(player),tonumber(alpha))
- end
- function carcolor(thePlayer,_,arg1,arg2,arg3,arg4)
- local vehicle = getPedOccupiedVehicle(thePlayer)
- if (vehicle) then
- local old,old2,old3,old4=getVehicleColor(vehicle)
- local arg11,arg22,arg33,arg44=tonumber(arg1),tonumber(arg2) or old2,tonumber(arg3) or old3,tonumber(arg4) or old4
- setVehicleColor(vehicle,arg11,arg22,arg33,arg44)
- outputChatBox("#00BFFF* #FFFFFFYour data has been saved!",thePlayer,255,255,255,true)
- savePlayerData(thePlayer,"everSetCustomVehicleColor",1)
- setElementData(thePlayer,"everSetCustomVehicleColor",1)
- else
- end
- end
- addEvent("colorchange",true)
- addEventHandler("colorchange",root, executecolor)
- addEvent("alphachange",true)
- addEventHandler("alphachange",root, executealpha)
- ----------------------------------------------------------
- -- Set vehicle color on player-ready and on vehicle change
- ----------------------------------------------------------
- function setPlayerVehicleColor(number, sort, model)
- if sort == "vehiclechange" then
- local ifSet = tonumber(getElementData(source,"everSetCustomVehicleColor"))
- if ifSet == 1 then
- local useColor = tostring(getElementData(source,"useCustomVehicleColor"))
- if (useColor == "true") then
- local c1 = tonumber(getElementData(source,"c1"))
- local c2 = tonumber(getElementData(source,"c2"))
- local c3 = tonumber(getElementData(source,"c3"))
- local c4 = tonumber(getElementData(source,"c4"))
- local car = getPedOccupiedVehicle(source)
- exc1, exc2, exc3, exc4 = getVehicleColor (car)
- if not c1 then c1 = exc1 end
- if not c2 then c2 = exc2 end
- if not c3 then c3 = exc3 end
- if not c4 then c4 = exc4 end
- setVehicleColor(car,c1,c2,c3,c4)
- else
- local car = getPedOccupiedVehicle(source)
- setVehicleColor(car,math.random(1,126),math.random(1,126),math.random(1,126),math.random(1,126))
- end
- else
- local car = getPedOccupiedVehicle(source)
- setVehicleColor(car,math.random(1,126),math.random(1,126),math.random(1,126),math.random(1,126))
- end
- end
- end
- function setPlayerVehicleColor2()
- local ifSet = tonumber(getElementData(source,"everSetCustomVehicleColor"))
- if ifSet == 1 then
- local useColor = tostring(getElementData(source,"useCustomVehicleColor"))
- if (useColor == "true") then
- local c1 = tonumber(getElementData(source,"c1"))
- local c2 = tonumber(getElementData(source,"c2"))
- local c3 = tonumber(getElementData(source,"c3"))
- local c4 = tonumber(getElementData(source,"c4"))
- local car = getPedOccupiedVehicle(source)
- exc1, exc2, exc3, exc4 = getVehicleColor (car)
- if not c1 then c1 = exc1 end
- if not c2 then c2 = exc2 end
- if not c3 then c3 = exc3 end
- if not c4 then c4 = exc4 end
- setVehicleColor(car,c1,c2,c3,c4)
- else
- local car = getPedOccupiedVehicle(source)
- setVehicleColor(car,math.random(1,126),math.random(1,126),math.random(1,126),math.random(1,126))
- end
- else
- local car = getPedOccupiedVehicle(source)
- setVehicleColor(car,math.random(1,126),math.random(1,126),math.random(1,126),math.random(1,126))
- end
- end
- addEventHandler("onNotifyPlayerReady", getRootElement(), setPlayerVehicleColor2)
- addEventHandler("onPlayerPickUpRacePickup", getRootElement(), setPlayerVehicleColor)
- ---------------------------------------------
- -- Set most widely used stats as element data
- ---------------------------------------------
- function setElementDataOnStart(source)
- thePlayer = source
- local a = loadPlayerData(thePlayer,"everPurchasedSkin")
- local b = loadPlayerData(thePlayer,"everPurchasedNametagColor")
- local c = loadPlayerData(thePlayer,"everSetCustomVehicleColor")
- local d = loadPlayerData(thePlayer,"useCustomVehicleColor")
- local e = loadPlayerData(thePlayer,"c1")
- local f = loadPlayerData(thePlayer,"c2")
- local g = loadPlayerData(thePlayer,"c3")
- local h = loadPlayerData(thePlayer,"c4")
- local i = loadPlayerData(thePlayer,"hlcRed")
- local j = loadPlayerData(thePlayer,"hlcGreen")
- local k = loadPlayerData(thePlayer,"hlcBlue")
- local adminredo = loadPlayerData(thePlayer,"admin_redo")
- local adminnextmap = loadPlayerData(thePlayer,"admin_nextmap")
- setElementData(thePlayer,"everPurchasedSkin",a)
- setElementData(thePlayer,"everPurchasedNametagColor",b)
- setElementData(thePlayer,"everSetCustomVehicleColor",c)
- setElementData(thePlayer,"useCustomVehicleColor",d)
- setElementData(thePlayer,"c1",e)
- setElementData(thePlayer,"c2",f)
- setElementData(thePlayer,"c3",g)
- setElementData(thePlayer,"c4",h)
- setElementData(thePlayer,"hlcRed",i)
- setElementData(thePlayer,"hlcGreen",j)
- setElementData(thePlayer,"hlcBlue",k)
- setElementData(thePlayer,"admin_redo",adminredo)
- setElementData(thePlayer,"admin_nextmap",adminnextmap)
- end
- -- Get player's element data (testing)
- function getElementDataOnCommand(player,command,data)
- outputChatBox(tostring(getElementData(player,tostring(data))))
- end
- addCommandHandler("get",getElementDataOnCommand)
- ------------
- -- Save name
- ------------
- addEventHandler ("onPlayerJoin",getRootElement(),
- function()
- local playerName = getPlayerName(source)
- savePlayerData(source,"playerName",string.gsub(playerName,"#%x%x%x%x%x%x", ""))
- end)
- -------------------------------------------
- -- Save new nick when the player changes it
- -------------------------------------------
- addEventHandler("onPlayerChangeNick",getRootElement(),
- function (olnick,newnick)
- savePlayerData(source,"playerName",string.gsub(newnick,"#%x%x%x%x%x%x", ""))
- end)
- -----------------
- -- Get dead count
- -----------------
- function getDeadCount ()
- deadAmount = 0
- for i,v in ipairs (getDeadPlayers()) do
- deadAmount = deadAmount +1
- end
- return deadAmount
- end
- ------------------
- -- Get alive count
- ------------------
- function getAliveCount ()
- aliveAmount = 0
- for i,v in ipairs (getAlivePlayers()) do
- aliveAmount = aliveAmount +1
- end
- return aliveAmount
- end
- --------------------------
- -- Retrieve player's level
- --------------------------
- function retrieveLevel(thePlayer)
- local playerLevel = loadPlayerData(thePlayer,"level")
- callClientFunction(thePlayer,"checkLevel",playerLevel)
- end
- function retrieveLevelVeh(thePlayer)
- local playerLevel = loadPlayerData(thePlayer,"level")
- callClientFunction(thePlayer,"checkLevelVeh",playerLevel)
- end
- -------------------------------------------
- -- Calling functions from the client's side
- -------------------------------------------
- function callServerFunction(funcname, ...)
- local arg = { ... }
- if (arg[1]) then
- for key, value in next, arg do arg[key] = tonumber(value) or value end
- end
- loadstring("return "..funcname)()(unpack(arg))
- end
- addEvent("onClientCallsServerFunction", true)
- addEventHandler("onClientCallsServerFunction", resourceRoot , callServerFunction)
- -----------------------
- -- Call client function
- -----------------------
- function callClientFunction(client, funcname, ...)
- local arg = { ... }
- if (arg[1]) then
- for key, value in next, arg do
- if (type(value) == "number") then arg[key] = tostring(value) end
- end
- end
- -- If the clientside event handler is not in the same resource, replace 'resourceRoot' with the appropriate element
- triggerClientEvent(client, "onServerCallsClientFunction", resourceRoot, funcname, unpack(arg or {}))
- end
- ----------------------
- -- Math.round function
- ----------------------
- function math.round(number, decimals, method)
- decimals = decimals or 0
- local factor = 10 ^ decimals
- if (method == "ceil" or method == "floor") then return math[method](number * factor) / factor
- else return tonumber(("%."..decimals.."f"):format(number)) end
- end
- ----------------
- -- Fun functions
- ----------------
- function announceScript(player, cmd, ...)
- local accountname = getAccountName(getPlayerAccount(player))
- if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then
- for id, players in ipairs(getElementsByType("player")) do
- local message = table.concat({...}," ")
- local textChat = textCreateDisplay ()
- local textItem = textCreateTextItem( message, 0.5, 0.5, 2.9, math.random(1,255),math.random(1,255),math.random(1,255), 255, 4.3, "center", "center" )
- textDisplayAddText ( textChat, textItem )
- textDisplayAddObserver ( textChat, players )
- setTimer ( textDestroyTextItem, 4000, 1, textItem )
- setTimer ( textDestroyDisplay, 4000, 1, textChat )
- end
- else
- outputChatBox("#00BFFF* #FFFFFFYou need to be logged in as admin to use this command!",player,255,255,255,true)
- end
- end
- addCommandHandler("ann", announceScript)
- function fakeAchievement(player,command,targetPlayerName,...)
- local accountname = getAccountName(getPlayerAccount(player))
- if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then
- if (targetPlayerName) then
- if (findPlayerByName(targetPlayerName)) or (targetPlayerName == "all") then
- if (...) then
- local text = table.concat({...}," ")
- local targetPlayer = findPlayerByName(targetPlayerName)
- if (targetPlayerName == "all" ) then
- callClientFunction(getRootElement(),"fakeUnlock",text)
- outputChatBox("#00BFFF* #FFFFFFFake achievement sent to #00BFFFEVERYONE #FFFFFFwith the text #ABCDEF"..text,getRootElement(),255,255,255,true)
- else
- callClientFunction(targetPlayer,"fakeUnlock",text)
- outputChatBox("#00BFFF* #FFFFFFFake achievement sent to "..getPlayerName(targetPlayer).."#FFFFFF with the text #ABCDEF"..text,getRootElement(),255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFPlease enter a message to display on the fake achievement.",player,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFNo players with that name found.",player,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFPlease enter the name of the player you wish to send the message to.",player,255,255,255,true)
- end
- end
- end
- addCommandHandler("fakea", fakeAchievement)
- function flyingCars(player,command,targetPlayerName,state)
- local accountname = getAccountName(getPlayerAccount(player))
- if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then
- if (targetPlayerName) then
- if (findPlayerByName(targetPlayerName)) or (targetPlayerName == "all") then
- if (state) then
- local targetPlayer = findPlayerByName(targetPlayerName)
- callClientFunction(targetPlayer,"enableFlyCheat",state)
- outputChatBox("#00BFFF* #FFFFFFFLYING CHEATS: #ABCDEF"..tostring(state).." #FFFFFFfor player "..getPlayerName(targetPlayer),getRootElement(),255,255,255,true)
- else
- outputChatBox("#00BFFF* #FFFFFFPlease input whether would you like to activate the cheat (true/false).",player,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFNo players with that name found.",player,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFPlease enter the name of the player you wish to enable cheats for!",player,255,255,255,true)
- end
- end
- end
- addCommandHandler("cFly", flyingCars)
- function hoverCars(player,command,targetPlayerName,state)
- local accountname = getAccountName(getPlayerAccount(player))
- if ( hasObjectPermissionTo ( player, "command.mute", true ) ) then
- if (targetPlayerName) then
- if (findPlayerByName(targetPlayerName)) or (targetPlayerName == "all") then
- if (state) then
- local targetPlayer = findPlayerByName(targetPlayerName)
- callClientFunction(targetPlayer,"enableHoverCheat",state)
- outputChatBox("#00BFFF* #FFFFFFHOVER CHEATS: #ABCDEF"..tostring(state).." #FFFFFFfor player "..getPlayerName(targetPlayer),getRootElement(),255,255,255,true)
- else
- outputChatBox("#00BFFF* #FFFFFFPlease input whether would you like to activate the cheat (true/false).",player,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFNo players with that name found.",player,255,255,255,true)
- end
- else
- outputChatBox("#00BFFF* #FFFFFFPlease enter the name of the player you wish to enable cheats for!",player,255,255,255,true)
- end
- end
- end
- addCommandHandler("cHover", hoverCars)
- ----------------------------------------------- SCOREBOARD -----------------------------------------------------
- addEventHandler("onResourceStart", getResourceRootElement(getThisResource()),
- function()
- exports.scoreboard:addScoreboardColumn("Money",getRootElement(),5)
- exports.scoreboard:addScoreboardColumn("Level",getRootElement(),4)
- exports.scoreboard:addScoreboardColumn("Country",getRootElement(),6)
- exports.scoreboard:removeScoreboardColumn("race rank")
- exports.scoreboard:removeScoreboardColumn("checkpoint")
- end)
- function scoreboardRefresh(thePlayer)
- outputDebugString("Refreshing the scoreboard...")
- local playerCash = tonumber(loadPlayerData(thePlayer,"cash"))
- local playerLevel = tonumber(loadPlayerData(thePlayer,"level"))
- setElementData(thePlayer,"Money","$"..playerCash)
- local levelDisplay = ""
- if playerLevel == 26 then
- levelDisplay = nlevel26
- elseif playerLevel == 27 then
- levelDisplay = nlevel27
- elseif playerLevel == 28 then
- levelDisplay = nlevel28
- elseif playerLevel == 29 then
- levelDisplay = nlevel29
- elseif playerLevel == 30 then
- levelDisplay = nlevel30
- elseif playerLevel == 31 then
- levelDisplay = nlevel31
- elseif playerLevel == 32 then
- levelDisplay = nlevel32
- elseif playerLevel == 33 then
- levelDisplay = nlevel33
- elseif playerLevel == 34 then
- levelDisplay = nlevel34
- elseif playerLevel == 35 then
- levelDisplay = nlevel35
- elseif playerLevel == 36 then
- levelDisplay = nlevel36
- elseif playerLevel == 37 then
- levelDisplay = nlevel37
- elseif playerLevel == 38 then
- levelDisplay = nlevel38
- elseif playerLevel == 39 then
- levelDisplay = nlevel39
- elseif playerLevel == 40 then
- levelDisplay = nlevel40
- elseif playerLevel == 41 then
- levelDisplay = nlevel41
- else
- levelDisplay = playerLevel
- end
- setElementData(thePlayer, "Level", levelDisplay)
- setTimer(setElementData,2000,1,thePlayer, "Country", getElementData(thePlayer,"country"))
- end
- function scoreboardRefreshTrigger()
- local thePlayer = source
- scoreboardRefresh(thePlayer)
- end
- addEventHandler("onPlayerJoin",getRootElement(),scoreboardRefreshTrigger)
- addEventHandler("onPlayerWasted",getRootElement(),scoreboardRefreshTrigger)
- ----------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------
- -- _____ ____ _ --
- -- / ____|/ __ \| | --
- -- _ __ ___ _ _| (___ | | | | | --
- -- | '_ ` _ \| | | |\___ \| | | | | --
- -- | | | | | | |_| |____) | |__| | |____ --
- -- |_| |_| |_|\__, |_____/ \___\_\______| --
- -- __/ | --
- -- |___/ --
- -- --
- ----------------------------------------------------------------------------------
- ----------------------------------------------------------------------------------
- -- Database connection info
- sqlHostname = "217.18.70.182"
- sqlUsername = "blackstar_popi"
- sqlPassword = "pokepoke"
- sqlDefaultDatabase = "blackstar_popi"
- sqlDefaultTable = "userdata"
- --[[
- sqlHostname = "127.0.0.1"
- sqlUsername = "pao13_dtr"
- sqlPassword = ""
- sqlDefaultDatabase = ""
- sqlDefaultTable = ""
- -- Connect to the database
- function mySQLConnect()
- sqlConnection = mysql_connect(sqlHostname,sqlUsername,sqlPassword,sqlDefaultDatabase)
- end
- addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),mySQLConnect)
- -- Make a new entry to the mySQL database
- function checkSqlData(source)
- if (sqlConnection == nil) then
- mySQLConnect()
- end
- local player = source
- local serial = getPlayerSerial(player)
- local entryCheck = sqlConnection:query("SELECT serial FROM "..sqlDefaultTable.." WHERE serial='"..serial.."'")
- if (entryCheck) then
- local result = mysql_result(entryCheck,1,1)
- if (result == "") or (result == nil) then
- outputDebugString("New entry added to the mySQL database!")
- sqlConnection:query("INSERT INTO "..sqlDefaultTable.." (serial) VALUES ('"..serial.."')")
- sqlConnection:query("UPDATE "..sqlDefaultTable.." SET playerName='"..string.gsub(getPlayerName(player),"#%x%x%x%x%x%x", "").."' WHERE serial='"..serial.."'")
- end
- else
- outputDebugString("New entry added to the mySQL database!")
- sqlConnection:query("INSERT INTO "..sqlDefaultTable.." (serial) VALUES ('"..serial.."')")
- sqlConnection:query("UPDATE "..sqlDefaultTable.." SET playerName='"..string.gsub(getPlayerName(player),"#%x%x%x%x%x%x", "").."' WHERE serial='"..serial.."'")
- end
- end
- addEventHandler("onPlayerJoin",getRootElement(),checkSqlData)
- addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
- function()
- for i,player in ipairs (getElementsByType("player")) do
- checkSqlData(player)
- end
- end)
- -- Load data from the database
- function loadPlayerData (player,datatype)
- if (sqlConnection == nil) then
- restartResource(getThisResource())
- end
- if (player) and (datatype) then
- local serial = getPlayerSerial(player)
- local findQuery = sqlConnection:query("SELECT "..datatype.." FROM "..sqlDefaultTable.." WHERE serial='"..serial.."'")
- if (findQuery) then
- local result = mysql_result(findQuery,1,1)
- if not (result == nil) then
- if not (result == "") then
- mysql_free_result(findQuery)
- return result
- else
- mysql_free_result(findQuery)
- return 0
- end
- else
- return 0
- end
- else
- --outputDebugString("Failed to get "..datatype.." for player "..getPlayerName(player).." @ findQuery")
- --outputDebugString("mysql_query failed: (" .. mysql_errno(sqlConnection) .. ") " .. mysql_error(sqlConnection))
- end
- end
- end
- -- Save data to the database
- function savePlayerData (player,datatype,newvalue)
- if (sqlConnection == nil) then
- restartResource(getThisResource())
- end
- if (player) and (datatype) and (newvalue) then
- local serial = getPlayerSerial(player)
- local saveData = sqlConnection:query("UPDATE "..sqlDefaultTable.." SET "..datatype.."='"..newvalue.."' WHERE serial='"..serial.."'")
- if (saveData == nil) then
- outputDebugString("Error executing the save query: (" .. mysql_errno(sqlConnection) .. ") " .. mysql_error(sqlConnection))
- end
- end
- end]]
- -- The load-and-save part.
- function loadPlayerData (player,datatype)
- local playerIP = getPlayerSerial (player)
- if (playerIP) then
- local root = xmlLoadFile ("users.xml")
- if (root) then
- local usersNode = xmlFindChild (root,"user",0)
- if (usersNode) then
- local playerRootNode = xmlFindChild (usersNode,"SERIAL_" .. getPlayerSerial(player),0)
- if not (playerRootNode == false) then
- local playerData = xmlNodeGetAttribute (playerRootNode,datatype)
- if (playerData) then
- xmlUnloadFile (root)
- return playerData
- else
- xmlNodeSetAttribute (playerRootNode,datatype,0)
- xmlSaveFile (root)
- xmlUnloadFile (root)
- return 0
- end
- else
- local playerRootNode = xmlCreateChild (usersNode,"SERIAL_" .. getPlayerSerial(player))
- xmlNodeSetAttribute (playerRootNode,datatype,0)
- xmlSaveFile (root)
- xmlUnloadFile (root)
- return 0
- end
- end
- end
- end
- end
- function savePlayerData (player,datatype,newvalue)
- local playerIP = getPlayerSerial (player)
- if (playerIP) then
- local root = xmlLoadFile ("users.xml")
- if (root) then
- local usersNode = xmlFindChild (root,"user",0)
- if (usersNode) then
- local playerRootNode = xmlFindChild (usersNode,"SERIAL_" .. getPlayerSerial(player),0)
- if not (playerRootNode == false) then
- local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue)
- xmlSaveFile (root)
- xmlUnloadFile (root)
- return newNodeValue
- else
- local playerRootNode = xmlCreateChild (usersNode,"SERIAL_" .. getPlayerSerial(player))
- local newNodeValue = xmlNodeSetAttribute (playerRootNode,datatype,newvalue)
- xmlSaveFile (root)
- xmlUnloadFile (root)
- return newNodeValue
- end
- end
- end
- end
- end
- addCommandHandler("leet",
- function(source,command,money)
- local playerCash = loadPlayerData(source,"cash")
- totalcash = playerCash + money
- savePlayerData(source,"cash", totalcash)
- scoreboardRefresh(source)
- outputChatBox ( "#007FFF[Server]#ffffffYou've been given #007FFF" ..money.. "$#FFFFFF!", getRootElement(), 255, 255, 255, true )
- end
- )
- addCommandHandler("cash",
- function(source)
- local playerCash = loadPlayerData(source,"cash")
- outputChatBox ( '#007FFF[Server]#FFFFFF' .. getPlayerName(source) .. '#FFFFFF has got #007FFF' ..playerCash.. '$#FFFFFF!', getRootElement(), 255, 255, 255, true )
- end
- )
- resourceRoot = getResourceRootElement()
- function chooserandom ()
- setTimer ( give, 400000, 1 )
- end
- addEventHandler ("onResourceStart", resourceRoot, chooserandom)
- function give ()
- local randomPlayer = getRandomPlayer ( )
- randomMoney = math.random ( 500, 2500 )
- local playerCash = loadPlayerData(randomPlayer,"cash")
- if playerCash then
- totalcash = playerCash + randomMoney
- savePlayerData(randomPlayer,"cash", totalcash)
- scoreboardRefresh(randomPlayer)
- end
- outputChatBox ( '#007FFF[Random Money]#FFFFFF' .. getPlayerName ( randomPlayer ) .. '#FFFFFF has been chosen to earn #007FFF' .. randomMoney .. '$#FFFFFF!', getRootElement(), 255, 255, 255, true )
- chooserandom()
- end
- function buyRepair(source)
- if ( isPedInVehicle ( source ) ) then
- local mapName = getMapName()
- if not (string.find (mapName,"DD")) then
- local cashHave = tonumber(loadPlayerData(source,"cash"))
- if (cashHave >= 500) then
- if (getVehicleModelFromName(getVehicleName(getPedOccupiedVehicle(source))) == 425) then
- outputChatBox("#FF0000[Server]#FFFFFFYou can't repair a Hunter!", source, 255, 0, 0, true)
- else
- cashToTake = cashHave - 500
- savePlayerData(source,"cash", cashToTake)
- outputChatBox("#007FFF[Shop]#FFFFFF" ..getPlayerName(source).. "#FFFFFF has bought a repair for #007FFF500$. (/br)", getRootElement(), 255, 255, 0, true)
- fixVehicle (getPedOccupiedVehicle(source))
- scoreboardRefresh(source)
- end
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou need at least #FF0000500$#FFFFFF to buy a repair.", source, 255, 0, 0, true)
- end
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou can't repair your car in a #FF0000DD map!", source, 255, 0, 0, true)
- end
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou've got to be #FF0000alive#FFFFFF to buy a repair!", source, 255, 0, 0, true)
- end
- end
- addCommandHandler('br', buyRepair)
- addCommandHandler('buyrepair', buyRepair)
- function buynitro(source, vehicle)
- if ( isPedInVehicle ( source ) ) then
- local mapName = getMapName()
- if not (string.find (mapName,"DD")) then
- local cashHave = tonumber(loadPlayerData(source,"cash"))
- if (cashHave >= 500) then
- cashToTake = cashHave - 500
- savePlayerData(source,"cash", cashToTake)
- outputChatBox("#007FFF[Shop]#FFFFFF" ..getPlayerName(source).. "#FFFFFF has bought a nitro for #007FFF500$. (/bn)", getRootElement(), 255, 255, 0, true)
- addVehicleUpgrade ( getPedOccupiedVehicle(source), 1010 )
- scoreboardRefresh(source)
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou need at least #FF0000500$#FFFFFF to buy some nitro.", source, 255, 0, 0, true)
- end
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou can't repair your car in a #FF0000DD map!", source, 255, 0, 0, true)
- end
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou've got to be #FF0000alive#FFFFFF to buy some nitro!", source, 255, 0, 0, true)
- end
- end
- addCommandHandler('bn', buynitro)
- addCommandHandler('buynitro', buynitro)
- function buyflip (source)
- rx, ry, rz = getPedRotation (source)
- x, y, z = getElementPosition (source)
- vehicle = getPedOccupiedVehicle (source)
- vehicler = getPedRotation (source)
- if ( isPedInVehicle ( source ) ) then
- local mapName = getMapName()
- if not (string.find (mapName,"DD")) then
- local cashHave = tonumber(loadPlayerData(source,"cash"))
- if cashHave >= 500 then
- cashToTake = cashHave - 500
- savePlayerData(source,"cash", cashToTake)
- outputChatBox("#007FFF[Shop]#FFFFFF" ..getPlayerName(source).. "#FFFFFF has fliped his car for #007FFF500$. (/bf)", getRootElement(), 255, 255, 0, true)
- setVehicleRotation ( vehicle, 0, 0, vehicler, true )
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou need at least #FF0000500$#FFFFFF to flip your car.", source, 255, 0, 0, true)
- end
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou can't repair your car in a #FF0000DD map!", source, 255, 0, 0, true)
- end
- else
- outputChatBox("#FF0000[Shop]#FFFFFFYou've got to be #FF0000alive#FFFFFF to flip your car!", source, 255, 0, 0, true)
- end
- end
- addCommandHandler('bf', buyflip)
- addCommandHandler('buyflip', buyflip)
Advertisement
Add Comment
Please, Sign In to add comment