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

[Tutorial] Shootable Triggers

HOT
broken avatar :(
Created 8 years ago
by reckfullies
0 Members and 1 Guest are viewing this topic.
43,536 views
broken avatar :(
  • M0ul3_G4m3r
  • Deleted Member
×
broken avatar :(
M0ul3_G4m3r
This user is deleted :(
Just as the error says, you didn't initialize the variable player.

There are 2 ways you can do this depending on who you want to give the perk to.

All Players:
Spoiler: click to open...
Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

while(1)
{
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

// What ever code you want to execute once all shootables are collected
IPrintLn("Here is your reward!");

for(i=0; i < players.size; i++)
{
players[i] zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );
}

            break;
}
}
}

Only the players that shot a shootable:
First, go into each of the shootable functions and change them to this:
Spoiler: click to open...
Code Snippet
Plaintext
function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
model_1 = GetEnt("shootable_model", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
    trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

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

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done(player);

break;
}

trig_2 Delete();
model_2 Delete();
}

then change the shootables_done function to this:
Spoiler: click to open...
Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("All Shootables Collected");

player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );

    break;
}
}
}

Thanks but I have try to use the "All Players" script but I got this error when I launching the game :
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
Thanks but I have try to use the "All Players" script but I got this error when I launching the game :
(Image removed from quote.)

You must have messed something up when copying or something, the function I gave you shouldn't be causing this.

Check line 30 of that script and if you cant figure it out just post the whole script here and Ill look at it
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 7 September 2016
Last active: 7 years ago
Posts
3
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
My Contact & Social Links
More
×
Vetrotec's Groups
Vetrotec's Contact & Social LinksVetrotecGaming
I've already seen this being talked about. I'm very very new to all this and was wondering how I'd go about making this script open a door if anyone can help me this would mean a lot to me and others.   :poker:
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 9 October 2014
Last active: 5 years ago
Posts
15
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
GNT123's Groups
GNT123's Contact & Social Links
I've already seen this being talked about. I'm very very new to all this and was wondering how I'd go about making this script open a door if anyone can help me this would mean a lot to me and others.   :poker:

Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
        level thread shootable_3();
}


