Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addEventHandler("onPlayerChat",root,
- function(message,type)
- if (string.find(message,"!points")) and not (string.find(message," !points")) then
- local playerPoints = loadPlayerData (source,"points")
- setTimer(outputChatBox,50,1,getPlayerName (source) .. " #FF0000has " .. tostring(playerPoints) .. " points!",getRootElement(),255,0,0,true)
- elseif (string.find(message,"!cash")) and not (string.find(message," !cash")) then
- local playerCash = loadPlayerData (source,"cash")
- setTimer(outputChatBox,50,1,getPlayerName (source) .. " #FF0000has " .. tostring(playerCash) .. "$!",getRootElement(),255,0,0,true)
- elseif (string.find(message,"!inforollpl")) and not (string.find(message," !inforollpl")) then
- setTimer(outputChatBox,50,1,"blahblahblah",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"Anyone can translate the english part o_o",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"and blah blah blah...",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"Wesseb maybe o.o",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"Or pat:<",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"Maybe eminem o_o",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"I can't speak polish :< sorry people:'(",source,255,0,0,false)
- elseif (string.find(message,"!inforoll")) and not (string.find(message," !inforoll")) then
- setTimer(outputChatBox,50,1,"Type !roll for start roll (cost 100$)!",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"First is generated if you will win money. ",source,255,0,0,false)
- setTimer(outputChatBox,50,1," 1/4 - You win points and generated cash",source,255,0,0,false)
- setTimer(outputChatBox,50,1," 1/4 - You win cash",source,255,0,0,false)
- setTimer(outputChatBox,50,1," 2/4 - You lose cash",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"You can win 1000$ max!",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"You can lose 1000$ max!",source,255,0,0,false)
- elseif (string.find(message,"!roll")) and not (string.find(message," !roll")) then
- local playerCash = loadPlayerData (source,"cash")
- if (tonumber(playerCash) > 100) then
- if not (rollLimitCheckPlayerIsIn (source)) then
- savePlayerData (source,"cash",loadPlayerData (source,"cash") -100)
- local firstRollNumber = math.random (1,4)
- local secondRollNumber = math.random (0,1000)
- local thirdRollNumber = math.random (0,10)
- rollLimitAddPlayer (source)
- if (firstRollNumber == 1) then
- setTimer(outputChatBox,50,1,"You win points AND cash! Calculating ...",source,255,0,0,false)
- setTimer(outputChatBox,500,1,"You've won " .. tostring (secondRollNumber) .. "$ and " .. tostring (thirdRollNumber) .. " points!",source,255,0,0,false)
- setTimer(savePlayerData,500,1,source,"cash",loadPlayerData(source,"cash") +secondRollNumber)
- setTimer(savePlayerData,500,1,source,"points",loadPlayerData(source,"points") +thirdRollNumber)
- elseif (firstRollNumber == 2) then
- setTimer(outputChatBox,50,1,"You win cash! Calculating ...",source,255,0,0,false)
- setTimer(outputChatBox,500,1,"You've won " .. tostring (secondRollNumber) .. "$!",source,255,0,0,false)
- setTimer(savePlayerData,500,1,source,"cash",loadPlayerData(source,"cash") +secondRollNumber)
- elseif (firstRollNumber == 3) then
- setTimer(outputChatBox,50,1,"You lose cash! Calculating ...",source,255,0,0,false)
- setTimer(outputChatBox,500,1,"You've lost " .. tostring (secondRollNumber) .. "$!",source,255,0,0,false)
- setTimer(savePlayerData,500,1,source,"cash",loadPlayerData(source,"cash") -secondRollNumber)
- elseif (firstRollNumber == 4) then
- setTimer(outputChatBox,50,1,"You lose cash! Calculating ...",source,255,0,0,false)
- setTimer(outputChatBox,500,1,"You've lost " .. tostring (secondRollNumber) .. "$!",source,255,0,0,false)
- setTimer(savePlayerData,500,1,source,"cash",loadPlayerData(source,"cash") -secondRollNumber)
- end
- else
- outputChatBox ("You only can use !roll once a minute!",source,255,0,0,false)
- cancelEvent()
- end
- else
- setTimer(outputChatBox,50,1,"You don't have got 100$, you need that before rolling!",source,255,0,0,false)
- end
- elseif (string.find(message,"!lang")) and not (string.find(message," !lang")) then
- setTimer(outputChatBox,50,1,"Enabled languages: Polish, English, (and Dutch)",getRootElement(),255,0,0,false)
- elseif (string.find(message,"!commands")) and not (string.find(message," !commands")) then
- setTimer(outputChatBox,50,1," Commands",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"!cash - see your cash!",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"!points - see your points!",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"!roll - win or lose points and money! (100$)",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"!inforollpl - More info about !roll (polish)",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"!inforoll - More info about !roll (english)",source,255,0,0,false)
- setTimer(outputChatBox,50,1,"!lang - Let see the enabled languages!",source,255,0,0,false)
- setTimer(outputChatBox,2550,1,"[CENSORED] /buykick /buyfreeze :<",source,255,0,0,false)
- if hasObjectPermissionTo ( source, "function.kickPlayer", false ) then
- setTimer(outputChatBox,2550,1," Admin commands (only admins see this)",source,255,0,0,false)
- setTimer(outputChatBox,2550,1,"/setPlayerData [player] [datatype] [amount] - Set players data",source,255,0,0,false)
- setTimer(outputChatBox,2550,1,"/getPlayerData [player] [datatype] - Get players data",source,255,0,0,false)
- setTimer(outputChatBox,2550,1,"/addvip [player] - Make a player VIP!",source,255,0,0,false)
- setTimer(outputChatBox,2550,1,"/removevip [player] - Remove a players VIP!",source,255,0,0,false)
- end
- if (loadPlayerData (source,"teamrank") == "vipt") then
- setTimer(outputChatBox,2550,1," VIP functions",source,255,0,0,false)
- setTimer(outputChatBox,2550,1,"/enterteam - Enter the Vip Test Members !",source,255,0,0,false)
- end
- end
- end)
- addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),
- function()
- outputChatBox ("#ffff00Points #ffffffand #ffff00cash #ffffffsystem loaded",getRootElement(),255,255,255,true)
- end)
- addCommandHandler("getPlayerData",
- 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 ("Succesfully data get - From: " .. getPlayerName(toplayer) .. " #FF0000- Datatype: " .. datatype .. " - amount: " .. amount .. ".",player,255,0,0,true)
- end
- else
- outputChatBox ("WRONG! Syntax: /getPlayerData [playername (partical)] [datatype]",player,255,0,0,false)
- end
- else
- outputChatBox ("Sorry, only admins can use this!",player,255,0,0,false)
- end
- end)
- addCommandHandler("setPlayerData",
- 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 ("Succesfully data set - To: " .. getPlayerName(toplayer) .. " #FF0000- Datatype: " .. datatype .. " - amount: " .. amount, player,255,0,0,true)
- outputChatBox (getPlayerName (player) .. " #FF0000have set new data for you! - Datatype: " .. datatype .. " - amount: " .. amount, toplayer,255,0,0,true)
- end
- else
- outputChatBox ("WRONG! Syntax: /setPlayerData [playername (partical)] [datatype] [amount]",player,255,0,0,false)
- end
- else
- outputChatBox ("Sorry, only admins can use this!",player,255,0,0,false)
- end
- end)
- addCommandHandler("addvip",
- function(player,command,toplayername)
- if hasObjectPermissionTo ( player, "function.kickPlayer", false ) then
- if (toplayername) then
- if (findPlayerByName (toplayername)) then
- toplayer = findPlayerByName (toplayername)
- savePlayerData (toplayer,"teamrank","vipt")
- outputChatBox ("Succesfully vipt added to: " .. getPlayerName(toplayer) .. ".", player,255,0,0,true)
- outputChatBox (getPlayerName (player) .. " #FF0000has made you VIPt! Fast do !commands for your new commands!", toplayer,255,0,0,true)
- else
- outputChatBox ("WRONG! Unknown username!",player,255,0,0,false)
- end
- else
- outputChatBox ("WRONG! Syntax: /addvipt [playername (partical)]",player,255,0,0,false)
- end
- else
- outputChatBox ("Sorry, only admins can use this!",player,255,0,0,false)
- end
- end)
- addCommandHandler("removevip",
- function(player,command,toplayername)
- if hasObjectPermissionTo ( player, "function.kickPlayer", false ) then
- if (toplayername) then
- if (findPlayerByName (toplayername)) then
- toplayer = findPlayerByName (toplayername)
- savePlayerData (toplayer,"teamrank","none")
- outputChatBox ("Succesfully VIP removed from: " .. getPlayerName(toplayer) .. ".", player,255,0,0,true)
- outputChatBox (getPlayerName (player) .. " #FF0000has removed your VIPt :<", toplayer,255,0,0,true)
- else
- outputChatBox ("WRONG! Unknown username!",player,255,0,0,false)
- end
- else
- outputChatBox ("WRONG! Syntax: /removevipt [playername (partical)]",player,255,0,0,false)
- end
- else
- outputChatBox ("Sorry, only admins can use this!",player,255,0,0,false)
- end
- end)
- addCommandHandler("enterteam",
- function(player,command)
- if (loadPlayerData (player,"teamrank") == "vipt") then
- if (vipteam) then
- setPlayerTeam (player,viptteam)
- else
- viptteam = createTeam ("Vip Members",0,255,127)
- setPlayerTeam (player,viptteam)
- end
- end
- end)
- function checkVIPTplayers ()
- if (viptteam) then
- local teamPlayerCount = countPlayersInTeam (viptteam)
- if (teamPlayerCount == 0) then
- destroyElement (viptteam)
- end
- end
- end
- addEventHandler ("onPlayerQuit",getRootElement(),checkVIPTplayers)
- addEventHandler ("onPlayerJoin",getRootElement(),checkVIPTplayers)
- --[[ddCommandHandler ("buykick",
- function(player,command,kickPlayerName)
- local playerCash = loadPlayerData (player,"cash")
- if (tonumber(playerCash) > 19999) then
- if (findPlayerByName (kickPlayerName)) then
- local playerToKick = findPlayerByName (kickPlayerName)
- setTimer(kickPlayer,2500,1,playerToKick,getPlayerName(player) .. " have buykicked you!")
- outputChatBox (getPlayerName(playerToKick) .. " #FF0000is buykicked by " .. getPlayerName(player) .. "#FF0000.",getRootElement(),255,0,0,true)
- savePlayerData (player,"cash",loadPlayerData(player,"cash") -20000)
- else
- outputChatBox ("The nickname seems to be wrong.",player,255,0,0,false)
- end
- else
- outputChatBox ("You can't kick anyone, you need 20,000$ first!",player,255,0,0,false)
- end
- end)
- addCommandHandler ("buyfreeze",
- function(player,command,kickPlayerName)
- local playerCash = loadPlayerData (player,"cash")
- if (tonumber(playerCash) > 6999) then
- if (findPlayerByName (kickPlayerName)) then
- local playerToKick = findPlayerByName (kickPlayerName)
- setElementFrozen (getPedOccupiedVehicle(playerToKick),true)
- setTimer (setElementFrozen,30000,1,getPedOccupiedVehicle(playerToKick),false)
- setTimer (outputChatBox,30000,1,getPlayerName(playerToKick) .. " #FF0000is defrozen. Have a nice day :D",getRootElement(),255,0,0,true)
- outputChatBox (getPlayerName(playerToKick) .. " #FF0000is buyfreezed by " .. getPlayerName(player) .. "#FF0000 (30 seconds).",getRootElement(),255,0,0,true)
- savePlayerData (player,"cash",loadPlayerData(player,"cash") -7000)
- else
- outputChatBox ("The nickname seems to be wrong.",player,255,0,0,false)
- end
- else
- outputChatBox ("You can't freeze anyone, you need 7,000$ first!",player,255,0,0,false)
- end
- end)]]--
- -- extra roll functions
- rollusers = {}
- function rollLimitCheckPlayerIsIn (player)
- for i,v in ipairs (rollusers) do
- if (v == player) then
- return true
- end
- end
- end
- function rollLimitAddPlayer (player)
- table.insert (rollusers,player)
- end
- function rollLimitCleanUp2 ()
- for i,v in ipairs (rollusers) do
- table.remove (rollusers,i)
- end
- end
- --[[addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),
- function()
- if (rollLimitTimer2) then
- outputChatBox ("Roll limit timer found, Delete and create new one.")
- killTimer (rollLimitTimer2)
- rollLimitTimer2 = setTimer (rollLimitCleanUp2,60000,0)
- else
- outputChatBox ("Roll limit timer not found, create new one.")
- rollLimitTimer2 = setTimer (rollLimitCleanUp2,60000,0)
- end
- end)]]--
- -- stop extra roll functions
- addEventHandler ("onPlayerRaceWasted",getRootElement(),
- function()
- killPed (source)
- setElementHealth (source,0)
- if (isPedInVehicle(source)) then
- blowVehicle (getPedOccupiedVehicle(source))
- end
- end)
- addEventHandler ("onPlayerJoin",getRootElement(),
- function()
- setElementHealth (source,0)
- setTimer (setElementHealth,1500,1,0)
- savePlayerData (source,"lastPlayerName",getPlayerName(source))
- end)
- addEventHandler ("onPlayerChangeNick",getRootElement(),
- function(olnick,newnick)
- savePlayerData (source,"lastPlayerName",newnick)
- end)
- function checkWinAndIfWinGiveWinCash (totalAmmo,killer,killerWeapon,bodypart,stealth)
- local rank = getAliveCount()
- if (rank == 1) then
- local allAlivePlayers = getAlivePlayers()
- local player = allAlivePlayers[1]
- local playerCount = getPlayerCount()
- local pointsToWin = playerCount *13
- local cashToWin = playerCount *53
- savePlayerData (player,"points",loadPlayerData(player,"points") + pointsToWin)
- savePlayerData (player,"cash",loadPlayerData(player,"cash") +cashToWin)
- outputChatBox (getPlayerName(player) .." #FF0000is first! He wins ".. tostring(pointsToWin).." points and "..tostring(cashToWin).."$!",getRootElement(),255,0,0,true)
- end
- end
- addEventHandler ("onPlayerWasted",getRootElement(),checkWinAndIfWinGiveWinCash)
- addEventHandler ("onPlayerQuit",getRootElement(),checkWinAndIfWinGiveWinCash)
- function findPlayerByName (playerPart)
- for i,v in ipairs (getElementsByType ("player")) do
- if (string.find(getPlayerName(v),playerPart)) then
- return v
- end
- end
- end
- function getDeadCount ()
- deadAmount = 0
- for i,v in ipairs (getDeadPlayers()) do
- deadAmount = deadAmount +1
- end
- return deadAmount
- end
- function getSpawnedCount ()
- spawnedAmount = 0
- for i,v in ipairs (getAlivePlayers()) do
- if (isPedInVehicle (v)) then
- spawnedAmount = spawnedAmount +1
- end
- end
- return spawnedAmount
- end
- function getAliveCount ()
- aliveAmount = 0
- for i,v in ipairs (getAlivePlayers()) do
- aliveAmount = aliveAmount +1
- end
- return aliveAmount
- 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
Advertisement
Add Comment
Please, Sign In to add comment