UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: HyperFirez on January 02, 2017, 05:02:02 am

Title: How do you specify a player?
Post by: HyperFirez on January 02, 2017, 05:02:02 am
In my script I am trying to get a specific player to be teleported when they activate the "Anywhere But Here" gobblegum. I tired using player = getplayers(); but that is giving me a syntax error...
Title: Re: How do you specify a player?
Post by: death_reaper0 on January 02, 2017, 07:04:57 am
In my script I am trying to get a specific player to be teleported when they activate the "Anywhere But Here" gobblegum. I tired using player = getplayers(); but that is giving me a syntax error...

if its from anywhere but here you should have the player activating it calling the script already. just have the player running it as "self"
Title: Re: How do you specify a player?
Post by: HyperFirez on January 02, 2017, 04:34:02 pm
if its from anywhere but here you should have the player activating it calling the script already. just have the player running it as "self"
Thanks man. I saw your "Nightclub" map & I love your Gobblegum system! Would it be possible to do a system like in Bo3 with menus instead of loading another map? (I'll do it either way, I am just curious).

Double Post Merge: January 02, 2017, 04:39:54 pm
Right now I have a struct with the targetname "abh_tele". Would I use getEnt to get the location's name? (This is my entire script if it helps any: http://paste.md-5.net/qinocenixo.coffee (http://paste.md-5.net/qinocenixo.coffee)) (Also, sorry for all the questions)
Title: Re: How do you specify a player?
Post by: death_reaper0 on January 02, 2017, 07:01:10 pm
id say do it like this

Code Snippet
Plaintext

anywhere_but_here()
{
iprintln("anywhere_but_here function activated");

abh_tele = getentarray("abh_tele","targetname");
teleport_points = [];
//if no telepoints are active, teleport to own location to avoid errors
tele_point = self.origin;
//filter out undiscovered telepoints
for( i = 0; i < abh_tele.size; i++ )
{
if(isdefined(abh_tele[i].is_activated) && abh_tele[i].is_activated)
teleport_points[teleport_points.size] = abh_tele[i];
}

if(isdefined(teleport_points) && teleport_points.size > 0)
tele_point = teleport_points[RandomInt( teleport_points.size )];
wait(1);

self setOrigin(tele_point.origin);
}

anywhere_but_here_init()
{
abh_tele = getentarray("abh_tele","targetname");
for( i = 0; i < abh_tele.size; i++ )
{
abh_tele[i].is_activated = false;
abh_tele[i] thread anywhere_but_here_activate();
}
}

anywhere_but_here_activate()
{
while(1)
{

players = get_players();
for( i = 0; i < players.size; i++ )
if(distance(players[i].origin, self.origin) < 64)
{
self.is_activated = true;
break;
}
wait .1;
}
}

and call anywhere_but_here_init(); from the scripts init, or wherever so it starts when the level does. i'm pretty tired right now (just pulled an all nighter) so there may be a script error. anyway, that ent you were using, make sure its a script origin and you can have as many as you want, it will only teleport the player to any "activated" ones (ones a player has been near at some point) because of that, you should have like, one per room and make sure it isnt too close to another zone, or on the edge of one, should be somewhere the player is likely to walk across
Title: Re: How do you specify a player?
Post by: HyperFirez on January 02, 2017, 07:59:14 pm
Thanks for your help!

EDIT: Bad Syntax on: abh_tele = GetEntArray("abh_tele","targetname");
EDIT2: I moved abh_tele = ... above teleport_points = [], and now it is saying bad syntax on teleport_points = [];
Title: Re: How do you specify a player?
Post by: BluntStuffy on January 02, 2017, 09:25:20 pm
Thanks for your help!

EDIT: Bad Syntax on: abh_tele = GetEntArray("abh_tele","targetname");
EDIT2: I moved abh_tele = ... above teleport_points = [], and now it is saying bad syntax on teleport_points = [];

This line is missing a semicolon ;  That's why you get the error

Code Snippet
Plaintext
	iprintln("anywhere_but_here function activated")
Title: Re: How do you specify a player?
Post by: HyperFirez on January 02, 2017, 09:48:32 pm
This line is missing a semicolon ;  That's why you get the error

Code Snippet
Plaintext
	iprintln("anywhere_but_here function activated")
Haha! I didn't even notice it!  :lol:
Title: Re: How do you specify a player?
Post by: death_reaper0 on January 02, 2017, 09:54:57 pm
Haha! I didn't even notice it!  :lol:
partly my fault derp, but that bit was copied from your code so i kinda overlooked it
Title: Re: How do you specify a player?
Post by: HyperFirez on January 02, 2017, 10:03:28 pm
partly my fault derp, but that bit was copied from your code so i kinda overlooked it
No worries. When I do go in game, it says that the function is activated, but nothing happens. (I have a script_origin with the targetname: abh_tele)
Title: Re: How do you specify a player?
Post by: death_reaper0 on January 03, 2017, 06:30:31 am
No worries. When I do go in game, it says that the function is activated, but nothing happens. (I have a script_origin with the targetname: abh_tele)
looking at the script, theres nothing calling it,
change
Code Snippet
Plaintext
thread anywhere_but_here();

to
Code Snippet
Plaintext
player thread anywhere_but_here();
also with how you set it up its gonna happen as soon as its taken from the machine
Title: Re: How do you specify a player?
Post by: HyperFirez on January 03, 2017, 07:32:33 am
also with how you set it up its gonna happen as soon as its taken from the machine
I did that so it doesn't randomize the chances to get it & I can directly test a specific one.

Double Post Merge: January 03, 2017, 01:33:34 pm
It works now, thanks again!