EvoGT Posted March 24, 2013 Share Posted March 24, 2013 Can you help me to make script when player last player alives , he wins ! i have to use this : setElementData(thePlayer,"Wins",tonumber(getElementData(thePlayer,"Wins"))+1) Script: 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 setElementData(thePlayer,"Wins",tonumber(getElementData(thePlayer,"Wins"))+1) outputChatBox ( "#FFA824The player " .. getPlayerName( alivePlayers[1] ) .. " won!", root, 255, 255, 255, true ) end What is wrong here ? Link to comment
Castillo Posted March 24, 2013 Share Posted March 24, 2013 How do you execute: "DestructionWin" function? Link to comment
EvoGT Posted March 24, 2013 Author Share Posted March 24, 2013 How do you execute: "DestructionWin" function? addEvent( 'onPlayerRaceWasted',true ) ... addEventHandler( "onPlayerRaceWasted", root,DestructionWin ) Link to comment
Castillo Posted March 24, 2013 Share Posted March 24, 2013 Well, your first problem is that you are using "thePlayer" in that script, instead of alivePlayers [ 1 ]. You can try with this: function DestructionWin ( ) local account = getPlayerAccount ( source ) if isGuestAccount( account ) then return end local wins = tonumber ( getElementData ( source, "Wins" ) ) or 0 setElementData ( source, "Wins", ( wins + 1 ) ) outputChatBox ( "#FFA824The player ".. getPlayerName ( source ) .." won!", root, 255, 255, 255, true ) end addEvent ( "onPlayerWinDD", true ) addEventHandler ( "onPlayerWinDD", root, DestructionWin ) Link to comment
EvoGT Posted March 24, 2013 Author Share Posted March 24, 2013 Solid look what i am trying to do this is from mtasa resources. function onPlayerDeadInRace() local thePlayer = source local dPlayers = getDeadRacePlayers() local aPlayers = getAliveRacePlayers() local Position = aPlayers + 1 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 ("#abcdef* [WIN] 1st! You got #FFFFFF" .. pointsForPlayer .." #FFFFFFpoints #abcdefand #FFFFFF" .. cashForPlayer .."$",thePlayer,255,255,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 ("#abcdef* [PRIZE] You got #FFFFFF" .. pointsForPlayer .." #FFFFFFpoints #abcdefand #FFFFFF" .. cashForPlayer .."$",thePlayer,255,255,255,true) setElementData(thePlayer,"Deaths",tonumber(getElementData(thePlayer,"Deaths"))+1) end else outputChatBox("#8bbae9* Minimum 2 players to get stats and cash!",thePlayer,255,255,255,true) end end This scripts bugs. That why i am trying to remake wins script with this: And this setElementData(thePlayer,"Wins",tonumber(getElementData(thePlayer,"Wins"))+1) and this if (#alivePlayers == 1) then help pls Link to comment
EvoGT Posted March 24, 2013 Author Share Posted March 24, 2013 The way of if Position == 1 then is buggy. I need to change it with if (#alivePlayers == 1) then Link to comment
X-SHADOW Posted March 24, 2013 Share Posted March 24, 2013 in the second script thePlayer isn't defined . Link to comment
EvoGT Posted March 24, 2013 Author Share Posted March 24, 2013 I know I tryed to make something.. But i need to change from if Position == 1 then to if (#alivePlayers == 1) then Link to comment
EvoGT Posted March 24, 2013 Author Share Posted March 24, 2013 Soo. How can i make it with this if (#alivePlayers == 1) then But including setElementData(thePlayer,"Wins",tonumber(getElementData(thePlayer,"Wins"))+1) pls help. Link to comment
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