Jump to content

Change map problem


Recommended Posts

Hi everyone. Well i was editing my race server

By default the race script when are the last player alive the map change or start the votemanager

But i want when all are deads and the last player still playing to make toptime

I dont know if im explaain

First im edited the destructionderby.lua and i make the change of rank.

Now all is good but i want, when the last player get hunter change map and i did this

and i dont have errors. if someone can helmpe

function testsource(number, sort, model) 
        local alivePlayers = getAlivePlayers() 
  
    if (#alivePlayers == 1) then 
    if sort == "vehiclechange" and model == 425 then 
        executeCommandHandler ( "random", #activePlayers ) -- i think here is the problem, executecommand arguments 
    end 
end 
end 
addEvent("onPlayerPickUpRacePickup",true) 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),testsource) 
addEventHandler("onPostFinish", rootElement, testsource ) 

the script have admins rights to executeCommandHandler

thanks for your time

Link to comment

yes that was my problem, any way forgoting the first code

im edited destructionderby.lua

im try to explain better

In the race gamemode, when all die less one player, that player win then the map is finished and start a new map.

But i dont wanna end the map. I want that last player still playing to get hunter and make toptime.

And i edited the destructionderby.lua

in this way

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

and this another

  
function DestructionDerby:onPlayerQuit(player) 
    if isActivePlayer(player) then 
        self:handleFinishActivePlayer(player) 
        if getActivePlayerCount() <= 0 then -- default is 1 
            RaceMode.endMap() 
        end 
    end 
end 
  

well , back to problem, the last player still playing, but i what i want is, when he get the hunter go to nextmap

  
function DestructionDerby:handleFinishActivePlayer(player) 
    -- Update ranking board for player being removed 
    if not self.rankingBoard then 
        self.rankingBoard = RankingBoard:create() 
        self.rankingBoard:setDirection( 'up', getActivePlayerCount() ) 
    end 
    local timePassed = self:getTimePassed() 
    self.rankingBoard:add(player, timePassed) 
    -- Do remove 
    finishActivePlayer(player) 
    -- Update ranking board if one player left 
    local activePlayers = getActivePlayers() 
    if #activePlayers == 1 then 
        self.rankingBoard:add(activePlayers[1], timePassed) 
        showMessage(getPlayerName(activePlayers[1]) .. ' ha sobrevivido!', 151, 151, 151) 
        givePlayerMoney(activePlayers[1],2000) 
    end 
end 
  
function testsource(number, sort, model) 
        local activePlayers = getActivePlayers() 
    if #activePlayers == 1 then 
    if sort == "vehiclechange" and model == 425 then 
            RaceMode.endMap() 
    end 
end 
end 
addEvent("onPlayerPickUpRacePickup",true) 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),testsource) 
addEventHandler("onPostFinish", rootElement, testsource ) 
  

i dont know if you can understandme

Link to comment

sorry for double post but now i have this problem

function planeEnter (thePlayer)  
local vehicle = getPedOccupiedVehicle(thePlayer)  
    local id = getElementModel ( vehicle ) 
    local alivePlayers = getAlivePlayers() 
    if (vehicle) then 
    if id == 425 then 
    if (#alivePlayers == 1) then 
    triggerServerEvent ( "StartMap", getLocalPlayer()) 
end 
end 
end 
end 
addEventHandler("onPostFinish", rootElement, planeEnter ) 

i want check if there are 2 hunters fightin and when one die then can go to nextmap

Link to comment

why you want copy boss system? ;D

try my code, hope you will understand

server-side

Hunters = 0 
onReachedHunter = false 
  
function checkingNow(theGuy) 
    if getElementData(theGuy,"state") == "alive" then 
        if getElementData (theGuy,"onHaveCount") == false then 
            Hunters = Hunters + 1 
            setElementData (theGuy,"onHaveCount",true) 
            onReachedHunter = true 
        end 
    end 
end 
  
function checkForHunters(number,sort,model) 
    if sort == "vehiclechange" then 
        if model == 425 then 
            setTimer(checkingNow,200,1,source) 
        end 
    end 
end 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),checkForHunters) 
  
function checkForOneAlive() 
    local alivePlayers = getAlivePlayers() 
    if getElementData (source,"onHaveCount") == true then 
        Hunters = Hunters - 1 
    end 
    if Hunters == 1 and onReachedHunter == true and #alivePlayers == 1 then 
        triggerEvent ( "StartMap", getRootElement()) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), checkForOneAlive) 
  
addEvent("onMapStarting") 
addEventHandler("onMapStarting", getRootElement(), 
function(mapInfo, mapOptions, gameOptions) 
    Hunters = 0 
    onReachedHunter = false 
    for i,thePlayers in ipairs(getElementsByType("player")) do 
        setElementData(thePlayers, "onHaveCount", false) 
    end 
end 
) 
  

don't steal this code and not publish it as your own

Link to comment
Thanks man. And im not try to copy boss sistem, Just i want the best to my players and they can get toptimes without problems.

edit: the code isnt work. Dont errors in debugscript

try to check onPlayerWasted with outputDebugString

Link to comment
Hunters = 0 
onReachedHunter = false 
  
function checkingNow(theGuy) 
    if getElementData(theGuy,"state") == "alive" then 
        if getElementData (theGuy,"onHaveCount") == false then 
            Hunters = Hunters + 1 
            setElementData (theGuy,"onHaveCount",true) 
            onReachedHunter = true 
        end 
    end 
end 
  
function checkForHunters(number,sort,model) 
    if sort == "vehiclechange" then 
        if model == 425 then 
            setTimer(checkingNow,200,1,source) 
        end 
    end 
end 
addEventHandler("onPlayerPickUpRacePickup",getRootElement(),checkForHunters) 
  
function checkForOneAlive() 
    local alivePlayers = getAlivePlayers() 
    if getElementData (source,"onHaveCount") == true then 
        Hunters = Hunters - 1 
    end 
    if Hunters == 1 and onReachedHunter == true then 
        triggerEvent ( "StartMap", getRootElement()) 
        outputDebugString ('test '..Hunters) 
    end 
end 
addEventHandler("onPlayerWasted", getRootElement(), checkForOneAlive) 
  
addEvent("onMapStarting") 
addEventHandler("onMapStarting", getRootElement(), 
function(mapInfo, mapOptions, gameOptions) 
    Hunters = 0 
    onReachedHunter = false 
    for i,thePlayers in ipairs(getElementsByType("player")) do 
        setElementData(thePlayers, "onHaveCount", false) 
    end 
end 
) 
  

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