UGX-Mods Login

or login with an authentication provider below
Sign In with Google
Sign In with Twitter
Sign In with Discord
Sign In with Steam
Sign In with Facebook
Sign In with Twitch

Give player gun trigger

HOT
broken avatar :(
Created 10 years ago
by pashan
0 Members and 1 Guest are viewing this topic.
4,884 views
broken avatar :(
×
broken avatar :(
UM Member, Mapper and 3d Modeler
Location: ca
Date Registered: 8 February 2014
Last active: 3 years ago
Posts
835
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Port Arthur
Signature
×
pashan's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
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?
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
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.
Last Edit: March 27, 2014, 10:32:15 pm by daedra descent
broken avatar :(
×
broken avatar :(
UM Member, Mapper and 3d Modeler
Location: ca
Date Registered: 8 February 2014
Last active: 3 years ago
Posts
835
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Port Arthur
×
pashan's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
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.
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 4 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
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
Last Edit: March 27, 2014, 11:43:39 pm by jjbradman
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
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.
broken avatar :(
×
broken avatar :(
UM Member, Mapper and 3d Modeler
Location: ca
Date Registered: 8 February 2014
Last active: 3 years ago
Posts
835
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Port Arthur
×
pashan's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Sorry for asking so many questions, but could you make it so the trigger get deleted. so only one player can use it.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
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?
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 4 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
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" );
}
Last Edit: March 28, 2014, 03:56:37 am by jjbradman
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
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.
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 4 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
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
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
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
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 4 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
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
broken avatar :(
×
broken avatar :(
Location: be
Date Registered: 17 August 2013
Last active: 3 years ago
Posts
369
Respect
Forum Rank
Perk Hacker
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
Web & Software Developer and Designer
Signature
"Deleted code is debugged code." - Jeff Sickel
"Mathematicians stand on each others' shoulders and computer scientists stand on each others' toes." - Richard Hamming
×
JR-Imagine's Groups
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
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.
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 8 years ago
Posts
2,790
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
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.
Last Edit: March 28, 2014, 07:35:38 am by daedra descent
broken avatar :(
×
broken avatar :(
UM Member, Mapper and 3d Modeler
Location: ca
Date Registered: 8 February 2014
Last active: 3 years ago
Posts
835
Respect
Forum Rank
The Decider
Primary Group
Community Mapper
My Groups
More
My Contact & Social Links
More
Personal Quote
Port Arthur
×
pashan's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
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
Last Edit: March 28, 2014, 05:42:03 pm by pashan

 
Loading ...