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

Flashlight

broken avatar :(
Created 13 years ago
by Ege115
0 Members and 1 Guest are viewing this topic.
4,519 views
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Hello everyone!

In my map I want a light that follows the player that is representing a flashlight, I got this script from zombiemodding that Yaphil made, and that was only for if you wanted the light all the time in a game if you putted the script in mapname.gsc under zombiemode::main but in my map I want the light to activate when activating a trigger, so I have been editing the script a little so it is in a gsc file itself and then I putted the line in mapname.gsc so the map connects to the script, Hope you know what I mean.
The map is loading, yes that is great, but when activating the trigger the light does'nt show up. Any ideas?

But I tested to only put the script normally as Yaphil said in mapname.gsc and then it worked but that is not when activating a trigger. But this is how the light script looks like when I edit it.


Code Snippet
Plaintext
#include common_scripts\utility;
#include maps\_utility;
#include maps\_zombiemode_utility;

flashlight()
{
level._effect ["flashlight"] = loadFX ("env/light/fx_lights_lantern_on"); //this may need to go in building horror.gsc in the fx section
trigger = getent ("flashlight" , "targetname");
trigger SetCursorHint( "HINT_NOICON" );
trigger SetHintString( "Press &&1 to pick up flashlight." );
trigger waittill ("trigger", user); //
players = get_players();
for(i = 0; i < players.size; i++)
{
// Places the FX roughly at half of the player's height
ent = Spawn("script_model", players.origin + (32, 0, 0));
ent SetModel("tag_origin");
playFxOnTag(level._effect["fx_lights_lantern_on"], ent, "tag_origin");
ent LinkTo(players);
trigger delete();

}
}
//the end

Post Merge: November 29, 2013, 02:35:25 pm
Opps I am so sorry that I did not place the script in a script window, I did that but for some reason it did'nt do it, sorry.
Last Edit: November 29, 2013, 08:33:45 pm by SajeOne
broken avatar :(
  • DeletedUser
  • Deleted Member
×
broken avatar :(
DeletedUser
This user is deleted :(
you cant link entities to a whole array of entities.
replace this:
Code Snippet
Plaintext
ent LinkTo(players);
with this:
Code Snippet
Plaintext
for(i = 0;i<players.size;i++)
{
  ent LinkTo(players[i]);
}
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
I'm pretty sure I wouldn't have made such a mistake. Must've somehow been lost while copying / editing the code.
Also, Ray, while your answer is generally not wrong, there already is a loop over the players in this piece of code, so you shouldn't do another loop inside the first one.
Here's my original post on ZM with the correct code:
http://www.zombiemodding.com/index.php?topic=13068.msg129452#msg129452
EDIT: Just noticed, in that post, I indeed did put the indexers for the players array. So they really must've been lost somehow.

- Phil.
Last Edit: November 29, 2013, 03:37:32 pm by YaPh1l
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
I tested your idea Ray but there are still no light, maybe the fx I have in this script is not good, maybe I should find an another fx.
Or could it be something wrong with this line that I have to adjust the numbers a little. Am I wrong? propably........
ent = Spawn("script_model", players.origin + (32, 0, 0));

Or does it even work to have this light script with a trigger in a gsc itself?
Or does this only work with the way as you Phil said at zombiemodding?
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Yes, it will work with a trigger too. Also
Code Snippet
Plaintext
(32, 0, 0)
will not have the FX's height adjusted, but you might want to not have the FX at height 0.

- Phil.
broken avatar :(
×
broken avatar :(
Location: kh
Date Registered: 9 August 2013
Last active: 7 years ago
Posts
503
Respect
Forum Rank
Zombie Enslaver
Primary Group
Member
×
codmoddd1234's Groups
codmoddd1234's Contact & Social Links
fix these and it should work

//
Code Snippet
Plaintext
players.origin[i]
playFxOnTag(level._effect["flashlight"], ent, "tag_origin");
Last Edit: November 29, 2013, 05:05:11 pm by codmoddd1234
broken avatar :(
×
broken avatar :(
Location: de
Date Registered: 6 August 2012
Last active: 6 years ago
Posts
277
Respect
Forum Rank
Mr. Elemental
Primary Group
Scripter Elite
My Groups
More
×
YaPh1l's Groups
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
YaPh1l's Contact & Social Links
Code Snippet
Plaintext
players.origin[i]
That's wrong. At least for what this code is supposed to do.

- Phil.
broken avatar :(
×
broken avatar :(
Location: se
Date Registered: 30 July 2013
Last active: 2 years ago
Posts
517
Respect
Forum Rank
Zombie Enslaver
Primary Group
Scripter
My Groups
More
My Contact & Social Links
More
×
Ege115's Groups
Scripter Has shown effort and knowledge in the area of scripting while being a part of the UGX-Mods community.
Ege115's Contact & Social LinksEge115
Hmm, there has to be something that is not right with this script, maybe it is just some simple fix that we have'nt thought about.

It is working if you just put the regular one of the script in the mapname.gsc, it is like the script just refuse to work the way I want it to work.

 
Loading ...