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,469 views
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 man that worked ill give you some credit in my map description once its updated!

Double Post Merge: October 15, 2016, 12:30:44 am
The script works but after testing it on multiplayer it gives the shield to only 1 player and not all players. Is theirs a way to script it to all players or all 4?

Double Post Merge: October 15, 2016, 12:31:42 am
holly fuck i was baked when I wrote that

Replace this:
Code Snippet
Plaintext
player zm_equipment::give(equipment);

With this:
Code Snippet
Plaintext
players = GetPlayers();

for(i=0; i < players.size; i++)
{
    players[i] zm_equipment::give(equipment);
}
Last Edit: October 15, 2016, 09:19:24 am by reckfullies
broken avatar :(
  • M0ul3_G4m3r
  • Deleted Member
×
broken avatar :(
M0ul3_G4m3r
This user is deleted :(
Hi!
What is the code to play song or a custom song when a trigger was shooted ?! thanks !  :accepted:
broken avatar :(
×
broken avatar :(
Location: ca
Date Registered: 1 August 2016
Last active: 7 years ago
Posts
7
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
Gondor's Groups
Gondor's Contact & Social Links
Replace this:
Code Snippet
Plaintext
player zm_equipment::give(equipment);

With this:
Code Snippet
Plaintext
players = GetPlayers();

for(i=0; i < players.size; i++)
{
    players[i] zm_equipment::give(equipment);
}

Thanks man but im currently having a glitch where sometimes the script bugs out and does not fully work and you only have to shoot 1 trigger and it gives you the Easter egg complete status. This is my code

Code Snippet
Plaintext
#using scripts\zm\_zm_weapons;
#using scripts\zm\_zm_weap_riotshield;
#using scripts\zm\_zm_equipment;

#using scripts\zm\craftables\_zm_craft_shield;

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("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();
}

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("Trigger 3 Shot"); // 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)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("Easter Egg Complete. Enjoy your new shield!");
equipment = GetWeapon("zod_riotshield");
players = GetPlayers();

for(i=0; i < players.size; i++)
{
    players[i] zm_equipment::give(equipment);
}
}

break;
}
}
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
I've noticed that when you done shooting all of the triggers only the first player gets the rewards and other three players don't. Is there a fix for this?
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 6 July 2016
Last active: 7 years ago
Posts
1
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
donovanne's Groups
donovanne's Contact & Social Links
This is the fully code if you want to get "Electric Cherry" :)

Code Snippet
Plaintext
#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("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();
}

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("Trigger 3 Shot"); // 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)
{
// 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;
}
}

Tested and it works fine ;)

This is for 3 triggers :)

Using the exact same code (other than different print messages), I'm getting the following error when linking in launcher:

^1�
^1^
^1ERR(0) scripts/custom/shootable.gsc (16,1) in "shootable_1()" : Bad Token '�' :  ^1�
^1^
^1ERR(0) scripts/custom/shootable.gsc (16,1) in "shootable_1()" : syntax error, unexpected TOKEN_ERROR : �
broken avatar :(
×
broken avatar :(
Location: us?
Date Registered: 21 August 2016
Last active: 2 years ago
Posts
80
Respect
Forum Rank
Rotting Walker
Primary Group
Member
×
All0utWar's Groups
All0utWar's Contact & Social Links
I've noticed that when you done shooting all of the triggers only the first player gets the rewards and other three players don't. Is there a fix for this?

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++)
{
//do whatever
players[i] zm_perks::give_perk( PERK_JUGGERNOG, false);
}
}

break;
}
}

I think this should work.
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
How do I make it so only a certain gun activates the shootable trigger and others don't? It would help me out a lot thanks!
broken avatar :(
×
broken avatar :(
Location: england
Date Registered: 28 November 2013
Last active: 2 months ago
Posts
44
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
×
jasonpage260's Groups
jasonpage260's Contact & Social Linksjason260xo_z_kelly
how would I go about to change this to the PowerUp free perk
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
how would I go about to change this to the PowerUp free perk

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.
broken avatar :(
×
broken avatar :(
Location: usUnited States
Date Registered: 30 March 2014
Last active: 3 years ago
Posts
25
Respect
Forum Rank
Legless Crawler
Primary Group
Member
My Contact & Social Links
More
Personal Quote
Some brown dude
Signature
Noob Map Maker & Graphic Designer
×
shaan211's Groups
Thanks a lot, should be able to add in a easter egg into my map now  :D
broken avatar :(
×
broken avatar :(
Location: ca
Date Registered: 1 August 2016
Last active: 7 years ago
Posts
7
Respect
Forum Rank
Legless Crawler
Primary Group
Member
×
Gondor's Groups
Gondor's Contact & Social Links
im having a glitch with my script where you don't need to shoot all 3 objects to get the easter egg complete. Sometimes its only 1 or 2 triggers you only need to shoot.
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
im having a glitch with my script where you don't need to shoot all 3 objects to get the easter egg complete. Sometimes its only 1 or 2 triggers you only need to shoot.

This shouldn't be possible since it checks twice if they are all activated, anyways try this.

Replace:
Code Snippet
Plaintext
function shootables_done()
{
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");
}

                break;
}
}

with:
Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

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

                        break;
}
}
}
Last Edit: October 19, 2016, 12:00:04 am by reckfullies
broken avatar :(
×
broken avatar :(
Location: us
Date Registered: 22 April 2015
Last active: 7 years ago
Posts
40
Respect
Forum Rank
Legless Crawler
Primary Group
Donator ♥
My Groups
More
My Contact & Social Links
More
Personal Quote
Level Designer
×
Taven's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Taven's Contact & Social LinkskingTavenkingTaven_Taven_TavenDevMy Site
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
Last Edit: October 20, 2016, 07:02:29 am by Taven
broken avatar :(
  • M0ul3_G4m3r
  • Deleted Member
×
broken avatar :(
M0ul3_G4m3r
This user is deleted :(
I got this error !  :o

^1}
^1^
^1ERR(6E) scripts/zm/custom/shootable.gsc (99,1)  : Compiler Internal Error :  Uninitialized local variable 'player'

Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

while(1)
{
if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("Here is your reward!");
player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );

                        break;
}
}
}
Last Edit: October 20, 2016, 05:43:50 pm by M0ul3_G4m3r
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 got this error !  :o

^1}
^1^
^1ERR(6E) scripts/zm/custom/shootable.gsc (99,1)  : Compiler Internal Error :  Uninitialized local variable 'player'

Code Snippet
Plaintext
function shootables_done()
{
self waittill(level.shootablesCollected >= level.shootablesNeeded);

while(1)
{
if(level.shootablesCollected == level.shootablesNeeded)
{
// What ever code you want to execute once all shootables are collected
IPrintLn("Here is your reward!");
player zm_perks::give_perk( PERK_ELECTRIC_CHERRY, false );

                        break;
}
}
}

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;
}
}
}
Last Edit: October 20, 2016, 06:11:13 pm by reckfullies

 
Loading ...