Sending player to spec

Post your scripting questions / solutions here

Moderator: Moderators

sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Sending player to spec

Post by sdlall »

Is it possible and without giving to much away at beginning of this post how would I go about sending people to spec once they have reached their 60 kill limit for the map.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

sdlall wrote:Is it possible and without giving to much away at beginning of this post ....
It's very hard to detect kills accurately. I managed to do this but I don't like to share this information unless you can tell me what you're trying to do with it :)...

However the spectator thing is very possible.

Code: Select all

local.player spectator
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.
HeavenBound
Colour Sergeant
Posts: 85
Joined: Thu Sep 11, 2008 12:55 am

Post by HeavenBound »

He's trying to do this:

When a player reaches 60 kills, the server asks they wait in spec til the round is over.

Some players aren't fond of the rule (tough crap) so don't obey it. He wants a mod that does it for them. =)
HeavenBound

I'm new at this :)
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

Yeap excatly what I am trying to do as HeavenBound explained. I run serverwatch which can detect when player gets ahead by so many kills but does not detect a stopping point. If that makes any sense. I am wondering if it is possible and what route I should take to conquer this script. Maybe just little insight, SOR into your magic script book.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Ah, don't get me started. Too late!

Foresight, serverwatch, autokick... it's all ineffective crap. DMW? After 4 hours that piece of crap still didn't scan all players on the server (stranded at number 5 lol). MAM? Impressive scripting but it's just pointless.

I never use any of these. Players can cheat all they want on my server. Fine by me, they add a new challenge. However I don't tollerate spawnkilling at all for some reason!

Okay, so I'll share it with you all, I made a standalone script a long time ago.
Just execute this and check the player's kills by his new property: .killcount. You can also detect his deaths with: .deathcount.

EDITED:

Code: Select all

//=============================================
//
// KILLED and DEATH logic for multiplayer
//
// --------------------------------------------------
// How to access player kill and death count:
//
//	The player variable: .killcount for kills
//	The player variable: .deathcount for deaths
//
// Do not change any of the following player variables:
//	- killcount
//	- deathcount
//	- detect
//
// --------------------------------------------------
// Use: Put this before waittill spawn in your mapscript
//
//	exec global/killed_player.scr
//
// --------------------------------------------------
// This script unfortunately cannot detect if a player fell to his doom
// or if he has been killed by a script.
//
// =============================================
//
main:

	level waittill spawn 

	thread mark_live
	waitframe
	thread kill_handler

end

/**************************
 Mark Live Players
 ------------------
 This thread marks all living players 
 with .status = "alive" and all dead/non-playing
 players with .status = "notalive"
*/
mark_live:

	while (1)
	{
		for (local.i = 1; local.i <= $player.size; local.i++)
		{
			if ( (isAlive $player[local.i]) && $player[local.i].dmteam != "spectator")
			{
				$player[local.i] weaponcommand dual targetname ("w" + $player[local.i].entnum)
				local.weapon = $("w" + $player[local.i].entnum )

				if(local.weapon != NULL)
				{
					local.weapon targetname ""
					$player[local.i].status = "alive"
				}
				else
				{
					$player[local.i].status = "notalive"
				}
			}
			else
			{
				$player[local.i].status = "notalive"
			}
		}
		
		wait 0.1
	}

end

kill_handler:

	while(1)
	{
		if ($player.size > 0)
		{
			for (local.i = 1; local.i <= $player.size; local.i++)
			{
				if ($player[local.i].detect == NIL || $player[local.i].detect == NULL)
				{
					if ($player[local.i].status == "alive")
					{
						$player[local.i] waitthread setup_kill
					}
				}
			}
		}

		wait 0.5
	}

end

//Based on giffe's death detection
setup_kill:

	if(self.detect != NIL && self.detect != NULL)
	{
		self.detect remove
	}

	self.detect = spawn trigger_multipleall "spawnflags" "128"
	self.detect.origin = self.origin
	self.detect.angle = self.angle
	self.detect setthread killed
	self.detect glue self
	self.detect.player = self
	self.detect.team = self.dmteam
	self.detect.alive = 1
	self.detect.attacker = NIL	
	self.detect setsize ( -17 -17 0 ) ( 17 17 92 )

end

