Trigger to take all weapons but 1

Post your scripting questions / solutions here

Moderator: Moderators

Tazz
Second Lieutenant
Posts: 155
Joined: Fri Feb 16, 2007 1:29 pm
Contact:

Trigger to take all weapons but 1

Post by Tazz »

ok thx yall for helping me on last map got it fully completed and testing now.....my next map is stalingrad i want to put triggers in at the boiler room doors all entries to take all ur weapons from u except the pistol making it bash only in there..i know my coords and everything but i dont know how to put in trigger or trigger it to takeall and give one...been searching on here but find things close but not exactly what i need.....thx for any and all help guys
User avatar
erick
Major
Posts: 280
Joined: Wed May 30, 2007 1:14 am
Location: USA

Post by erick »

Here is a tutorial for spawning triggers
http://blazinmohaa.com/adding_triggers_final.htm

To make the player take all but the pistol you would have to go something like this:

$mytrigger waittill trigger

local.player = parm.other

local.player takeall

if (local.player = allied)
local.player item weapons/colt45.tik

else

local.player item weapons/p38.tik

end


I am not sure if this will work (the allied part). You could test it.
Tazz
Second Lieutenant
Posts: 155
Joined: Fri Feb 16, 2007 1:29 pm
Contact:

Post by Tazz »

ok thx alot i got my trigger in place now and it takes all weaopns and it only gives u pistol back but u have to choose pistol from ur bar at bottom it doesnt give it in ur hands...how can i make it put the pistol in ur hands without having to choose weapon.....also i would like to know how to add more triggers in same script i tried a few things and couldnt get it to work....here is what i have so far but i need 2 more triggers at the other doors to the boiler room

Code: Select all

level waittill prespawn

	local.trig = spawn trigger_multiple

	local.trig.origin = (  885 85 -100 )                                 // This is where you place the cords you have.

	local.trig setsize ( -85 -45 -55 ) ( 85 45 55 )                             //The way this works is it defines the box size. (the larger the numbers the larger the area)

//Directions for the size(south east down) (north west up)           I believe these are in inches

	local.trig setthread  Trigger1                                                      //Name of thread.
		
	Trigger1:                                                                                   //This is the name of the thread you defined earlier in setthread.

	self waittill trigger                                                                      //Tells it to wait until the trigger is set off and is something you will never change.

	local.player=parm.other                                                            //Something you will never change.

	if (local.player.isTrigger1==1)                                                   //Change this to the name of the thread, in this case Trigger1.

	
	end                                                                                           //This defines the end of this thread.

 

local.player.isTrigger1=1                                                           //Since we made the player turn on the trigger, this says what to do once it?s turned on.

local.player takeall                                                            // This is where you execute the command. You never change the words ?local.player?.

local.player item weapons/colt45.tik                                                                         // This is where you execute the 2nd command. You never change the words ?local.player?.

local.player.isTrigger1=0                                                           //Again make sure this has the name of the thread above for it to work.

	end
User avatar
erick
Major
Posts: 280
Joined: Wed May 30, 2007 1:14 am
Location: USA

Post by erick »

You actually made that complicated, (something I usually do before I see the easy answer)

Here is your code:

level waittill prespawn

local.trig = spawn trigger_multiple

local.trig.origin = ( 885 85 -100 ) // This is where you place the cords you have.

local.trig setsize ( -85 -45 -55 ) ( 85 45 55 ) //The way this works is it defines the box size. (the larger the numbers the larger the area)

//Directions for the size(south east down) (north west up) I believe these are in inches

local.trig setthread Trigger1 //Name of thread.

Trigger1: //This is the name of the thread you defined earlier in setthread.

self waittill trigger //Tells it to wait until the trigger is set off and is something you will never change.

local.player=parm.other //Something you will never change.

if (local.player.isTrigger1==1) //Change this to the name of the thread, in this case Trigger1.


end //This defines the end of this thread.



local.player.isTrigger1=1 //Since we made the player turn on the trigger, this says what to do once it?s turned on.

local.player takeall // This is where you execute the command. You never change the words ?local.player?.

local.player item weapons/colt45.tik // This is where you execute the 2nd command. You never change the words ?local.player?.

local.player.isTrigger1=0 //Again make sure this has the name of the thread above for it to work.

end


Change it to this to get 2 more triggers:

main:
level waittill prespawn

local.trig = spawn trigger_multiple

local.trig.origin = ( 885 85 -100 ) // This is where you place the cords you have.

