UGX-Mods

Call of Duty 5: World at War => Help Desk => Topic started by: pashan on March 27, 2014, 10:14:23 pm

Title: Give player gun trigger
Post by: pashan on March 27, 2014, 10:14:23 pm
How do i make so that when a player holds the use button a trigger it give the player a specific gun for example a ray gun?
Title: Re: Give player gun trigger
Post by: daedra descent on March 27, 2014, 10:27:21 pm
Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

while(1)
{

players = get_players();
trigger waittill("trigger", players);
players GiveWeapon( "ray_gun" );
wait(1);
}
}

This should work(hopefully, never tested it xD).

EDIT: Removed the cost, didn't add that in the code so it was useless.
Title: Re: Give player gun trigger
Post by: pashan on March 27, 2014, 10:58:33 pm
Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

while(1)
{

players = get_players();
trigger waittill("trigger", players);
players GiveWeapon( "ray_gun" );
wait(1);
}
}

This should work(hopefully, never tested it xD).

EDIT: Removed the cost, didn't add that in the code so it was useless.

Since i don't know how to script how do i make it so that the ray gun replaces the weapon the player is holding

because your code just gives the player a ray gun and gives and extra slot like mulekick.
Title: Re: Give player gun trigger
Post by: jjbradman on March 27, 2014, 11:43:14 pm
Since i don't know how to script how do i make it so that the ray gun replaces the weapon the player is holding

because your code just gives the player a ray gun and gives and extra slot like mulekick.

here you have :)

Code Snippet
Plaintext
gun_give_trig()
{
player = undefined;
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

while(1)
{
trigger waittill("trigger", player);

currentweapon = player GetCurrentWeapon();
player TakeWeapon( currentweapon );
player GiveWeapon( "ray_gun" ); //change here to the name of the gun you want"the name of the weapon file"
wait(1);
}
}
the code has a reference to change weapon :P
Title: Re: Give player gun trigger
Post by: daedra descent on March 27, 2014, 11:48:28 pm
here you have :)

Code Snippet
Plaintext
gun_give_trig()
{
player = undefined;
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

while(1)
{
trigger waittill("trigger", player);

currentweapon = player GetCurrentWeapon();
player TakeWeapon( currentweapon );
player GiveWeapon( "ray_gun" ); //change here to the name of the gun you want"the name of the weapon file"
wait(1);
}
}
the code has a reference to change weapon :P

Stop taking my thunder dammit xD

Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

while(1)
{

players = get_players();
trigger waittill("trigger", players);
current_weapon = players getCurrentWeapon();

if(isdefined(current_weapon) )
{
players TakeWeapon( current_weapon );
}

players GiveWeapon( "ray_gun" );
players SwitchToWeapon( "ray_gun" );
wait(1);
}
}

This should do it. I'm not sure if declaring "player" as undefined makes a difference so i never added it.
Title: Re: Give player gun trigger
Post by: pashan on March 28, 2014, 12:00:07 am
Sorry for asking so many questions, but could you make it so the trigger get deleted. so only one player can use it.
Title: Re: Give player gun trigger
Post by: daedra descent on March 28, 2014, 12:06:42 am
Sorry for asking so many questions, but could you make it so the trigger get deleted. so only one player can use it.

Well, that changes things a bit.  :P

Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

players = get_players();
trigger waittill("trigger", players);
current_weapon = players getCurrentWeapon();

if(isdefined(current_weapon) )
{
players TakeWeapon( current_weapon );
}

players GiveWeapon( "ray_gun" );
players SwitchToWeapon( "ray_gun" );
trigger delete();
}

How about this?
Title: Re: Give player gun trigger
Post by: jjbradman on March 28, 2014, 03:56:06 am
Stop taking my thunder dammit xD
noup :3 haha. hey dd what is the point of checking for if the player current weapon is defined? xD lol i htink that in this context the current weapon will obviosly be difined, you should have made that the "if" checks if the player weapons.size is == to 2 , cause if he has 1 weap this code will leave the player with just one weapon. also the get players is uneeded.
so....
Code Snippet
Plaintext
gun_give_trig()
{
player = undefined;
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

trigger waittill("trigger", player);
weapList = player GetWeaponsListPrimaries();

    if( weaplist.size >= 2 )
{
current_weapon = player getCurrentWeapon();
player TakeWeapon( current_weapon );
player thread give_raygun();
}
else if( weaplist.size <= 1 )
    {
        player thread give_raygun();
}

trigger delete();
}