killed:

	//self waittill trigger	//causes inaccuracy

	local.murderer = parm.other

	//check if player is still on the server or on the same team
	if (self.player == NIL || self.player == NULL)
	{
		self remove
		end
	}

	if ( self.alive == 0 || self.player.dmteam == "spectator")
	{
		end
	}


	//MAIN KILL-HANDLER
	if ( isAlive self.player != 1 && self.alive == 1 )
	{	
		self nottriggerable
		self.alive = 0
		self.attacker = local.murderer
		waitframe
		
		//benzin barrel
		if (local.murderer == NULL) 
		{
			if (self.player.deathcount == NIL)
				self.player.deathcount = 0
			
			self.player.deathcount++
			end
		}
		//committed suicide or teamkill
		if ( local.murderer == self.player || local.murderer.dmteam == self.player.dmteam )
		{
			if ( local.murderer.killcount == NIL )
			{
				local.murderer.killcount = 0
				local.murderer.killcount--
			}
			else if ( local.murderer.killcount != NIL )
			{
				local.murderer.killcount--
			}
		}
		//no traitor
		else if ( local.murderer.dmteam != self.player.dmteam )
		{
			if ( local.murderer.killcount == NIL )
			{
				local.murderer.killcount = 0
				local.murderer.killcount++
			}
			else if ( local.murderer.killcount != NIL )
			{
				local.murderer.killcount++
			}
		}

		if (self.player.deathcount == NIL)
			self.player.deathcount = 0

		self.player.deathcount++
		self immediateremove
	}

end
Hm, my live detection is also in there... If you ever need to be sure a player is playing in your scripting, execute the mark_live thread and check for .status == "alive".
Last edited by $oldier Of Ra on Tue Apr 21, 2009 9:14 pm, edited 6 times in total.
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.
HeavenBound
Colour Sergeant
Posts: 85
Joined: Thu Sep 11, 2008 12:55 am

Post by HeavenBound »

Yay Sor!! lol
HeavenBound

I'm new at this :)
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

Yes they are ineffective. Only you use serverwatch because of the stats and also little bit more player interactive but has ALOT of flaws in it. C.I. use just for the pk3. Anyways, you have given me alot to look over and probrably take day or so to take it all in.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Ah, you're trying to understand the script. Something worth knowing then is this: a trigger with spawnflags 128 detects explosions and player bullets.
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.
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

Fairly new at all this so was wanting to get idea on how to setup that. Since you showed me now trying to pick it apart and understand it so that I can try to write the part where once a player reachs 60 puts them in spec. for the rest of the time on that map until the next map starts. But guess would work to if they reached 60 and it put them in spec with a message and if they came out and killed someone then it would just do it all over again. I think even that would deter someone from keep coming out until next map start.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Well you don't have to, just put it in a new script and execute it (from dmprecache, mapscript...). All you then have to do is continuously check if a playe has got 60 kills or more ( .killcount property) and send them to spectator.
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.
Aprop
Major
Posts: 291
Joined: Mon Nov 17, 2008 3:40 pm

Post by Aprop »

Intresting script... but player can reconnect to server and reset killcounter?
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 »

Aprop, a reconnect resets their in-game stats anyway.
Admin
Image
Image
Honour guide me.

here's my stuff - inequation.org | here's where I work - thefarm51.com
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

I changed a few small things in the kill-detection script I posted above, I suggest you overwrite the one you have with the new one. It seemed this standalone version wasn't really up-to-date with the one I'm using in my spawn detection.
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.
sdlall
Sergeant Major
Posts: 110
Joined: Tue Mar 24, 2009 11:41 pm

Post by sdlall »

Looking over the changed one now and reading reference guide for the millionth time. I appreciate at all the time you have put into this posting and just about ready to call this post dead. I think I am over my head in local ++ < threads { and etc. The only thing I am sure of is that your script was the hard part and what I should be writing is simple and probably not as long but just having no luck in even starting on it. Going to keep trying for now or for at least 1 ++ day.

is the local.i the client number if not what does that stand for
Last edited by sdlall on Tue Apr 21, 2009 9:38 pm, edited 1 time in total.
$oldier Of Ra
Lieutenant Colonel
Posts: 404
Joined: Sun Oct 16, 2005 7:16 pm
Location: Belgium
Contact:

Post by $oldier Of Ra »

Then it seems to me that you don't know how for statements work nor what arrays are if you're way over your head about that :)

You should do something like this:

Code: Select all

spec_kick:

        exec global/killed_player.scr //my script
      
        level waittill spawn

        while(1)
        {
               for (local.i = 1; local.i <= $player.size; local.i++)
               {
                       if ($player[local.i].killcount != NIL && $player[local.i].dmteam != "spectator" && $player[local.i].killcount >= 60)
                       {
                                 $player[local.i] iprint "You have killed enough players for this match!" 1
                                 $player[local.i] spectator
                                 wait 0.3
                       }
                 }
 
               wait 1.5
          }

end
Well, the script wasn't hard, just finding the method to count kills (and deaths) as accurately as possible was harder. As you can read in the script, I based myself on GiffE's death logic script.
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.
Post Reply