Jump to content

Wins script


EvoGT

Recommended Posts

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

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

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

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