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?
Getting DMTeam
Moderator: Moderators
- MPowell1944
- Moderator
- Posts: 287
- Joined: Thu Jan 09, 2003 7:06 am
- Location: Woodstock, GA
- Contact:
- MPowell1944
- Moderator
- Posts: 287
- Joined: Thu Jan 09, 2003 7:06 am
- Location: Woodstock, GA
- Contact:
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.
And here is the code for the stepping on the mine
I have tried checking the team and setvar after mine: but when I do that, mod doesnt work at all for some reason.
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
}
}
endCode: 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
endWell in the mine placing code add s/th like this:
Where you have this:
Add:
And in the explosion code add (below local.player = parm.other):
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 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
Code: Select all
if(local.player.dmteam == self.planter_team)
end
- MPowell1944
- Moderator
- Posts: 287
- Joined: Thu Jan 09, 2003 7:06 am
- Location: Woodstock, GA
- Contact:
few,right
after 5 hours of debugging i read this thread again and realised self.planter_team is not the mine, its the trigger!!!!!!!
now im going to bed:)
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