function shootable_1()
{
    trig_1 = GetEnt("shootable_trig_1", "targetname");
model_1 = GetEnt("shootable_model_1", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

while(1)
{
trig_1 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

while(1)
{
trig_2 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_2 Delete();
model_2 Delete();
}
function shootable_3()
{
    trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

while(1)
{
trig_3 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_3 Delete();
model_3 Delete();
}



function shootables_done()
{
door_power = GetEnt("door_power", "targetname");
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
             door_power MoveZ(-100, 5);

             wait 5;

             door_power Delete();

        break;
}
}
}
Haven't test this but it should work. Just do reckfullies tutoral at the top of the forum and just add one more script model with a targetname "shootable_model_3" and a trigger damage with the targetname "shootable_trig_3" then add your door make it a  script modle and add the targetname "door_power".  Finally, this should work but it will not say your entering the zone so if you want zombies to spawn in your power room you might have to have someone easle help you with that.

 
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 7 September 2016
Last active: 7 years ago
Posts
3
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
My Contact & Social Links
More
×
Vetrotec's Groups
Vetrotec's Contact & Social LinksVetrotecGaming
Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
        level thread shootable_3();
}


function shootable_1()
{
    trig_1 = GetEnt("shootable_trig_1", "targetname");
model_1 = GetEnt("shootable_model_1", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

while(1)
{
trig_1 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

while(1)
{
trig_2 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_2 Delete();
model_2 Delete();
}
function shootable_3()
{
    trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

while(1)
{
trig_3 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_3 Delete();
model_3 Delete();
}



function shootables_done()
{
door_power = GetEnt("door_power", "targetname");
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
             door_power MoveZ(-100, 5);

             wait 5;

             door_power Delete();

        break;
}
}
}
Haven't test this but it should work. Just do reckfullies tutoral at the top of the forum and just add one more script model with a targetname "shootable_model_3" and a trigger damage with the targetname "shootable_trig_3" then add your door make it a  script modle and add the targetname "door_power".  Finally, this should work but it will not say your entering the zone so if you want zombies to spawn in your power room you might have to have someone easle help you with that.

Ill check now if it works :)
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 7 September 2016
Last active: 7 years ago
Posts
3
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
My Contact & Social Links
More
×
Vetrotec's Groups
Vetrotec's Contact & Social LinksVetrotecGaming
Code Snippet
Plaintext
function init()
{
level.shootablesNeeded = 3;
level.shootablesCollected = 0;

level thread shootable_1();
level thread shootable_2();
        level thread shootable_3();
}


function shootable_1()
{
    trig_1 = GetEnt("shootable_trig_1", "targetname");
model_1 = GetEnt("shootable_model_1", "targetname");

trig_1 SetHintString("");
trig_1 SetCursorHint("HINT_NOICON");

while(1)
{
trig_1 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_1 Delete();
model_1 Delete();
}

function shootable_2()
{
trig_2 = GetEnt("shootable_trig_2", "targetname");
model_2 = GetEnt("shootable_model_2", "targetname");

trig_2 SetHintString("");
trig_2 SetCursorHint("HINT_NOICON");

while(1)
{
trig_2 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 2 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_2 Delete();
model_2 Delete();
}
function shootable_3()
{
    trig_3 = GetEnt("shootable_trig_3", "targetname");
model_3 = GetEnt("shootable_model_3", "targetname");

trig_3 SetHintString("");
trig_3 SetCursorHint("HINT_NOICON");

while(1)
{
trig_3 waittill("trigger");

level.shootablesCollected++;

IPrintLn("Trigger 1 Shot"); // Not Needed

thread shootables_done();

break;
}

trig_3 Delete();
model_3 Delete();
}



function shootables_done()
{
door_power = GetEnt("door_power", "targetname");
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

if(level.shootablesCollected == level.shootablesNeeded)
{
             door_power MoveZ(-100, 5);

             wait 5;

             door_power Delete();

        break;
}
}
}
Haven't test this but it should work. Just do reckfullies tutoral at the top of the forum and just add one more script model with a targetname "shootable_model_3" and a trigger damage with the targetname "shootable_trig_3" then add your door make it a  script modle and add the targetname "door_power".  Finally, this should work but it will not say your entering the zone so if you want zombies to spawn in your power room you might have to have someone easle help you with that.

Black screens my game on load up. just me?
broken avatar :(
×
broken avatar :(
Location: england
Date Registered: 19 September 2015
Last active: 5 years ago
Posts
2
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
Kierpok's Groups
Kierpok's Contact & Social Links
could you tell me if its possible to make is so every person in my game gets the perk

Double Post Merge: October 26, 2016, 09:36:55 pm
You must have messed something up when copying or something, the function I gave you shouldn't be causing this.

Check line 30 of that script and if you cant figure it out just post the whole script here and Ill look at it

THIS IS MY SCRIPT FOR IT AND IT WORKS TO SHOOT ALL 3 TEDDYS BUT WHEN IT GETS TO IT IT DOSE NOT GIVE ANY PERK ANY ONE GOT IDEAS WHY? (Sorry for caps trying to make it look different from the script ^.^)


#using scripts\zm\_zm_perks;
#insert scripts\zm\_zm_perks.gsh;
 
function init()
{
    level.shootablesNeeded = 3;
    level.shootablesCollected = 0;
 
    level thread shootable_1();
    level thread shootable_2();
    level thread shootable_3();
}
 
function shootable_1()
{
    trig_1 = GetEnt("shootable_trig", "targetname");
    model_1 = GetEnt("shootable_model", "targetname");
 
    trig_1 SetHintString("");
    trig_1 SetCursorHint("HINT_NOICON");
 
    while(1)
    {
        trig_1 waittill("trigger", player);
 
        level.shootablesCollected++;
 
        IPrintLn("1/3 teddys"); // Not Needed
 
        thread shootables_done(player);
 
        break;
    }
 
    trig_1 Delete();
    model_1 Delete();
}
 
function shootable_2()
{
    trig_2 = GetEnt("shootable_trig_2", "targetname");
    model_2 = GetEnt("shootable_model_2", "targetname");
 
    trig_2 SetHintString("");
    trig_2 SetCursorHint("HINT_NOICON");
 
    while(1)
    {
        trig_2 waittill("trigger", player);
 
        level.shootablesCollected++;
 
        IPrintLn("2/3 teddys"); // Not Needed
 
        thread shootables_done(player);
 
        break;
    }
 
    trig_2 Delete();
    model_2 Delete();
}
 
function shootable_3()
{
    trig_3 = GetEnt("shootable_trig_3", "targetname");
    model_3 = GetEnt("shootable_model_3", "targetname");
 
    trig_3 SetHintString("");
    trig_3 SetCursorHint("HINT_NOICON");
 
    while(1)
    {
        trig_3 waittill("trigger", player);
 
        level.shootablesCollected++;
 
        IPrintLn("all teddys collected"); // Not Needed
 
        thread shootables_done(player);
 
        break;
    }
 
    trig_3 Delete();
    model_3 Delete();
}
 
function shootables_done(player)
{
    while(1)
    {
        self waittill(level.shootablesCollected >= level.shootablesNeeded);
 
        if(level.shootablesCollected == level.shootablesNeeded)
        {
           players = GetPlayers();

         for(i=0; i < players.size; i++)
           {   
            player zm_perks::give_perk( PERK_WIDOWS_WINE, false );
         }
        }
 
        break;
    }
}
Last Edit: October 26, 2016, 09:36:55 pm by Kierpok
broken avatar :(
×
broken avatar :(
Location: gbMilton Keynes
Date Registered: 17 January 2014
Last active: 4 years ago
Posts
6,877
Respect
1,004Add +1
Forum Rank
Immortal
Primary Group
Community Scripter
My Groups
More
My Contact & Social Links
More
Signature
If you want scripts / features made for you, then contact me by PM or email / skype etc
it will cost you tho so if you have no intention of reciprocating don't even waste my time ;)
×
Harry Bo21'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.
Harry Bo21's Contact & Social Links[email protected]HarryBo21HarryBo000
Wrong perk reference

It's the specialty name you must use

Think for widows it's either

"Specialty_widowswine"

If not its

"Specialty_widows_wine"

Check the zm_perks gsh for the list

The other you've used is just a variable
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 24 March 2014
Last active: 6 years ago
Posts
2
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
My Contact & Social Links
More
×
iSkillz v6's Groups
iSkillz v6's Contact & Social LinksiSkillz_v6iSkillz v6
Trying to get audio to play when a trigger has been shot tried everything. Sorta like the EE from The Giant.

EDIT: Figured it out :P

How do you do this, I would really like to know :)
broken avatar :(
×
broken avatar :(
Location: gbbradford
Date Registered: 26 September 2014
Last active: 7 years ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
harvez's Groups
harvez's Contact & Social Links
Add this to the top of the script:
Code Snippet
Plaintext
#using scripts/zm/_zm_powerups;

Then add this to the shootable_done function:
Code Snippet
Plaintext
level thread zm_powerups::specific_powerup_drop("powerupname", origin);

Just replace "powerupname" with the code name of the powerup.

Avaliable Powerups:
Spoiler: click to open...
  • bonfire_sale
  • carpenter
  • double_points
  • fire_sale
  • free_perk
  • full_ammo
  • insta_kill
  • shield_charge
  • weapon_minigun
  • ww_grenade

Then make origin the origin you want the powerup to spawn at.
Example:
Code Snippet
Plaintext
test = GetEnt("test", "targetname");

level thread zm_powerups::specific_powerup_drop("full_ammo", test.origin); // This will spawn a max ammo at the origin of the test entity.

im getting this error?
^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (157,1)  : Compiler Internal Error :  Unresolved external 'zm_powerups::specific_powerup_drop'
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 17 February 2014
Last active: 1 year ago
Posts
69
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
Personal Quote
What is broken can be reforged
Signature
Completed maps:
Kingdom Hearts - World at War Link
Minecraft - Black ops 3 Link

WIP:
~

×
shinged's Groups
shinged's Contact & Social LinksShingedvinny545TheShingedMatarra_
im getting this error?
^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (157,1)  : Compiler Internal Error :  Unresolved external 'zm_powerups::specific_powerup_drop'

You gotta include the powerups script in your gsc.
Code Snippet
Plaintext
#using scripts\zm\zm_powerups;

Double Post Merge: October 28, 2016, 12:05:07 am
im getting this error?
^1}
^1^
^1ERR(6E) scripts/custom/shootable.gsc (157,1)  : Compiler Internal Error :  Unresolved external 'zm_powerups::specific_powerup_drop'

You gotta include the powerups script in your gsc.
Code Snippet
Plaintext
#using scripts\zm\zm_powerups;
Last Edit: October 28, 2016, 12:05:07 am by shinged
broken avatar :(
×
broken avatar :(
Location: gb
Date Registered: 7 March 2016
Last active: 7 years ago
Posts
5
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
deathy0909's Groups
deathy0909's Contact & Social Links
Wrong perk reference

It's the specialty name you must use

Think for widows it's either

"Specialty_widowswine"

If not its

"Specialty_widows_wine"

Check the zm_perks gsh for the list

The other you've used is just a variable

I would just like to state that using PERK_WIDOWS_WINE will not affect the outcome. Also it is "specialty_widowswine" which is also defined by PERK_WIDOWS_WINE.

His problem was inside the loop.

Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);
 
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

for(i=0; i < players.size; i++)
{   
player[i] zm_perks::give_perk( PERK_WIDOWS_WINE, false );
}
}
break;
}
}

I have fixed the code so if you wish to replace the function you can do.

Also question for OP, out of curiosity why did you add a loop into shootables_done?
broken avatar :(
×
broken avatar :(
Location: england
Date Registered: 19 September 2015
Last active: 5 years ago
Posts
2
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
Kierpok's Groups
Kierpok's Contact & Social Links
I would just like to state that using PERK_WIDOWS_WINE will not affect the outcome. Also it is "specialty_widowswine" which is also defined by PERK_WIDOWS_WINE.

His problem was inside the loop.

Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);
 
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

for(i=0; i < players.size; i++)
{   
player[i] zm_perks::give_perk( PERK_WIDOWS_WINE, false );
}
}
break;
}
}

I have fixed the code so if you wish to replace the function you can do.

Also question for OP, out of curiosity why did you add a loop into shootables_done?


Thank you sooo much I would have no idea thats what was wrong with the scrip ^^ Trying my best to wrap my head round it but its preaty hard :0 Thank you again !!
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 12 September 2016
Last active: 3 years ago
Posts
306
Respect
Forum Rank
Perk Hacker
Primary Group
Member
My Contact & Social Links
More
×
reckfullies's Groups
reckfullies's Contact & Social LinksReckfulliesReckfullies
I would just like to state that using PERK_WIDOWS_WINE will not affect the outcome. Also it is "specialty_widowswine" which is also defined by PERK_WIDOWS_WINE.

His problem was inside the loop.

Spoiler: click to open...
Code Snippet
Plaintext
function shootables_done(player)
{
while(1)
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);
 
if(level.shootablesCollected == level.shootablesNeeded)
{
players = GetPlayers();

for(i=0; i < players.size; i++)
{   
player[i] zm_perks::give_perk( PERK_WIDOWS_WINE, false );
}
}
break;
}
}

I have fixed the code so if you wish to replace the function you can do.

Also question for OP, out of curiosity why did you add a loop into shootables_done?

I'm pretty sure the reason the loop is there was for something I was doing with the script in my map before I released it here, doubt it is really needed unless i'm forgetting something.
broken avatar :(
×
broken avatar :(
Location: es
Date Registered: 29 January 2013
Last active: 2 years ago
Posts
43
Respect
Forum Rank
Legless Crawler
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
×
pedrehitor's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
pedrehitor's Contact & Social LinkspedrehitorpedrehitorPedrehitor74
Someone knows what script I have to put to shoot three bears and open a door

 
Loading ...