give_raygun()
{
self GiveWeapon( "ray_gun" );
self SwitchToWeapon( "ray_gun" );
}
Title: Re: Give player gun trigger
Post by: daedra descent on March 28, 2014, 04:24:41 am
noup :3 haha. hey dd what is the point of checking for if the player current weapon is defined? xD lol i htink that in this context the current weapon will obviosly be difined, you should have made that the "if" checks if the player weapons.size is == to 2 , cause if he has 1 weap this code will leave the player with just one weapon. also the get players is uneeded.
so....
Code Snippet
Plaintext
gun_give_trig()
{
player = undefined;
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

trigger waittill("trigger", player);
weapList = player GetWeaponsListPrimaries();

    if( weaplist.size >= 2 )
{
current_weapon = player getCurrentWeapon();
player TakeWeapon( current_weapon );
player thread give_raygun();
}
else if( weaplist.size <= 1 )
    {
        player thread give_raygun();
}

trigger delete();
}

give_raygun()
{
self GiveWeapon( "ray_gun" );
self SwitchToWeapon( "ray_gun" );
}

Shh... go home JJ, your drunk.
Title: Re: Give player gun trigger
Post by: jjbradman on March 28, 2014, 04:53:00 am
haha i actually am (/u\) but you dont have to say it (/n\) lol
but im sure the code has to work this way xD
Title: Re: Give player gun trigger
Post by: daedra descent on March 28, 2014, 04:55:32 am
haha i actually am (/u\) but you dont have to say it (/n\) lol
but im sure the code has to work this way xD

Oh? Then why does it work the way i made it? xD
Title: Re: Give player gun trigger
Post by: jjbradman on March 28, 2014, 05:24:30 am
i dont understand ._.' haha the second code would take the players weapon even if he only had 1 weap D: and nobody wants to end up with just 1 weap :s
Title: Re: Give player gun trigger
Post by: JR-Imagine on March 28, 2014, 06:45:25 am
Well, that changes things a bit.  :P

Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

players = get_players();
trigger waittill("trigger", players);
current_weapon = players getCurrentWeapon();

if(isdefined(current_weapon) )
{
players TakeWeapon( current_weapon );
}

players GiveWeapon( "ray_gun" );
players SwitchToWeapon( "ray_gun" );
trigger delete();
}

How about this?
Just wondering, why are you doing players = getplayers(); if the next line sets players to whichever player triggers it? Also, I would change the F in the hintstring to &&1.
Title: Re: Give player gun trigger
Post by: daedra descent on March 28, 2014, 07:34:53 am
Just wondering, why are you doing players = getplayers(); if the next line sets players to whichever player triggers it? Also, I would change the F in the hintstring to &&1.

For #YOLO reasons.
Title: Re: Give player gun trigger
Post by: pashan on March 28, 2014, 05:38:41 pm
Well, that changes things a bit.  :P

Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("Press F to get a Ray Gun");

players = get_players();
trigger waittill("trigger", players);
current_weapon = players getCurrentWeapon();

if(isdefined(current_weapon) )
{
players TakeWeapon( current_weapon );
}

players GiveWeapon( "ray_gun" );
players SwitchToWeapon( "ray_gun" );
trigger delete();
}

How about this?

I am a bit new to coding but i added a new line (because i want it to be a hidden easter egg)

Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("");
trigger setCursorHint( "HINT_NOICON" );

players = get_players();
trigger waittill("trigger", players);
current_weapon = players getCurrentWeapon();

if(isdefined(current_weapon) )
{
players TakeWeapon( current_weapon );
}

players GiveWeapon( "ray_gun" );
players SwitchToWeapon( "ray_gun" );
trigger delete();
}

Post Merge: March 28, 2014, 05:42:03 pm
i dont understand ._.' haha the second code would take the players weapon even if he only had 1 weap D: and nobody wants to end up with just 1 weap :s

The player would always have 2 weapons:

you start out with colt = 1 weapon

the player then buys a second weapon because the colt sucks = 2 weapons

then the player will get the ray gun which will replace his current weapon he is holding  = 2 weapons

do you get what i am trying to say.

and also the trigger is in the 3rd room and the player wouldn't be able to get their with only the colt.

- Pashan
Title: Re: Give player gun trigger
Post by: jjbradman on March 29, 2014, 12:09:55 am
I am a bit new to coding but i added a new line (because i want it to be a hidden easter egg)

Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("");
trigger setCursorHint( "HINT_NOICON" );

players = get_players();
trigger waittill("trigger", players);
current_weapon = players getCurrentWeapon();

if(isdefined(current_weapon) )
{
players TakeWeapon( current_weapon );
}

