Jump to content

[HELP] Wrong text


LabiVila

Recommended Posts

        local all = getAlivePlayers () 
        if (#all == 1) then 
                local player1 = all[1] 
                local p1Account = getPlayerAccount (player1) 
                if p1Account and not isGuestAccount (p1Account) then 
                        local points = points + everyone 
                        outputChatBox ("You got "..points.." points for finishing first.", player1, 255, 255, 255) 
                        setAccountData (p1Account, "DMpoints", getAccountData (p1Account, "DMpoints") + points) 
                else 
                        outputChatBox ("You are not logged in.", player1, 255, 255, 255) 
                end 
        end 
        if (#all == 2) then 
                local player2 = all[2] 
                local p2Account = getPlayerAccount (player2) 
                if p2Account and not isGuestAccount (p2Account) then    
                        local points = points + everyone - 1 
                        outputChatBox ("You got "..points.." points for finishing second.", player2, 255, 255, 255) 
                        setAccountData (p2Account, "DMpoints", getAccountData (p2Account, "DMpoints") + points) 
                else 
                        outputChatBox ("You are not logged in.", player2, 255, 255, 255) 
                end 
        end 

Hey, thanks for taking time. So I recently got stuck in a problem, everything works fine but the outputchatBoxs.

outputChatBox ("You got "..points.." points for finishing second.", player2, 255, 255, 255) 

- this outputs in the wrong time, it outputs when two players are alive, not when second players is dead.

I want it like when player 2 dies, it outputs him the message, not when player 3 dies and two are alive, it outputs a random player between the two alive ones.

Thanks

Link to comment

Yea should've placed the event tho;

addEventHandler ("onPlayerWasted", getRootElement(), who) 

and it's not triggered anyhow. I've also got this;

function onLogin () 
    local account = getPlayerAccount (source) 
    if account then 
        local points = getAccountData (account, "DMpoints") 
        outputChatBox ("Your statistics have been loaded successfully."..points) 
    end 
end 
addEventHandler ("onPlayerLogin", getRootElement(), onLogin) 

it saves the points, nothing else

Link to comment

WAIT, i just got your problem...

You should output that after the second dies,so, here's how it will go:

  
function output (player) 
all = getAlivePlayers() 
if #all == 1 then 
outputChatBox("You won as first",all[1]) 
outputChatBox("You won as second",player) 
end 
end 
addEventHandler("onPlayerWasted",root,output) 
  
  

sorry, but i didn't read your script well earlier.

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