Jump to content

Change map problem


Recommended Posts

Posted

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

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted

I don't really understand what are you trying to do, but the second argument of executeCommandHandler is the player to execute it, but you're filling that argument with the amount of players alive instead.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted

Well, it should end the map if the amount of active players is 1.

Are you sure is returning 1 the function: getActivePlayers?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

yes

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted

U can use this for random map without executeComm

From admin panel.

  
triggerServerEvent ( "StartMap", getLocalPlayer()) 
  

In my map test panel work fine.

Posted

It should work Yakuza, I don't see anything wrong with your code.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

exelent..!! i didnt know about that trigger

thanks Hunterix and Solidskane14 for your time :)

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted

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

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted

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

357ac0078264.jpg

- Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]

Posted

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

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted
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

357ac0078264.jpg

- Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]

Posted

nothing with debug

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted
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 
) 
  

357ac0078264.jpg

- Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]

Posted

dont work, but no problem man.. im gonna make another way

thanks for youur time and cya

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

Posted
exelent..!! i didnt know about that trigger

thanks Hunterix and Solidskane14 for your time :)

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
dont work, but no problem man.. im gonna make another way

thanks for youur time and cya

i can help you tomorrow, tell me in msn or skype

357ac0078264.jpg

- Working on [php/HTML/Mysql/Lua/Java Scripts/Web Design/3D Modeling]

Posted

thanks homie

Actual Nick: [XGN]BorderLine

Actual Clan: XLatino

Actual Status: Staff, Mod Level 1

(BOSS)Yakuza - [vS]Yakuza - [sXE]Yakuza - [uG]Yakuza - [FTLS]Racing - [XGN]Borderline

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