Jump to content

Dm votemanager


h4x7o0r

Recommended Posts

Posted

Hey guys,

I'm having a DM server and i wanna change a lil bit how votemanager's acting. For example, DM maps obviously are finished when at last one player is taking the Hunter and then kill others alive. The problem is that it's kinda impossible for some1 skilled to finish the map because others are failing before reaching the hunter. So is there any command / resource on community to modify this votemap to appear just only last player alive take the hunter or so ?

Sincerly i've search for a related topic but couldn't fine anything useful at all.

Thanks in advance.

Posted

Thank you so much for your help, i've found this :https://community.multitheftauto.com/index.php?p=resources&s=details&id=5530

But when u download the resource, there's a link to download and there u must pay some money. I don't trust those things and also, i think it's kinda denied to upload it that way. who knows. anyways I will still searching for.

Posted

Mkay, open up race/modes/destructionderby.lua

find in function DestructionDerby:onPlayerWasted(player)

if getActivePlayerCount() <= 1 then 

replace it with

if getActivePlayerCount() <= 0 then 

So it should look like this

function DestructionDerby:onPlayerWasted(player) 
    if isActivePlayer(player) then 
        self:handleFinishActivePlayer(player) 
        if getActivePlayerCount() <= 0 then 
            RaceMode.endMap() 
        else 
            TimerManager.createTimerFor("map",player):setTimer(clientCall, 2000, 1, player, 'Spectate.start', 'auto') 
        end 
    end 
    RaceMode.setPlayerIsFinished(player) 
    showBlipsAttachedTo(player, false) 
end 

About this hunter thingy you could check if player is the only one playing and as soon as he gets hunter simply kill him and map will end.

Posted (edited)

thank you very much for your solution, it's working very well (i've used kinda different this)

  
    if getActivePlayerCount() < 1 then 
  

also as u suggested i should kill the last player who takes the hunter so i decided to use it this way :

  
    -- Update ranking board if one player left 
    local activePlayers = getActivePlayers() 
    if #activePlayers == 1 then 
        self.rankingBoard:add(activePlayers[1], timePassed) 
        showMessage(getPlayerName(activePlayers[1]) .. ' is the final survivor!', 0, 255, 0) 
        triggerEvent( "onPlayerWinDD",activePlayers[1] ) 
    end 
        --------- 
        if ( tonumber(getElementModel(veh)) == 425 ) and ( #activePlayers == 1) then  
          
  
       end 
  

I don't know if this is the right way, and also to kill him should I use setElementHealth or other ?

Thanks for all your help guys.

LE. i've modified "and" tnx

Edited by Guest
Posted

In Lua you don't use "&&" as AND operator, you use "and".

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

The code is right. I guess to kill the player you can use whichever you want in race gamemode.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted
  
    -- Update ranking board if one player left 
    local activePlayers = getActivePlayers() 
    if #activePlayers == 1 then 
        self.rankingBoard:add(activePlayers[1], timePassed) 
        showMessage(getPlayerName(activePlayers[1]) .. ' is the final survivor!', 0, 255, 0) 
        triggerEvent( "onPlayerWinDD",activePlayers[1] ) 
    end 
        --  
        local targetPlayer = getPlayerFromName ( targetPlayerName ) 
        if ( tonumber(getElementModel(veh)) == 425 ) and ( #activePlayers == 1) then 
            if targetPlayer then 
                   setElementHealth ( targetPlayer, getElementHealth(targetPlayer) - 110 ) 
            end 
        end 
  

I don't know if it's correct.

Posted

Is "veh" and "targetPlayerName" declared?

By the way, you don't need to do all that thing on setElementHealth, simply set player's health to 0.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted (edited)
  
    -- Update ranking board if one player left 
    local activePlayers = getActivePlayers() 
    if #activePlayers == 1 then 
        self.rankingBoard:add(activePlayers[1], timePassed) 
        showMessage(getPlayerName(activePlayers[1]) .. ' is the final survivor!', 0, 255, 0) 
        triggerEvent( "onPlayerWinDD",activePlayers[1] ) 
    end 
        -- 
        local targetPlayer = getPlayerFromName (sourcePlayer ) 
        local veh = getPedOccupiedVehicle(targetPlayer) 
         
        if ( tonumber(getElementModel(veh)) == 425 ) and ( #activePlayers == 1) then 
            if targetPlayer then 
                   setElementHealth ( targetPlayer, getElementHealth(targetPlayer) - 110 ) 
            end 
        end 
  

How about now ?

Edited by Guest
Posted

I still don't get where are you getting "sourcePlayer" and "player" variables from, where do you declare them?

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

i dont understand scripting but i think in this script should be something like killPlayer

for when player gets hunter or atleast when player gets hunter script put him 0 hp

Posted

This one will end the map if last player has already hunter

    -- Update ranking board if one player left 
local activePlayers = getActivePlayers() 
if #activePlayers == 1 then 
    self.rankingBoard:add(activePlayers[1], timePassed) 
    showMessage(getPlayerName(activePlayers[1]) .. ' is the final survivor!', 0, 255, 0) 
    triggerEvent( "onPlayerWinDD",activePlayers[1] ) 
    if (getElementModel(getPedOccupiedVehicle(activePlayers[1])) == 425) then 
        RaceMode.endMap() 
    end 
end 

And this one will end the map when last player gets hunter

(add it end of the file)

addEventHandler("onElementModelChange",root, 
function(old,new) 
    if (getElementType(source) == "vehicle") then 
            if #activePlayers <= 1 then 
                if (new == 425) then 
                    RaceMode.endMap() 
                end 
            end 
    end 
end) 

Posted

Thank you for all your help, i will try this asap. All the best.

LE: line.119 : Attempt to get length of global 'activeplayers' (a nil value)

Posted

Call "getActivePlayers" function to get active players.

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

Anyone who can help me? (It's not working not even first part, when last player alive is taking the hunter nothing happens. At the 2nd script it's shows me that error and idk how to call getActivePlayers.

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