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?
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
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
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
Last Edit: January 16, 2014, 04:11:50 am by jjbradman
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
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.
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
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.
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
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