MOTD Grenade Pit

broken avatar :(
Created 1187 days ago
by MZslayer11
0 Members and 1 Guest are viewing this topic.
1,569 views
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 7 March 2014
Last active: 22 hours ago
Posts
1,189
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Site Moderator
My Groups
More
My Contact & Social Links
More
×
MZslayer11's Groups
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
MZslayer11's Contact & Social LinksAsk MeService_Code_30MZslayer11
So a while ago this topic was posted about MOTD Grenade Disposal and i'm having a little trouble getting it to work with the code posted.

Here is what I have (Credit to Lilrifa):

In mapname.gsc:
Under "maps\_zombiemode::main();"
//Grenade Disposal===================
p = get_players();
for(i=0;i<p.size;i++)
{
p[i] thread watch_for_grenade();
        p[i] IPrintLnBold("Player Connected");
}
// Grenade Disposal=================

Bottom of file:
// Grenade Disposal
watch_for_grenade()
{
self endon( "death" );
self endon( "disconnect" );

for (;;)
{
self waittill("grenade_fire",grenade,weapname);
self IPrintLnBold(weapname);
if(weapname == "fraggrenade" || weapname == "Stielhandgranate")
{
self IPrintLnBold("Grenade Thrown");
grenade thread disposal(self, "grenade_check_trig");
}
}
}

disposal(player, grenade_disposal)
{
player IPrintLnBold("Checking for trig");
trig = getEnt( "targetname" , "grenade_disposal");
checking = 1;
while(checking)
{
wait(0.05);

if(self isTouching(trig))
{
player maps\_zombiemode_score::add_to_player_score(20);
self delete();
player IPrintLnBold("Deleting Grenade");
}

checking = 0;
}
}

Original Post: http://ugx-mods.com/forum/index.php/topic,7052.0.html

Whats happening to me is that all my grenades are deleted instead of just the ones that are thrown into the trigger. Any help is appriecated.
This topic contains a post which is marked as the Best Answer. Click here to view it.
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 30 December 2012
Last active: 6 days ago
Posts
573
Respect
Forum Rank
Zombie Enslaver
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
My preferred name is "xSanchez78".
Check me out here: [You are not allowed to view external links. Register or Login to see them]
×
alaurenc9's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
alaurenc9's Contact & Social Linksalaurenc9xSanchez78xSanchez78xSanchez78
this is because your trigger is undefined.

your trigger is undefined because you are using GetEnt very incorrectly.

i assume you wanted this??

trig = GetEnt( grenade_disposal, "targetname" );

also take out

self endon( "death" );


in watch_for_grenade(), because that would mean once u spectate, this script stops running for the rest of the game.

also your while loop ends after only one check??
i would recommend replacing that whole functions with this:

disposal( player, grenade_disposal ) 
{
self endon( "death" ); // if the grenade explodes, end this function
trig = GetEnt( grenade_disposal, "targetname" );
while( true )
{
wait 0.05;
if( IsDefined( self ) && self IsTouching( trig ) ) // check if the nade is still defined first ( it hasnt blown up yet )
{
player maps\_zombiemode_score::add_to_player_score( 20 );
self Delete(); // delete after adding points, because this function ends on the grenade's delete
return;
}
}
}
Last Edit: November 24, 2015, 05:15:30 pm by alaurenc9
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 7 March 2014
Last active: 22 hours ago
Posts
1,189
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Site Moderator
My Groups
More
My Contact & Social Links
More
×
MZslayer11's Groups
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
MZslayer11's Contact & Social LinksAsk MeService_Code_30MZslayer11
Thanks ill give that a go

Double Post Merge: November 24, 2015, 05:28:18 pm
Hmm its still doing the same thing with your changes.
Last Edit: November 24, 2015, 05:28:18 pm by MZslayer11
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 7 days ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
Signature
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
Thanks ill give that a go

Double Post Merge: November 24, 2015, 05:28:18 pm
Hmm its still doing the same thing with your changes.

Maybe add another check then?
    if(IsDefined( trig ) && self IsTouching( trig ) )

it seems that it is deleting due to that line, and maybe you have a typo in your kvp in radiant, or more than one of those triggers, or something, and trig isn't defined since you had it backwards (the original post had it backwards too) and in quotes... What is your kvp for that trigger in radiant? If that check addition stops it from deleting at all, I would guess that trig is not defined then.

Edit: Your kvp should be "grenade_check_trig" since that is the string you are passing.

disposal(player, grenade_disposal) 
{
player IPrintLnBold("Checking for trig");
trig = getEntArray( grenade_disposal, "targetname" )[0];//in case you have more than one, will error, need to edit script to thread on each of them if you want more than one
while(isdefined(self))
{
wait(0.05);

if(isdefined(trig) && self isTouching(trig))
{
player maps\_zombiemode_score::add_to_player_score(20);
self delete();
player IPrintLnBold("Deleting Grenade");
}
}
}

For multiple triggers try something like:
disposal(player, grenade_disposal) 
{
player IPrintLnBold("Checking for trig");
trigs = getEntArray( grenade_disposal, "targetname" );
array_thread(trigs,::WatchMe,self,player);
}
WatchMe(grenade, player){
while(isdefined(grenade))
{
wait(0.05);

if(isdefined(self) && grenade isTouching(self))
{
player maps\_zombiemode_score::add_to_player_score(20);
grenade delete();
player IPrintLnBold("Deleting Grenade");
}
}
}
Last Edit: November 24, 2015, 06:16:04 pm by MakeCents
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 7 March 2014
Last active: 22 hours ago
Posts
1,189
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Site Moderator
My Groups
More
My Contact & Social Links
More
×
MZslayer11's Groups
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
MZslayer11's Contact & Social LinksAsk MeService_Code_30MZslayer11
Alright its is almost working properly with the stuff that MakeCents posted (the multiple triggers one). For some reason, it gives me 40 points when I throw it into the pit, and when I do not throw it in the pit, it doesn't get deleted (yay), but it gives me 40 points when it explodes.  :o

this is the exact code i'm using now:

Under maps\_zombiemode::main();
//Grenade Disposal===================
p = get_players();
for(i=0;i<p.size;i++)
{
p[i] thread watch_for_grenade();
        p[i] IPrintLnBold("Player Connected");
}
// Grenade Disposal=================

Bottom of file:
// Grenade Disposal
watch_for_grenade()
{
self endon( "disconnect" );

for (;;)
{
self waittill("grenade_fire",grenade,weapname);
self IPrintLnBold(weapname);
if(weapname == "fraggrenade" || weapname == "Stielhandgranate")
{
self IPrintLnBold("Grenade Thrown");
grenade thread disposal(self, "grenade_check_trig");
}
}
}

disposal(player, grenade_disposal)
{
player IPrintLnBold("Checking for trig");
trigs = getEntArray( grenade_disposal, "targetname" );
array_thread(trigs,::WatchMe,self,player);
}

WatchMe(grenade, player){
while(isdefined(grenade))
{
wait(0.05);

if(isdefined(self) && grenade isTouching(self))
{
player maps\_zombiemode_score::add_to_player_score(20);
grenade delete();
player IPrintLnBold("Deleting Grenade");
}
}
}

I have two trigger multiples in  radiant with the KVP:
targetname - grenade_check_trig

WTF is wrong now lol?
Marked as best answer by MZslayer11 on Today at 04:53:32 am
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 14 September 2013
Last active: 7 days ago
Posts
1,895
Respect
Forum Rank
Zombie Destroyer
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Personal Quote
BE ORIGINAL
×
MakeCents's Groups
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
Community Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
BO3 Modtools Alpha
BO3 Modtools Alpha
This user has access to the Black Ops 3 Modtools Alpha
You should only have one trig unless you have multiple places you can do this at. When you say you have two, are they at the same place or touching? If they are touching, then that is why prob, delete one.
If the triggers are in different places then it could also need another check, try:

WatchMe(grenade, player){
while(isdefined(grenade))
{
wait(0.05);

if(isdefined(self) && isdefined(grenade) && grenade isTouching(self))
{
player maps\_zombiemode_score::add_to_player_score(20);
grenade delete();
player IPrintLnBold("Deleting Grenade");
}
}
}
Last Edit: November 25, 2015, 04:40:20 am by MakeCents
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 7 March 2014
Last active: 22 hours ago
Posts
1,189
Respect
Forum Rank
Zombie Colossus
Primary Group
UGX Site Moderator
My Groups
More
My Contact & Social Links
More
×
MZslayer11's Groups
UGX Site Moderator Has the ability to issue warnings to users, edit and remove posts from the forum and to move topics to other boards. Upholds the rules of the forum. Moderates Chat Rooms.
MZslayer11's Contact & Social LinksAsk MeService_Code_30MZslayer11
You should only have one trig unless you have multiple places you can do this at. When you say you have two, are they at the same place or touching?
It could also need another check, try:

WatchMe(grenade, player){
while(isdefined(grenade))
{
wait(0.05);

if(isdefined(self) && isdefined(grenade) && grenade isTouching(self))
{
player maps\_zombiemode_score::add_to_player_score(20);
grenade delete();
player IPrintLnBold("Deleting Grenade");
}
}
}

yeah they are at two seperate places. Ill give that a try.

Double Post Merge: November 25, 2015, 04:53:04 am
Thank you so much, that got it working +1!
Last Edit: November 25, 2015, 04:53:04 am by MZslayer11

 

Login

or login with an authentication provider below
Twitter
Discord
Steam
Twitch
Google
Loading ...