Jump to content

Problem with stats


LukisLT

Recommended Posts

  
 
 
addEventHandler("onPlayerChat")
function(message,type) ,getRootElement(),
  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 <!-- s:D --><img src=\"{SMILIES_PATH}/icon_biggrin.gif\" alt=\":D\" title=\"Very Happy\" /><!-- s: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)
Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...