Jump to content

State Problem


EvoGT

Recommended Posts

function DestructionWin( vehicle ) 
    local alivePlayers = getAlivePlayers( ) 
    if (#alivePlayers == 1) then 
        if isElement( alivePlayers[1] ) then 
            local account = getPlayerAccount( alivePlayers[1] ) 
            if isGuestAccount( account ) then return end 
                local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM")) 
                savePlayerData(thePlayer,"mapsWonDM", mapsWonDM+1) 
            outputChatBox ( "#00FF00* [#FFFFFFWIN#00FF00]#FFFFFF" .. getPlayerName( alivePlayers[1] ) .. " #FFFFFFwins this map!", root, 255, 255, 255, true ) 
        end 
    end 
end 
addEvent( 'onPlayerRaceWasted',true ) 
addEventHandler( "onPlayerRaceWasted", root,DestructionWin ) 

There is a problem , that player with state "waiting" can win ;/

Edited by Guest
Link to comment

Please take note! It is not that hard to understand. I only added a few characters.

function DestructionWin( vehicle ) 
    local alivePlayers = getAlivePlayers( ) 
    if (#alivePlayers == 1) and getElementData(alivePlayers[1], 'state') ~= 'waiting' then 
        if isElement( alivePlayers[1] ) then 
            local account = getPlayerAccount( alivePlayers[1] ) 
            if isGuestAccount( account ) then return end 
                local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM")) 
                savePlayerData(thePlayer,"mapsWonDM", mapsWonDM+1) 
            outputChatBox ( "#00FF00* [#FFFFFFWIN#00FF00]#FFFFFF" .. getPlayerName( alivePlayers[1] ) .. " #FFFFFFwins this map!", root, 255, 255, 255, true ) 
        end 
    end 
end 
addEvent( 'onPlayerRaceWasted',true ) 
addEventHandler( "onPlayerRaceWasted", root,DestructionWin ) 

Link to comment
function DestructionWin( vehicle ) 
    local alivePlayers = getAlivePlayers( ) 
    if (#alivePlayers == 1) and getElementData(alivePlayers[1], 'state') ~= 'waiting' then 
        thePlayer = alivePlayers[1] 
        if isElement( thePlayer ) then 
            local account = getPlayerAccount( thePlayer ) 
            if isGuestAccount( account ) then return end 
                local mapsWonDM = tonumber(loadPlayerData(thePlayer,"mapsWonDM")) 
                savePlayerData(thePlayer,"mapsWonDM", mapsWonDM+1) 
            outputChatBox ( "#00FF00* [#FFFFFFWIN#00FF00]#FFFFFF" .. getPlayerName( thePlayer ) .. " #FFFFFFwins this map!", root, 255, 255, 255, true ) 
        end 
    end 
end 
addEvent( 'onPlayerRaceWasted',true ) 
addEventHandler( "onPlayerRaceWasted", root,DestructionWin ) 

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