h4x7o0r Posted December 28, 2012 Share Posted December 28, 2012 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. Link to comment
manve1 Posted December 28, 2012 Share Posted December 28, 2012 there is a race gamemode on community made which has a separate script inside of it which does this. (( Sorry i forgot how it was named )) Link to comment
h4x7o0r Posted December 28, 2012 Author Share Posted December 28, 2012 thanks for reply, would have been awesome if i can find that gamemode on community, i've searched now but no result. Link to comment
manve1 Posted December 28, 2012 Share Posted December 28, 2012 i think its something like: alternative gamemode not sure sorry bro Link to comment
h4x7o0r Posted December 28, 2012 Author Share Posted December 28, 2012 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. Link to comment
SpUnKyMe Posted December 29, 2012 Share Posted December 29, 2012 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. Link to comment
h4x7o0r Posted December 29, 2012 Author Share Posted December 29, 2012 (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 December 29, 2012 by Guest Link to comment
Anderl Posted December 29, 2012 Share Posted December 29, 2012 In Lua you don't use "&&" as AND operator, you use "and". Link to comment
h4x7o0r Posted December 29, 2012 Author Share Posted December 29, 2012 And about the code ? Link to comment
Anderl Posted December 29, 2012 Share Posted December 29, 2012 The code is right. I guess to kill the player you can use whichever you want in race gamemode. Link to comment
h4x7o0r Posted December 30, 2012 Author Share Posted December 30, 2012 -- 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. Link to comment
Anderl Posted December 30, 2012 Share Posted December 30, 2012 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. Link to comment
h4x7o0r Posted December 30, 2012 Author Share Posted December 30, 2012 (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 December 30, 2012 by Guest Link to comment
Anderl Posted December 30, 2012 Share Posted December 30, 2012 I still don't get where are you getting "sourcePlayer" and "player" variables from, where do you declare them? Link to comment
h4x7o0r Posted December 30, 2012 Author Share Posted December 30, 2012 I have changed it a little bit. As I know sourcePlayer it's predefined . Link to comment
xTravax Posted December 30, 2012 Share Posted December 30, 2012 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 Link to comment
SpUnKyMe Posted December 30, 2012 Share Posted December 30, 2012 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) Link to comment
h4x7o0r Posted December 31, 2012 Author Share Posted December 31, 2012 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) Link to comment
Anderl Posted December 31, 2012 Share Posted December 31, 2012 Call "getActivePlayers" function to get active players. Link to comment
h4x7o0r Posted January 1, 2013 Author Share Posted January 1, 2013 Looks like also the first part of script doesn't work Link to comment
h4x7o0r Posted January 4, 2013 Author Share Posted January 4, 2013 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now