players GiveWeapon( "ray_gun" );
players SwitchToWeapon( "ray_gun" );
trigger delete();
}

Post Merge: March 28, 2014, 05:42:03 pm
The player would always have 2 weapons:

you start out with colt = 1 weapon

the player then buys a second weapon because the colt sucks = 2 weapons

then the player will get the ray gun which will replace his current weapon he is holding  = 2 weapons

do you get what i am trying to say.

and also the trigger is in the 3rd room and the player wouldn't be able to get their with only the colt.

- Pashan
anyways the code leaves option for leaving a player qith 1 weap. so the code might work for you but, in a more open environment the code must be as i said....also you didnt mentioned your map set up so one makes code which works in every stage not just your map.
besides the    
Code Snippet
Plaintext
if(isdefined(current_weapon) )
{
players TakeWeapon( current_weapon );
}

if statement was completly useless and the players = get_players(); was just there for "yolo" reasons lol
Title: Re: Give player gun trigger
Post by: ProGamerzFTW on March 29, 2014, 09:19:19 am
If you don't want your weapon replaced when having a single gun like jj had earlier.

Untested.

Code Snippet
Plaintext
gun_give_trig()
{
trigger = getent("gun_trig", "targetname");
trigger sethintstring("");
trigger setCursorHint( "HINT_NOICON" );

trigger waittill("trigger", players);
current_weapon = players getCurrentWeapon();
weapon_list = players GetWeaponsListPrimaries();

if(isdefined(current_weapon) && weapon_list.size > 1)
{
players TakeWeapon( current_weapon );
}

players GiveWeapon( "ray_gun" );
players SwitchToWeapon( "ray_gun" );
trigger delete();
}
Title: Re: Give player gun trigger
Post by: SadBoyPro on July 11, 2014, 11:23:45 am
Hey guys this may have been answered here but i am a bit new so here's with the question.

Am I right in thinking this will allow one to only let a specific player activate the trigger?

The reason I ask is that I am looking for some help in creating a piece of code which says that;

If player = "player name" trigger = false

so essentially the play cannot purchase the gun unless the player name is one i have defined.
Title: Re: Give player gun trigger
Post by: Alerion on July 11, 2014, 11:33:02 am
Please create a new topic next time where you say which topic you are referring to.
Title: Re: Give player gun trigger
Post by: SadBoyPro on July 11, 2014, 03:00:07 pm
Oh I have  :) I was just inquiring in this thread to get clarification that the code that was posted performed that function. I'm clearly new and don't quite understand it hence my question was directed actually at this post :)
Title: Re: Give player gun trigger
Post by: epicduck97 on July 12, 2014, 04:24:16 am
quick question, which script can we add the code to? I've done this stuff in non UGX maps, and they go in youmapname.gsc in root raw map folder. With ugx we dont have that, in that folder.. We have it in yourmapname.iwd in the root mods folder. I've tried it there and it doesnt work. The ugx install wiki says to put code "within ugx_mod.iwd and ugxm_guns.iwd" I did it in zombiemode.gsc, in ugx_mod.iwd, and It didnt work.. Where can I put it? sorry im a noob lol
Title: Re: Give player gun trigger
Post by: djobdam on September 06, 2014, 06:34:19 pm
one question, if u want to get the raygun without pressing a trigger what kind of code do I need?

Double Post Merge: September 06, 2014, 07:39:40 pm
I've got this script

Code Snippet
Plaintext
//Secret_Easter_Egg
Secret_trigger_1()
{
   trig1 = getEnt("secret_trigger","targetname");
   trig1 waittill("trigger", player );
   trig1 delete();
   trig1 SetCursorHint( "HINT_NOICON" );
   
self.secret_trigger_num = self.secret_trigger_num + 1;

thread secret_weapon();
}

secret_trigger_2()
{
   trig2 = getEnt("secret_trigger2","targetname");
   trig2 waittill("trigger", player );
   trig2 delete();
   trig2 SetCursorHint( "HINT_NOICON" );

self.secret_trigger_num = self.secret_trigger_num + 1;

thread secret_weapon();
}

secret_trigger_3()
{
   trig3 = getEnt("secret_trigger3","targetname");
   trig3 waittill("trigger", player );
   trig3 delete();
   trig3 SetCursorHint( "HINT_NOICON" );

self.secret_trigger_num = self.secret_trigger_num + 1;

secret_weapon()
{
door = getEnt("secret_door","targetname");
if(self.secret_trigger_num == 2)
{
door movez(-500, 25);
wait 8;
door delete();
}
}

and instead of a door that opens I want to get a gun, how do I do that?