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

script help D:

broken avatar :(
Created 12 years ago
by jjbradman
0 Members and 1 Guest are viewing this topic.
3,443 views
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
i made this trying to script an heli but it it gives me tons of error like uninitialized variable player,helicopter, etc,etc, can some help me find whats wrong with it? :(

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

init()
{
self.heli_cost = 500;
helicopter = getEnt("helicopter","targetname");
path = getEnt("moveto","targetname");
trig = getEntArray("cop_trig","targetname");

thread helicopter_think(trig);
}

helicopter_think(trig)
{
while(1)
{
players = get_players();
for(i=0;i<players.size;i++)

trig waittill("trigger",player);
{
player PlayerLinkTo(helicopter);
self.current_weapon = player GetCurrentWeapon();
player giveweapon("panzerschrek_zombie_upgraded");
player SwitchToWeapon("panzerschrek_zombie_upgraded");
player DisableWeaponCycling();
player EnableInvulnerability();
player HideViewModel();

helicopter MoveZ(700,10,1,1);

wait 5;

helicopter MoveTo(path,20,1,1);

wait 5;

player takeweapon("panzerschrek_zombie_upgraded");
player SwitchToWeapon(self.current_weapon);
player EnableWeaponCycling();
player DisableInvulnerability();
player ShowViewModel();
player Unlink();

wait 30;
}
}
}

nevermind fixed all syntax problems by changing
Code Snippet
Plaintext
player
to
Code Snippet
Plaintext
players[i]

but the script doent work how i wanted D: the heli just moves at game game start without me going to the trig :l
Last Edit: January 16, 2014, 03:40:23 am by jjbradman
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
Signature
Let's keep this thread on topic from here on in. -DBZ

+1 to off-topic reply -DBZ

lmao. Too funny.

Goliath Script Placer: http://ugx-mods.com/forum/index.php/topic,11234.msg125257/topicseen.html#new

"...Christ, people. Learn C, instead of just stringing random characters
together until it compiles (with warnings)..."

-Linus Torvalds
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
The helicopter variable isn't being passed through to the other functions. Just pass it through like you did with the trig.

If your going to use get_players(); function, then you need to either specify which player your executing the code on(Player[0], player[1], etc), or put all the players in an array(player). Also, you used "player" as a variable when you actually need "players"(What you declared at get_players();)

if the variable "path" represents the helicopters path, then it should be an array so that it gets all the script_structs needed.

I believe that you need to have an () around the seconds that you need to wait, not just wait 5; or whatever.

EDIT: not sure why its using italics.
Last Edit: January 16, 2014, 03:45:59 am by daedra descent
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
ok heres my changes .-. hahaha im still a noob at scripting
path is just one struct, thats why i dont need an array...for now xs
it doesnt gives me syntax error with "wait" like that  :P
Last Edit: January 16, 2014, 04:11:50 am by jjbradman
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

init()
{
path = getEnt("moveto","targetname");
helicopter = getEnt("helicopter","targetname");
trig = getEnt("cop_trig","targetname");
array_thread(trig,helicopter,path::helicopter_think);
}

helicopter_think(trig)
{
while(1)
{
players = get_players();
for(i=0;i<players.size;i++)

trig waittill("trigger",player);
{
players[i] PlayerLinkTo(helicopter);
self.current_weapon = players[i] GetCurrentWeapon();
players[i] giveweapon("panzerschrek_zombie_upgraded");
players[i] SwitchToWeapon("panzerschrek_zombie_upgraded");
players[i] DisableWeaponCycling();
players[i] EnableInvulnerability();
players[i] HideViewModel();

helicopter MoveZ(700,10,1,1);

wait 5;

helicopter MoveTo(path,20,1,1);

wait 5;

players[i] takeweapon("panzerschrek_zombie_upgraded");
players[i] SwitchToWeapon(self.current_weapon);
players[i] EnableWeaponCycling();
players[i] DisableInvulnerability();
players[i] ShowViewModel();
players[i] Unlink();

wait 30;
}
}
}

ok heres my changes .-. hahaha im still a noob at scripting
path is just one struct, thats why i dont need an array...for now xs
it doesnt gives me syntax error with "wait" like that  :P

Oh, i guess you can use it either way.

I don't know why the trig is going off before you use it, maybe you could use a level notify and level waittill instead, not sure if it would fix the issue any.
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
ok everything is fine except once i use the trigger it doesnt link the player to the script_model of the helicopter , do you know whats wrong? TnT
Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

init()
{
path = getEnt("moveto","targetname");
helicopter = getEnt("helicopter","targetname");
trig = getEnt("cop_trig","targetname");
thread helicopter_think(trig,helicopter,path);
}

helicopter_think(trig,helicopter,path)
{
while(1)
{
players = get_players();
for(i=0;i<players.size;i++)

trig waittill("trigger",player);
{
players[i] PlayerLinkTo(helicopter);
self.current_weapon = players[i] GetCurrentWeapon();
players[i] giveweapon("panzerschrek_zombie_upgraded");
players[i] SwitchToWeapon("panzerschrek_zombie_upgraded");
players[i] DisableWeaponCycling();
players[i] EnableInvulnerability();
players[i] HideViewModel();

helicopter MoveZ(700,10,1,1);

wait 1;

helicopter MoveTo(path,10,1,1);

wait 1;

players[i] takeweapon("panzerschrek_zombie_upgraded");
players[i] SwitchToWeapon(self.current_weapon);
players[i] EnableWeaponCycling();
players[i] DisableInvulnerability();
players[i] ShowViewModel();
players[i] Unlink();

wait 30;
}
}
}
broken avatar :(
×
broken avatar :(
☭ Soviet Commander ☭
Location: us
Date Registered: 13 August 2012
Last active: 10 years ago
Posts
2,789
Respect
Forum Rank
King of the Zombies
Primary Group
Community Daedra
My Groups
More
My Contact & Social Links
More
×
daedra descent's Groups
Community Daedra
Community Daedra
daedra descent's Contact & Social LinksBlueSoviet
No i don't, sorry.
broken avatar :(
×
broken avatar :(
drago
Location: mx
Date Registered: 5 July 2013
Last active: 7 years ago
Posts
941
Respect
Forum Rank
The Decider
Primary Group
Member
My Contact & Social Links
More
×
jjbradman's Groups
jjbradman's Contact & Social Linksjjbradmanjjbradmanjjbradman
No i don't, sorry.

thats all i want to fix by now :L how do i link player to 1 place
cause my map will have an heli and i want to lock players movement in an origin to give them a weapon yo shot while in heli.
as for the heli to move i'll use vehicle paths which makes things way easier xL
broken avatar :(
×
broken avatar :(
Former UGX Lead Asset Creator
Location: ca
Date Registered: 17 August 2012
Last active: 7 years ago
Posts
1,932
Respect
Forum Rank
Zombie Destroyer
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
Personal Quote
Eh?
Signature

(Click to enter portfolio)
×
SajeOne's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
thats all i want to fix by now :L how do i link player to 1 place
cause my map will have an heli and i want to lock players movement in an origin to give them a weapon yo shot while in heli.
as for the heli to move i'll use vehicle paths which makes things way easier xL
Make sure there isn't anything in between the for loop and the brace:

Probably would be why as i would be undefined(although you would think there would be a script error). Either way if there still is problems just post back.

Also you don't want to put extensive waits inside your for loop. For this instance what will happen is player[0] will have all those actions set, then 30 seconds later player[1] will have those actions set. It's a for loop which means it's not going to loop through the next player until it reaches the end of the loop, which isn't possible in an unnoticeable time when there is a 30 second wait.
broken avatar :(
×
broken avatar :(
Location: gbComing up in the world
Date Registered: 26 November 2013
Last active: 11 years ago
Posts
325
Respect
Forum Rank
Perk Hacker
Primary Group
Scripter Elite
My Groups
More
My Contact & Social Links
More
Personal Quote
I own the hat!
×
DuaLVII's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Scripter Elite Has shown excellence and experience in the area of custom scripting in the UGX-Mods community.
DuaLVII's Contact & Social LinksDuaLVIIthomas.gascoigne.7DuaLVIITheProlonger
According to my knowledge of scripting so far, the player is defined from the waittill funtion.
In my eyes the for flow control isn't needed, In fact in my eyes what I'm seeing the code will be trying to do is picking someone to go in the helicopter rather than the trigger user (If that is even working as is)

In your case;
Code Snippet
Plaintext
while(1)
{
          player = undefined;
}

Code Snippet
Plaintext
trig waittill( "trigger", player );
if( is_player_valid( player ) )
{
         player playerlinkto(helicopter);
         //Rest of the function here
}

Unless your wanting all players on the helicopter, If so then the for flow control would be needed but only in specific parts where it links the players and where it unlinks the players.

Someone may correct me on this, but till then, just make a backup of what you currently have before trying this since I only wrote this from memory.

Thanks,
DuaLVII
Last Edit: January 16, 2014, 10:51:46 am by DuaLVII
broken avatar :(
×
broken avatar :(
Former UGX Lead Asset Creator
Location: ca
Date Registered: 17 August 2012
Last active: 7 years ago
Posts
1,932
Respect
Forum Rank
Zombie Destroyer
Primary Group
UGX V.I.P.
My Groups
More
My Contact & Social Links
More
Personal Quote
Eh?
×
SajeOne's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
UGX V.I.P.
UGX V.I.P.
If so then the for flow control would be needed but only in specific parts where it links the players and where it unlinks the players.
Exactly. Only have the loop where you are triggering events specific for all players. Then have your waits and other actions that don't need to happen for each player outside the for loop.

In response to the code you posted you are closer but you want the waittill to be outside the for loop, otherwise it's going to wait 4 times for each player.
Last Edit: January 16, 2014, 03:38:32 pm by SajeOne

 
Loading ...