Jump to content

Help Me


Resto

Recommended Posts

Hi I would need help always when I want to add !msgs or !messages so I do not and it means that when someone types !msgs / !messages so give him Resto sent a total of 4500 messages ..

The second problem is that I would like to know how many a player !cash !deaths !playtime !wins !hunters !messages so that, for example write !cash Resto Resto and writing it has $400

Then there is another bug that when you win so I do not win when you win but I have to jump into the water or be capable Blow me, please help me! :(

This is my script:

Stats_Client:

function addColumns() 
    exports.scoreboard:scoreboardAddColumn("Home",15) 
    exports.scoreboard:scoreboardAddColumn("Country",50) 
    exports.scoreboard:scoreboardAddColumn("Money",60) 
    exports.scoreboard:scoreboardAddColumn("Points",50) 
    exports.scoreboard:scoreboardAddColumn("fps",20) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), addColumns) 
  
addEventHandler('onClientPlayerJoin', root, 
    function() 
        setElementData(source,"Points",0) 
        setElementData(source,"Playtime",0) 
        setElementData(source,"Wins",0) 
        setElementData(source,"Deaths",0) 
        setElementData(source,"Hunters",0) 
    end 
) 
  

Stats_Server:

gRoot = getRootElement() 
LastWinners={"","","","",""} 
  
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) and not isGuestAccount ( playeraccount ) then  
            local playermoney = getPlayerMoney ( source )  
            local playerpoints = getElementData(source,"Points") 
            local playertime = getElementData(source,"Playtime") 
            local playerwins = getElementData(source,"Wins") 
            local playerdeaths = getElementData(source,"Deaths") 
            local playerhunters = getElementData(source,"Hunters") 
            setAccountData ( playeraccount, "money", playermoney ) 
            setAccountData ( playeraccount, "points", playerpoints ) 
            setAccountData ( playeraccount, "playtime", playertime ) 
            setAccountData ( playeraccount, "wins", playerwins ) 
            setAccountData ( playeraccount, "deaths", playerdeaths ) 
            setAccountData ( playeraccount, "hunters", playerhunters ) 
      end 
end 
  
function onPlayerLogin (_, playeraccount ) 
    if ( playeraccount ) then 
        local playermoney = getAccountData ( playeraccount, "money" ) 
        local playerpoints = getAccountData ( playeraccount, "points" ) 
        local playertime = getAccountData ( playeraccount, "playtime" ) 
        local playerwins = getAccountData ( playeraccount, "wins" ) 
        local playerdeaths = getAccountData ( playeraccount, "deaths" ) 
        local playerhunters = getAccountData ( playeraccount, "hunters" ) 
        setPlayerMoney ( source, playermoney ) 
        setElementData(source,"Points",playerpoints or 0) 
        setElementData(source,"Playtime",playertime or 0) 
        setElementData(source,"Wins",playerwins or 0) 
        setElementData(source,"Deaths",playerdeaths or 0) 
        setElementData(source,"Hunters",playerhunters or 0) 
    end 
end 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin) 
  
function ResetStats (player, command) 
    local nick = getPlayerName(player) 
    setElementData(player,"Points",0) 
    outputChatBox("Player #FFFFFF" .. nick .. " #009BFFhas reseted all points!", getRootElement(), 0, 155, 255, true) 
end 
addCommandHandler("resetpoints", ResetStats) 
  
function BuyNos (player, command) 
    if (getPlayerMoney(player) > 3000) then 
        local auto = getPedOccupiedVehicle(player) 
        local nick = getPlayerName(player) 
        addVehicleUpgrade(auto,1010) 
        setPlayerMoney(player, getPlayerMoney(player) - 3000 ) 
        outputChatBox("Player #FFFFFF" .. nick .. " #009BFFbought for $3000 nitro! #FFFFFF(/nos)", getRootElement(), 0, 155, 255, true) 
        else  
        outputChatBox("Not enough money.", player, 0, 155, 255, true) 
    end 
