Getting DMTeam

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Getting DMTeam

Post by MPowell1944 »

Ok. I am trying to figure out a script for a mod that I am modifying. This is to prevent teamkilling.

Portable Mines. You pick them up from a central spot, and plant them. When you pick it up, I want the script to get your DMteam, and when a person steps on the mine that you've planted, if you both are on the same team, it doesnt hurt the person. Only blows up if other team steps on it. Right now, it kills anyone.

How would I go about getting a DMteam of the person who uses the trigger, then compare it to the person who steps on the mine that is placed?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Would be easier if you showed us some of your script, but I suppose just setting a variable like $mymine.attacker for the mine when it's being placed and then checking it at boom-time would do it :)
Image
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post by MPowell1944 »

Here is the code for the Grabbing of the mine. Here you can see I did a teamcheck so I could add light to the mines so it would tell which team set them. I am assuming a similar method is used for the problem I am having.

Code: Select all

bomb_place:
	local.player = parm.other

	local.set = 0
	while(local.player.useheld == 1)
	{	
		local.count = getcvar "Elgan_mines" 
		local.count = int local.count

		if (local.player.mines==local.count)
		{
//			local.player iprint "You need to find a mine first"	
			end
		}
			wait 1
			local.set++
			if(local.set ==3)
			{
				if(level.can==0)
				{
				end
				}

				level.can = 0
				level.num++
				local.player.mines++

//				local.player waitthread global/items.scr::remove_item "explosive"

				if(local.player.dmteam == "axis")
				{
				local.mine = spawn script_model "targetname" ("mine" + level.num)
				local.mine model "items/explosive.tik"
				local.mine.origin = local.player.origin
				local.mine notsolid
				local.mine light 100 0 0 64
				local.mine setthread mine
				}
				else
				{
				local.mine = spawn script_model "targetname" ("mine" + level.num)
				local.mine model "items/explosive.tik"
				local.mine.origin = local.player.origin
				local.mine notsolid
				local.mine light 0 0 100 64
				local.mine setthread mine
				}
				local.mine_trig = spawn trigger_multiple "targetname" ("mine_trig" + level.num)
				local.mine_trig setsize ( -20 -20 -20 ) ( 20 20 20 )
				local.mine_trig.origin = local.player.origin
				local.mine_trig setthread mine
				local.mine_trig nottriggerable
				local.player playsound plantbomb1
				local.mine_shoot = spawn trigger_multiple "spawnflags" "128" "health" "999999" "targetname" ("mineshot" + level.num)
				local.mine_shoot setsize ( -20 -20 -20 ) ( 20 20 20 )
				local.mine_shoot.origin = local.player.origin
				local.mine_shoot setthread mine_shot

				$("mineshot" + level.num) glue $("mine" + level.num)
				$("mine_trig" + level.num) glue $("mine" + level.num)
				
				local.bottom_spot = local.player.origin  - ( 0 0 10000 )
				local.spot = trace local.player.origin local.bottom_spot 0 

				$("mine" + level.num) moveto local.spot
				$("mine" + level.num) speed 999	
				$("mine" + level.num) move

				local.set = 0
//				local.player iprint "You have 5 seconds to get out the way"
				iprintln self.targetname
//				wait 5
				local.player iprint "Mine Active"
				wait 2
				local.mine_trig triggerable
				level.can = 1
				level.num1 = level.num
			}
		
	}

end
And here is the code for the stepping on the mine

Code: Select all

mine:

local.newnum = level.num
local.newnum = local.newnum - level.take

local.player=parm.other

local.Exp1 = spawn "fx/scriptbazookaexplosion.tik"
local.Exp2 = spawn "animate/fx_mortar_dirt.tik"

local.Exp1.origin = local.player.origin // $("bomb" + local.player).origin
local.Exp1 anim start
local.Exp2.origin = local.player.origin //$("bomb" + local.player).origin
local.Exp2 anim start
wait 1
local.Exp1 remove
local.Exp2 remove

for (local.t=0; local.t <= level.num + 1; local.t++)
{
	if(self istouching  $("mine" + local.t)){
		$("mine" + local.t) remove
	}
wait .1
}

self remove

end
I have tried checking the team and setvar after mine: but when I do that, mod doesnt work at all for some reason.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Well in the mine placing code add s/th like this:

Where you have this:

Code: Select all

 local.mine model "items/explosive.tik"
            local.mine.origin = local.player.origin
            local.mine notsolid
            local.mine light 100 0 0 64
            local.mine setthread mine 
Add:

Code: Select all

// might want to use it to give planter kills
local.mine.planter = local.player
// also simply get team b/c planter could switch teams
local.mine.planter_team = local.player.dmteam
And in the explosion code add (below local.player = parm.other):

Code: Select all

if(local.player.dmteam == self.planter_team)
  end
Image
User avatar
MPowell1944
Moderator
Posts: 287
Joined: Thu Jan 09, 2003 7:06 am
Location: Woodstock, GA
Contact:

Post by MPowell1944 »

Ok I got it to work. However, will the mine still kill the person who places it?
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

few,right

after 5 hours of debugging i read this thread again and realised self.planter_team is not the mine, its the trigger!!!!!!!

Code: Select all


mine:

local.newnum = level.num
local.newnum = local.newnum - level.take

local.player=parm.other


for (local.t=0; local.t <= level.num + 1; local.t++)
{
	if(self istouching  $("mine" + local.t))
	{
		if(local.player.dmteam == $("mine" + local.t).planter_team)
		{
  			end
		}	
		$("mine" + local.t) remove
	}
wait .1
}

waitthread explode parm.other self.origin self

self remove

end
now im going to bed:)
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

lol yah true :oops: nice find Elgan :)
Image
Elgan
Site Admin
Posts: 890
Joined: Tue Apr 13, 2004 10:43 pm
Location: uk
Contact:

Post by Elgan »

hehe luckily doin so i managed to remove alot of silly code and make it alot better. wonder if i made them silly code in the other mines scripts and sticky bombs:S
Post Reply