Jump to content

Need help here...


GTX

Recommended Posts

Posted

Here seems to be wrong this: if getElementData(source, "state") == "dead" then...

I can't get it... It's working fine if I delete that code

Code:

function earnMoney() 
    local position = getAliveRacePlayers() 
    local acc = getPlayerAccount(source) 
    if getElementData(source, "state") == "dead" then 
    else 
  
    if not (position <= 0) then 
        if getPlayerCount() >= count 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 = getAccountData(acc,"Cash") or 0 
            outputChatBox("#FFFFFF>> #ff8600You have recieved $" .. finalCash .. "!",source,255,255,255,true) 
            setAccountData(acc,"Cash", tostring(playerCash) + finalCash) 
            outputDebugString("Final cash for player "..getPlayerName(source)..": "..finalCash) 
        else 
            outputChatBox("#FFFFFF>> #ff0000Need atleast " .. count .. " players to affect the stats!", source, 255, 255, 255, true) 
            return 
        end 
        scoreboardRefresh(source) 
    end 
end 
end 
addEventHandler("onPlayerWasted", getRootElement(), earnMoney) 

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
  
function earnMoney(old, new) 
    if old == "alive" and new == "dead" then 
    local position = getAliveRacePlayers() 
    local acc = getPlayerAccount(source) 
   -- Missing part? 
    else 
    if not (position <= 0) then 
        if getPlayerCount() >= count 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 = getAccountData(acc,"Cash") or 0 
            outputChatBox("#FFFFFF>> #ff8600You have recieved $" .. finalCash .. "!",source,255,255,255,true) 
            setAccountData(acc,"Cash", tostring(playerCash) + finalCash) 
            outputDebugString("Final cash for player "..getPlayerName(source)..": "..finalCash) 
        else 
            outputChatBox("#FFFFFF>> #ff0000Need atleast " .. count .. " players to affect the stats!", source, 255, 255, 255, true) 
            return 
        end 
        scoreboardRefresh(source) 
    end 
end 
end 
addEventHandler("onPlayerWasted", getRootElement(), earnMoney) 

Try it :)

Btw , your ingame nick is : GTX ?

My Projects!

No one.

Posted
function earnMoney( ) 
    local position = getAliveRacePlayers( ) 
    local acc = getPlayerAccount( source ) 
    if not getElementData( source, "state" ) == "dead" then 
        if not isGuestAccount( acc ) then 
            if type( count ) == 'number' then 
                if not position <= 0 then 
                    if getPlayerCount( ) >= count 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 = getAccountData( acc,"Cash" ) or 0 
                        outputChatBox("#FFFFFF>> #ff8600You have recieved $" .. tostring( finalCash ) .. "!",source,255,255,255,true) 
                        setAccountData( acc,"Cash", tostring( playerCash ) + finalCash ) 
                        outputDebugString( "Final cash for player "..getPlayerName( source )..": "..tostring( finalCash ) ) 
                    else 
                        outputChatBox( "#FFFFFF>> #ff0000Need atleast " .. tostring( count ).. " players to affect the stats!", source, 255, 255, 255, true) 
                        return 
                    end 
                    scoreboardRefresh( source ) 
                end 
            else 
                outputChatBox( 'count variable is not number' ) 
            end  
        end  
    end 
end 
addEventHandler( "onPlayerWasted", root, earnMoney ) 

/debugscript 3 use pls.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

Both codes don't work.

And no, my in-game nick is GTX#

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

What is the "count" variable? is it defined somewhere else in your script or just not defined?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Yes, it is defined

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted

Test it and say what output.