local.trig setsize ( -85 -45 -55 ) ( 85 45 55 ) //The way this works is it defines the box size. (the larger the numbers the larger the area)

//Directions for the size(south east down) (north west up) *** These are in world units as in radiant. (16 units = 1 foot)


local.trig setthread Trigger1 //Name of thread.

Trigger1: //This is the name of the thread you defined earlier in setthread.

self waittill trigger //take this out. Trigger1 is the setthread that runs when the trigger is triggered, you dont need to wait for it to be triggered again

local.player=parm.other //Something you will never change.


local.player takeall
local.player item weapons/colt45.tik //ADD all of this
local.player ammo pistol 100
local.player useweaponclass pistol
end


Take all of the green out it isnt needed
if (local.player.isTrigger1==1)
end //This defines the end of this thread.


local.player.isTrigger1=1 //Since we made the player turn on the trigger, this says what to do once it?s turned on.

local.player takeall // This is where you execute the command. You never change the words ?local.player?.

local.player item weapons/colt45.tik // This is where you execute the 2nd command. You never change the words ?local.player?.

local.player.isTrigger1=0 //Again make sure this has the name of the thread above for it to work.

end


And then just add 2 more sections for triggers. Here is the final code with all of the triggers.

Code: Select all

main:
level waittill prespawn

local.trig = spawn trigger_multiple
local.trig.origin = ( 885 85 -100 ) //your coords you had
local.trig setsize ( -85 -45 -55 ) ( 85 45 55 ) 
local.trig setthread Trigger1 

local.trig2 = spawn trigger_multiple
local.trig2.origin = (Put your coord here)
local.trig2 setsize (setsize here)(****)
local.trig2 setthread Trigger2

local.trig3 = spawn trigger_multiple
local.trig3.origin = (Put your coord here)
local.trig3 setsize (setsize here)(*****)
local.trig3 setthread Trigger3


level waittill spawn

Trigger1: 
local.player=parm.other 
local.player takeall
local.player item weapons/colt45.tik 
local.player ammo pistol 100
local.player useweaponclass pistol
end

Trigger2: 
local.player=parm.other 
local.player takeall
local.player item weapons/colt45.tik 
local.player ammo pistol 100
local.player useweaponclass pistol
end

Trigger3: 
local.player=parm.other 
local.player takeall
local.player item weapons/colt45.tik 
local.player ammo pistol 100
local.player useweaponclass pistol
end
There is your code. Tell me if it works and reply back if you need any help
Tazz
Second Lieutenant
Posts: 155
Joined: Fri Feb 16, 2007 1:29 pm
Contact:

Post by Tazz »

thx alot man works perfect now all i have to do is figure out how u got that and how it works lol....thx again man
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Um sorry to be so picky but since all the trigger threads are exactly the same word for word why not just use the setthread to use the same thread for all of the triggers it is a lot less writing that way . Also I think you missed an end at the end of the main thread and before the trigger threads .

Code: Select all

main:
level waittill prespawn

local.trig = spawn trigger_multiple
local.trig.origin = ( 885 85 -100 ) //your coords you had
local.trig setsize ( -85 -45 -55 ) ( 85 45 55 ) 
local.trig setthread Triggers

local.trig2 = spawn trigger_multiple
local.trig2.origin = (Put your coord here)
local.trig2 setsize (setsize here)(****)
local.trig2 setthread Triggers

local.trig3 = spawn trigger_multiple
local.trig3.origin = (Put your coord here)
local.trig3 setsize (setsize here)(*****)
local.trig3 setthread Triggers


level waittill spawn

end

Triggers: 
local.player=parm.other 
local.player takeall
local.player item weapons/colt45.tik 
local.player ammo pistol 100
local.player useweaponclass pistol
end

All this sounds simple enough but there are some things to concider . First the trigger is going to keep firing as long as the player is triggering it so it will take and give over and over again . If you make the trigger not triggerable untill the player is no longer touching it that would help . Second players who have not hit a trigger will still have the normal weapons .
Image
Tazz
Second Lieutenant
Posts: 155
Joined: Fri Feb 16, 2007 1:29 pm
Contact:

Post by Tazz »

. Second players who have not hit a trigger will still have the normal weapons .
yes thats right.....im only putting triggers at all the entrances to the boiler room in stalingrad because we r making it bash only....if u dont go in the boiler room u will play the other parts of the maps with whatever weapon u choose but bash only in boiler......then ill try the other way u said with the setthread...it is less typing and i like that=)...also will take up less space in my script...thx for all the replys guys
dcbulldog
Lance Corporal
Posts: 10
Joined: Mon Feb 25, 2008 6:11 am
Location: Arkansas
Contact:

