(SOLVED) How to force map to automatically change

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

(SOLVED) How to force map to automatically change

Post by Broadus »

In my co-op mod, all of the players are supposed to be on the same team. When the players beat the level, I call in "teamwin allies" and the Allies win.
The problem is, they won't consider it a successful round unless there was (or is?) a player on the Axis team. So instead of going to the next map, it just restarts the current one.
Is there a way I can force the server to change maps? Like, is there a global script I can edit, or a script I can put into the map that would make it change?
Last edited by Broadus on Sun Dec 28, 2008 6:25 pm, edited 1 time in total.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Code: Select all

bsptransition( String next_map )


Transitions to the next BSP. Keeps player data, and game data.

Code: Select all

map( String map_name )


Starts the specified map.
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

Are these scripts I put into the map?
I wrote them like this:

Code: Select all

bsptransition(m1l2a)

Code: Select all

map(m1l2a)
And nothing happened with either of them.
Last edited by Broadus on Fri Dec 19, 2008 4:59 am, edited 2 times in total.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

What else did you try did you try

bsptransition(maps/m1l2a)

What thread did you put that in ?
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

Are you sure bsptransition works? Especially in multiplayer. I'm scripting for online multiplayer.

If I could somehow force a console command in the map script, then I could just use the console command "map ??????". I don't want to make the player, or the host, have to do the console commands manually.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

In mission m1l2a when they want to go to the next mission they use this line

Code: Select all

exec global/missioncomplete.scr m1l2b 1
global/missioncomplete.scr

Code: Select all

main local.nextlevel local.bsp:
	if ($player.health <= 0)
		pause

	$player stopwatch 0	
	if (local.nextlevel != NIL)
	{
		if (local.bsp != NIL)
		{
			game.loadout = false
			bsptransition local.nextlevel
		}
		else
		{
			game.loadout = NIL
			leveltransition local.nextlevel
		}
	}

end
of course you can't use that as is . I don't know the difference between bsptransition and leveltransition they seem the same .
Last edited by bdbodger on Fri Dec 19, 2008 5:17 am, edited 1 time in total.
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

That line doesn't work in multiplayer.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

if you can enter map ??? in the console you should be able to use it in script the same way . Are you useing the Allieswin still ? I would say don't if you are .
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

Unfortunately, trying to use console commands as scripts, as in just typing:

Code: Select all

map m1l2b
into a thread doesn't work.
Image
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

I see OK
Image
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

So does anyone have any idea how to solve my problem in the first post?
Image
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Read my last post:

/forum/viewtopic.php?t=13355

Cheers ;)
Our official website: http://www.mohaairborne.co.cc
(Still accessible through http://mohaaclantb.tk and http://users.skynet.be/mohaaclantb/)

For all your bot needs!!!!

$oldier Of Ra.
Rookie One.pl
Site Admin
Posts: 2752
Joined: Fri Jan 31, 2003 7:49 pm
Location: Nowa Wies Tworoska, Poland
Contact:

Post by Rookie One.pl »

I had this method of forcing map changes and restarts by faking a vote. Off the top of my head:

Code: Select all

// allow votes
setcvar "g_allowVote" "1"
// cancel any votes that may be in progress
for (local.i = 1; local.i <= $player.size; local.i++)
   $player[local.i] vote no
// use any player to call the map switch vote
$player[1] callvote map "yournextmap"
// force vote passing
for (local.i = 1; local.i <= $player.size; local.i++)
   $player[local.i] vote yes
// map change should occur halfway through the above loop
Now that this code snippet doesn't take 3 things into account:
1) there might be no players in the server (but, on the other hand, how would they win, then?)
2) I'm not sure how connecting (i.e. map loading) players are seen by the game; anyway, you need a player who's got the map loaded and is in game at least as a spectator to call the vote
3) this overrides the admin's setting of g_allowVote cvar; one way to overcome this would be to save off its value just before faking the vote in a game object variable:

Code: Select all

game.allow_vote = getcvar("g_allowVote")
and restore it at the next map's start:

Code: Select all

setcvar "g_allowVote" game.allow_vote
However, you'd need to put that code in every map script. I don't think it's very important, though, I've always considered admins who thought disabling votes would decrease abuse are morons. :P
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
Broadus
Captain
Posts: 235
Joined: Mon Jan 30, 2006 5:35 am

Post by Broadus »

Well, now this problem has been solved in a different topic.
But, a voting system might be good to have in case of emergencies, like all the players get stuck or something... Hopefully I won't have any such emergencies, but I guess they're inevitable.
Image
Post Reply