EvoGT Posted March 25, 2013 Posted March 25, 2013 (edited) 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 March 25, 2013 by Guest
EvoGT Posted March 25, 2013 Author Posted March 25, 2013 Maybe this local isNew = getElementData (getLocalPlayer(), "state") if isNew == "waiting" How to make that player with state "waiting" cant win.
codeluaeveryday Posted March 25, 2013 Posted March 25, 2013 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 )
EvoGT Posted March 25, 2013 Author Posted March 25, 2013 Sometimes it Writes My name, that i win. But win gets other player . Where could the problem be ?
codeluaeveryday Posted March 25, 2013 Posted March 25, 2013 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 )
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now