end  
addCommandHandler("nos", BuyNos) 
  
function BuyRepair (player, command) 
    if (getPlayerMoney(player) > 10000) then 
        local auto = getPedOccupiedVehicle(player) 
        local nick = getPlayerName(player) 
        fixVehicle(auto) 
        setPlayerMoney(player, getPlayerMoney(player) - 10000 ) 
        outputChatBox("Player #FFFFFF" .. nick .. " #009BFFbought for $10 000 repair! #FFFFFF(/fix)", getRootElement(), 0, 155, 255, true) 
        else 
        outputChatBox("Not enough money.", player, 0, 155, 255, true) 
    end 
end 
addCommandHandler("fix", BuyRepair) 
  
function BuyFlip (player, command) 
    if (getPlayerMoney(player) > 5000) then 
        local auto = getPedOccupiedVehicle(player) 
        local nick = getPlayerName(player) 
        rx, ry, rz = getVehicleRotation (auto) 
        setVehicleRotation (auto, rx +180, ry, rz +180) 
        setPlayerMoney(player, getPlayerMoney(player) - 5000 ) 
        outputChatBox("Player #FFFFFF" .. nick .. " #009BFFbought for $5000 flip! #FFFFFF(/flip)", getRootElement(), 0, 155, 255, true) 
        else 
        outputChatBox("Not enough money.", player, 0, 155, 255, true) 
    end 
end 
addCommandHandler("flip", BuyFlip) 
  
addEventHandler ("onPlayerChat",getRootElement(), 
function(message,type) 
    local nick = getPlayerName(source) 
    if (string.find(message,"!points")) and not (string.find(message," !points")) then 
        local playerpoints = getElementData(source,"Points") 
        outputChatBox("" .. nick .. " #009BFFhas #FFFFFF" .. playerpoints .. "#009BFF points!", getRootElement(), 0, 155, 255, true) 
    else if (string.find(message,"!cash")) and not (string.find(message," !cash")) then 
        outputChatBox("" .. nick .. " #009BFFhas #FFFFFF" .. getPlayerMoney(source) .. "$#009BFF !", getRootElement(), 0, 155, 255, true) 
    else if (string.find(message,"!playtime")) and not (string.find(message," !playtime")) then 
        local playertime = getElementData(source,"Playtime") 
        outputChatBox("" .. nick .. " #009BFFhas played for #FFFFFF" .. playertime .. "#009BFF minutes!", getRootElement(), 0, 155, 255, true) 
    else if (string.find(message,"!wins")) and not (string.find(message," !wins")) then 
        local playerwins = getElementData(source,"Wins") 
        outputChatBox("" .. nick .. " #009BFFhas #FFFFFF" .. playerwins .. "#009BFF wins!", getRootElement(), 0, 155, 255, true) 
    else if (string.find(message,"!deaths")) and not (string.find(message," !deaths")) then 
        local playerdeaths = getElementData(source,"Deaths") 
        outputChatBox("" .. nick .. " #009BFFhas #FFFFFF" .. playerdeaths .. "#009BFF deaths!", getRootElement(), 0, 155, 255, true) 
    else if (string.find(message,"!hunters")) and not (string.find(message," !hunters")) then 
        local playerhunters = getElementData(source,"Hunters") 
        outputChatBox("" .. nick .. " #009BFFhas #FFFFFF" .. playerhunters .. "#009BFF hunters!", getRootElement(), 0, 155, 255, true) 
    end 
    end 
    end 
    end 
    end 
end 
end) 
  
function updatePlayersStats ( ) 
    for index, player in ipairs ( getElementsByType "player" ) do  
    setElementData ( player, "Money", "$".. getPlayerMoney ( player ).." " ) 
    end 
end 
setTimer ( updatePlayersStats, 5000, 0 ) 
  
