Jump to content

[RACE]Give Money and money collum scoreboard.


Admigo

Recommended Posts

Dear Scripters,

I want to make when u get the hunter u will get 1000 money.

But when i take the hunter i dont get money.

And i made a money collum for score board but it dont work.

Code Hunter Money:

function SToptimesManager:playerFinished( player, newTime, dateRecorded ) 
    -- Check if top time recording is disabled for this player 
    if getElementData ( player, "toptimes" ) == "off" then 
        return 
    end 
  
    if not self.mapTimes then 
        outputDebug( 'TOPTIMES', 'SToptimesManager:playerFinished - self.mapTimes == nil' ) 
        return 
    end 
  
    dateRecorded = dateRecorded or getRealDateTimeNowString() 
  
    local oldTime   = self.mapTimes:getTimeForPlayer( player )  -- Can be false if no previous time 
    local newPos    = self.mapTimes:getPositionForTime( newTime, dateRecorded ) 
  
    -- See if time is an improvement for this player 
    if not oldTime or newTime < oldTime then 
  
        local oldPos    = self.mapTimes:getIndexForPlayer( player ) 
        triggerEvent("onPlayerToptimeImprovement", player, newPos, newTime, oldPos, oldTime, self.displayTopCount, self.mapTimes:getValidEntryCount() ) 
  
        -- See if its in the top display 
        if newPos <= self.displayTopCount then 
            outputChatBox( '#FF6600[TOPTIME]: #FFFFFF' .. getPlayerName(source) .. ' #FFFFFFgot toptime position #FF6600' .. newPos ..  ' #FF6600[Time: ' .. SMaptimes:timeMsToTimeText(newTime) .. ']', root,  2, 255, 2, true) 
        givePlayerMoney ( player, 1000 ) 
        end 
  
        if oldTime then 
            outputDebug( '#FF6600[TOPTIME]: #FFFFFF' .. getPlayerName(source) .. ' #FFFFFFgot toptime position #FF6600' .. newPos ..  ' #FF6600[Time: ' .. SMaptimes:timeMsToTimeText(newTime) .. ']', root,  2, 255, 2, true) 
        givePlayerMoney ( player, 1000 ) 
        end 
  
        self.mapTimes:setTimeForPlayer( player, newTime, dateRecorded ) 
  
        -- updateTopText if database was changed 
        if newPos <= self.displayTopCount then 
            self:updateTopText() 
        end 
    end 
  
    outputDebug( 'TOPTIMES', '++ SToptimesManager:playerFinished ' .. tostring(getPlayerName(player)) .. ' time:' .. tostring(newTime) ) 
end 

Code Money Collum Client:

addEventHandler("onClientResourceStart",resourceRoot, 
function () 
    setTimer(updateMoney, 1000, 0) 
end) 
  
function updateMoney() 
    local newMoney = getPlayerMoney ( localPlayer ) 
    if pMoney ~= newMoney then 
        pMoney = newMoney 
        setElementData ( localPlayer, "Money", newMoney ) 
    end 
end 

Code Money Collum Server:

addEventHandler("onResourceStart",resourceRoot, 
    function() 
    call(getResourceFromName("scoreboard"),"addScoreboardColumn","Money") 
  
    end 
) 

Pls,how can i fix this problems?

Thanks Admigo

Link to comment
function someoneReachedHunter(number, sort, model) 
    if sort == "vehiclechange" and model == 425 then 
        outputChatBox ( getPlayerName(source).." #FF6464has gotten the hunter! Run!", getRootElement(), 255, 255, 255, true ) 
        givePlayerMoney ( source , 1000 ) 
    end 
end 
addEvent("onPlayerPickUpRacePickup",true) 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),someoneReachedHunter) 

Just added an line to scripter 'hunter_alert' From resources

Link to comment
  
local oldMoney = getPlayerMoney() 
  
function renderMoney() 
    newMoney = getPlayerMoney() 
    if ( tonumber(newMoney) ~= tonumber(oldMoney) ) then 
         triggerEvent("onClientMoneyChange",localPlayer,oldMoney,newMoney) 
         oldMoney = newMoney 
    end 
end 
addEventHandler("onClientRender",root,renderMoney) 
  
addEvent("onClientMoneyChange",true) 
addEventHandler("onClientMoneyChange",root, 
function (old, new) 
    setElementData ( localPlayer, "Money", new ) 
end) 

Modified 1 line , made by solidsnake..

Link to comment
function someoneReachedHunter(number, sort, model) 
    if sort == "vehiclechange" and model == 425 then 
        outputChatBox ( getPlayerName(source).." #FF6464has gotten the hunter! Run!", getRootElement(), 255, 255, 255, true ) 
        givePlayerMoney ( source , 1000 ) 
    end 
end 
addEvent("onPlayerPickUpRacePickup",true) 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),someoneReachedHunter) 

Just added an line to scripter 'hunter_alert' From resources

Works but only one problem,when u stay longer in the hunter pickup u get more money.

And the scoreboard:

local oldMoney = getPlayerMoney() 
  
function renderMoney() 
    newMoney = getPlayerMoney() 
    if ( tonumber(newMoney) ~= tonumber(oldMoney) ) then 
         triggerEvent("onClientMoneyChange",localPlayer,oldMoney,newMoney) 
         oldMoney = newMoney 
    end 
end 
addEventHandler("onClientRender",root,renderMoney) 
  
addEvent("onClientMoneyChange",true) 
addEventHandler("onClientMoneyChange",root, 
function (old, new) 
    setElementData ( localPlayer, "Money", new ) 
end) 

When you get the hunter u get money and you see money in the scoreboard but when there comes a new map the money collum is 0 but at admin you see that you have money.

How can i fix this pls.

Link to comment
addEventHandler('onGamemodeMapStart', root, 
        local money = getPlayerMoney ( localPlayer ) 
        setElementData ( localPlayer, "Money", money ) 
end) 

I put the code in script now i get spam errors in debuscript NameTags.lua 38:Bad Argument 1# to ipairs (table exptected,got nil)

I deleted the code but now i get the error everytime and cant play race gm anymore. I didnt change something in nametag.

How to fix it?

Link to comment
  
local oldMoney = getPlayerMoney() 
  
function renderMoney() 
    newMoney = getPlayerMoney() 
    if ( tonumber(newMoney) ~= tonumber(oldMoney) ) then 
         triggerEvent("onClientMoneyChange",localPlayer,oldMoney,newMoney) 
         oldMoney = newMoney 
    end 
end 
addEventHandler("onClientRender",root,renderMoney) 
  
addEvent("onClientMoneyChange",true) 
addEventHandler("onClientMoneyChange",root, 
function (old, new) 
    setElementData ( localPlayer, "Money", new ) 
end) 

Modified 1 line , made by solidsnake..

Can you send my this code with the new code pls?

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