function earnMoney( ) 
    local position = getAliveRacePlayers( ) 
    outputChatBox( 'var:position '..tostring( position ) ) 
    local acc = getPlayerAccount( source ) 
    outputChatBox( 'var:acc '..tostring( acc ) ) 
    outputChatBox( 'var:count '..tostring( count ) ) 
    if not getElementData( source, "state" ) == "dead" then 
        outputChatBox( 'state == dead ' ) 
        if not isGuestAccount( acc ) then 
            outputChatBox( ' not guest account ' ) 
            if type( count ) == 'number' then 
                outputChatBox( 'var:count == number' ) 
                if not position <= 0 then 
                    outputChatBox( 'not positon <= 0' ) 
                    if getPlayerCount( ) >= count then 
                        outputChatBox( 'getPlayerCount( ) >= count' ) 
                        local pAlive = getAliveRacePlayers( ) 
                        local pDead = getDeadRacePlayers( ) 
                        outputChatBox( 'var:pAlive '..tostring( pAlive ) ) 
                        outputChatBox( 'var:pDead '..tostring( pDead ) ) 
                         
                        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 = getAccountData( acc,"Cash" ) or 0 
                        outputChatBox( 'var:playerCash '..tostring( playerCash ) ) 
                        outputChatBox("#FFFFFF>> #ff8600You have recieved $" .. tostring( finalCash ) .. "!",source,255,255,255,true) 
                        setAccountData( acc,"Cash", tostring( playerCash ) + finalCash ) 
                        outputDebugString( "Final cash for player "..getPlayerName( source )..": "..tostring( finalCash ) ) 
                    else 
                        outputChatBox( "#FFFFFF>> #ff0000Need atleast " .. tostring( count ).. " players to affect the stats!", source, 255, 255, 255, true) 
                        return 
                    end 
                    scoreboardRefresh( source ) 
                end 
            else 
                outputChatBox( 'count variable is not number' ) 
            end  
        else 
            outputChatBox( 'guest account ' ) 
        end  
    end 
end 
addEventHandler( "onPlayerWasted", root, earnMoney ) 

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

var:position 2

var:acc userdata: 0x90d5e90

var:count 2

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted (edited)

Can you explain data name 'state' and value 'dead'?

Edited by Guest

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

Posted

I got 'state' from race resource, so if player's state is 'dead' then...

Do you require a paid scripter? Contact me! (Unavailable) Currently I am experienced in Lua, PHP, HTML, CSS, SQL and JS.

Developer and owner of

https://projectbea.st - Project Beast
Posted
I got 'state' from race resource, so if player's state is 'dead' then...

You want check if player not dead but dead? :D

function earnMoney( ) 
    local position = getAliveRacePlayers( ) 
    outputChatBox( 'var:position '..tostring( position ) ) 
    local acc = getPlayerAccount( source ) 
    outputChatBox( 'var:acc '..tostring( acc ) ) 
    outputChatBox( 'var:count '..tostring( count ) ) 
    --if getElementData( source, "state" ) == "dead" then 
        outputChatBox( 'state == dead ' ) 
        if not isGuestAccount( acc ) then 
            outputChatBox( ' not guest account ' ) 
            if type( count ) == 'number' then 
                outputChatBox( 'var:count == number' ) 
                if not position <= 0 then 
                    outputChatBox( 'not positon <= 0' ) 
                    if getPlayerCount( ) >= count then 
                        outputChatBox( 'getPlayerCount( ) >= count' ) 
                        local pAlive = getAliveRacePlayers( ) 
                        local pDead = getDeadRacePlayers( ) 
                        outputChatBox( 'var:pAlive '..tostring( pAlive ) ) 
                        outputChatBox( 'var:pDead '..tostring( pDead ) ) 
                         
                        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 = getAccountData( acc,"Cash" ) or 0 
                        outputChatBox( 'var:playerCash '..tostring( playerCash ) ) 
                        outputChatBox("#FFFFFF>> #ff8600You have recieved $" .. tostring( finalCash ) .. "!",source,255,255,255,true) 
                        setAccountData( acc,"Cash", tostring( playerCash ) + finalCash ) 
                        outputDebugString( "Final cash for player "..getPlayerName( source )..": "..tostring( finalCash ) ) 
                    else 
                        outputChatBox( "#FFFFFF>> #ff0000Need atleast " .. tostring( count ).. " players to affect the stats!", source, 255, 255, 255, true) 
                        return 
                    end 
                    scoreboardRefresh( source ) 
                end 
            else 
                outputChatBox( 'count variable is not number' ) 
            end  
        else 
            outputChatBox( 'guest account ' ) 
        end  
    --end 
end 
addEventHandler( "onPlayerWasted", root, earnMoney ) 

You not need check it :lol:

Code updated.

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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