Jump to content

[HELP] Wrong text


LabiVila

Recommended Posts

Posted
        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

Posted

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

Posted

It won't be very useful as you can't determine the time the player dies. Is there any other way I can do it? I can erase the whole script if needed

Posted

i said add a little delay, add a little delay before you check how many players are alive, because as you know, after the player is wasted, it takes him a few seconds before he actually dies, his body remains on the ground, so add a little delay.

Posted

Try change check for first player alive to: #all == 0

and for second player alive to: #all == 1

If I understand the function correctly, it should work. :)

Posted

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.

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