function UpdateMinute ( ) 
    for index, player in ipairs ( getElementsByType "player" ) do 
        setElementData(player,"Playtime",tonumber(getElementData(player,"Playtime"))+1) 
    end 
end 
setTimer ( UpdateMinute, 60000, 0 ) 
  
function checkForHunter(number,sort,model) 
    thePlayer = source 
    if sort == "vehiclechange" then 
        if model == 425 then 
            if getElementData(thePlayer,"playerGotHunter") == false then 
                setElementData(thePlayer,"playerGotHunter",true) 
                outputChatBox ( getPlayerName(source).." #009BFFhas gotten the hunter! +400 Points and $5000.", getRootElement(), 0, 155, 255, true ) 
                setElementData(thePlayer,"Points",tonumber(getElementData(thePlayer,"Points"))+400) 
                givePlayerMoney(thePlayer,5000) 
                setElementData(thePlayer,"Hunters",tonumber(getElementData(thePlayer,"Hunters"))+1) 
                setSkyGradient( 60, 100, 196, 136, 170, 212 ) 
                setWaterColor ( 117, 71, 34, 255 ) 
            end 
        end 
    end 
end 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),checkForHunter) 
  
function onPlayerDeadInRace() 
    local thePlayer = source 
    local dPlayers = getDeadRacePlayers() 
    local aPlayers = getAliveRacePlayers() 
    local Position = aPlayers + 1 
local playeraccount = getPlayerAccount ( thePlayer ) 
if ( playeraccount ) and not isGuestAccount ( playeraccount ) then 
    if dPlayers + aPlayers >= 2 then 
        local cashForPlayer = math.floor((120/Position)*(dPlayers + aPlayers)) 
        local pointsForPlayer = math.floor((30/Position)*(dPlayers + aPlayers)) 
        givePlayerMoney(thePlayer,cashForPlayer) 
        setElementData(thePlayer,"Points",tonumber(getElementData(thePlayer,"Points"))+pointsForPlayer) 
        if Position == 1 then 
            outputChatBox ("#FFFFFF".. getPlayerName(thePlayer) .." #009BFFis first! He wins #FFFFFF" .. pointsForPlayer .." #009BFFpoints and #FFFFFF" .. cashForPlayer .."$#009BFF!",gRoot,0,155,255,true) 
            setElementData(thePlayer,"Wins",tonumber(getElementData(thePlayer,"Wins"))+1) 
                if LastWinners[1] == "" then 
                    if LastWinners[2] == "" then 
                        if LastWinners[3] == "" then 
                            if LastWinners[4] == "" then 
                                if LastWinners[5] == "" then 
                                    LastWinners[5] = thePlayer 
                                else 
                                    LastWinners[4] = thePlayer 
                                end 
                            else 
                                LastWinners[3] = thePlayer 
                            end 
                        else 
                            LastWinners[2] = thePlayer 
                        end 
                    else 
                        LastWinners[1] = thePlayer 
                    end 
                else 
                    LastWinners[5] = LastWinners[4] 
                    LastWinners[4] = LastWinners[3] 
                    LastWinners[3] = LastWinners[2] 
                    LastWinners[2] = LastWinners[1] 
                    LastWinners[1] = thePlayer 
                end 
  
        else 
            outputChatBox ("You have recieved #FFFFFF" .. pointsForPlayer .." #009BFFpoints and #FFFFFF" .. cashForPlayer .."$#009BFF!",thePlayer,0,155,255,true) 
            setElementData(thePlayer,"Deaths",tonumber(getElementData(thePlayer,"Deaths"))+1) 
        end 
    else 
        outputChatBox("Min. 2 players to get stats and cash!",thePlayer,0,155,255,true) 
    end 
else 
    outputChatBox("Please login to obtain statistics",thePlayer,0,155,255,true) 
end 
end 
addEvent("onPlayerWasted", true) 
addEventHandler("onPlayerWasted", gRoot , onPlayerDeadInRace) 
  
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 
  

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...