after the player leaves the room

Post by dcbulldog »

wont the player still have just the pistol when he leaves the boiler room?
Can you have the player get his weapons back?
Tazz
Second Lieutenant
Posts: 155
Joined: Fri Feb 16, 2007 1:29 pm
Contact:

Post by Tazz »

yeah u can have the player get his weapon or weapons back but u will have to put another trigger where u want to that will do that....if u leave our boiler room u will still only have pistol but if u want to leave with weapons u will need to put in another trigger somewhere outside the ones that take and give back weapons.....
Wierdo
Corporal
Posts: 47
Joined: Wed Jan 09, 2008 11:15 pm
Location: Winfield, KS

Doesn't work

Post by Wierdo »

The script to remove weapons is not being cast on my player. I have tried renaming it because of a previous command that may have named my player $player[local.tm]. any ideas?

Code: Select all

spectate:
while(1) 
{ 
for (local.playtm=1;local.playtm <= $player.size;local.playtm++) 
{ 
if ($player[local.playtm].dmteam == "axis") 
   $player[local.playtm] german 
   $player[local.playtm] threatbias 1000 

if ($player[local.playtm].dmteam == "allies") 
   $player[local.playtm] american 
   $player[local.playtm] threatbias 1000 

if ($player[local.playtm].dmteam == "spectator") 
   $player[local.playtm] threatbias ignoreme 
}
waitframe 
} 
end

Code: Select all

weapon_trig:
   $weapon_trig waittill trigger
   local.tm takeall 
   local.tm item weapons/colt45.tik 
   local.tm ammo pistol 0 
   local.tm useweaponclass pistol 
end
Both codes have been threaded, and the weapon trigger is actually an entity in the map.
Wierdo
Corporal
Posts: 47
Joined: Wed Jan 09, 2008 11:15 pm
Location: Winfield, KS

Fixed it

Post by Wierdo »

I had to do this to get it to run:

Code: Select all

weapon_trig:
   $weapon_trig waittill trigger
   for (local.i=1;local.i <= $player.size;local.i++)
   {
   local.origin = $player.origin
   $player[local.i] takeall
   }
   goto weapon_trig
end
I have a deadbox in my map. Players who die 6 seconds after the game starts go here and may watch the game in progress. A waiting area, which will prevent them from interfereing with the current match.
Tazz
Second Lieutenant
Posts: 155
Joined: Fri Feb 16, 2007 1:29 pm
Contact:

Post by Tazz »

have u tried it like this?

Code: Select all

weapon_trig: 
   local.tm=parm.other
   local.tm takeall 
   local.tm item weapons/colt45.tik 
   local.tm ammo pistol 0 
   local.tm useweaponclass pistol 
end
just wondering because on mine i dont waittill trigger...that is the trigger

whenh u trigger this is what happens

parm.other then takeall then it gives u selected weapon
Wierdo
Corporal
Posts: 47
Joined: Wed Jan 09, 2008 11:15 pm
Location: Winfield, KS

Mistakenness

Post by Wierdo »

Still working with the code. For some reason, my method casts to all players. Hence, all players lose wepons on respawn.

My new method uses this:

Code: Select all

weapon_trig:
   $weapon_trig waittill trigger
   local.playtm=parm.other 
   local.playtm takeall
   goto weapon_trig
end 
Will test to see if this works sometime.
User avatar
211476
Captain
Posts: 273
Joined: Fri Feb 29, 2008 2:20 am
Location: Arizona, USA
Contact:

Post by 211476 »

is this for the MFD bashers server?
Image
Wierdo
Corporal
Posts: 47
Joined: Wed Jan 09, 2008 11:15 pm
Location: Winfield, KS

bashers?

Post by Wierdo »

No, it is not. This is for a completely new map which is a Speedball field. The map has a center flag which runs up the pole to score for either team. Map also has AI, which will play for the flag, even if there are no players on the field. (Axis and Allies from single player.)

The code is needed for a deadbox. Players eliminated from the field after the game starts will spawn weaponless to the deadbox, where the game can be watched from the sidelines. Those who spawn late will wait here for the next match. The AI take about 38 seconds to win by themselves, but will occasionaly hang up for nearly 2 minutes if "line of sight" becomes an issue.
Post Reply