Home   Help Search Login Register  

Author Topic: Need help with at least 1 script  (Read 3774 times)

0 Members and 1 Guest are viewing this topic.

Offline Maverick2002

  • Members
  • *
Need help with at least 1 script
« on: 17 Feb 2007, 00:29:20 »
Hi!

I`m not a guru when it comes to scripting, so i wonder if anyone can help me with a few things..

1 problem:
I want spesific soldiers in a group (playable in MP) only to be able to pick up spesific weapons from crates. Like the sniper will only be able to pick up M24 and MK12 from ammo crates, the machinegunner can just pick M249 and so on...i guess i need a script?

2 problem:
In a group of 10 (also playable in MP) i want only 2 soldiers(pilots) to be able to mount helicopters as pilots. The 8 other soldiers in the group should be restricted to fly helicopters (mount them as pilots).

I have an alternative solutions, with simple triggers and "setvehiclelock" for the choppers, but it only works like 80% of what i want..

Thank you!

Offline pyro05x

  • Members
  • *
  • teh uber scriptz0r
    • My Biki user page
Re: Need help with at least 1 script
« Reply #1 on: 17 Feb 2007, 04:55:06 »
i can give you an answer for the pilot thing....

  • give each chopper a unique name.
  • create a trigger close to it.
  • set the condition to this: typeOf (driver helochopter) != 'SoldierWPilot'
  • onActivation: (driver helochopter) action ['Eject', helochopter]

basically it just makes him eject after trying to mount
« Last Edit: 18 Feb 2007, 05:40:54 by Cory B »
while {alive pyro05x} do {
    newScript = pyro05x execVM "writeScript.sqf";
    waitUntil {scriptDone newScript}; sleep 0;  };

Offline Maverick2002

  • Members
  • *
Re: Need help with at least 1 script
« Reply #2 on: 18 Feb 2007, 16:32:17 »
Thanks!

So now only pilots can mount the chopper as pilot, and denies regular soldiers?
And i guess "activation" should be set to "none" in the triggers?

Offline Maverick2002

  • Members
  • *
Re: Need help with at least 1 script
« Reply #3 on: 19 Feb 2007, 23:58:19 »
Sorry, but can anyone describe littlebit more how that works?
What is SoldierWPilot and how do i decides who can be the pilot?

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Need help with at least 1 script
« Reply #4 on: 20 Feb 2007, 01:44:59 »
You did read the post by Cory B?

Give the chopper a name in its name field via the unit placement dialog.

Create a trigger close to it.

The condition that will activate the trigger:  typeOf (driver helochopter) != "SoldierWPilot" ...helochopter presumably represents the name of the chopper given in the first step. "SoldierWPilot" is the classname of the pilot model.  So this line is checking if whoever gets in the chopper is a pilot or not.

Presuming the condition is true and the person getting in the pilots seat is not "SoldierWPilot", then the OnActivation line will run:
(driver helochopter) action ["Eject", helochopter] ... Which means he is automatically ejected.


If on the other hand the person getting into the pilots seat is "SoldierWPilot" then the trigger will not fire.....Hopefully   :dunno:  :D

Unfortunately it doesn't seem to work.


Planck
« Last Edit: 20 Feb 2007, 02:04:09 by Planck »
I know a little about a lot, and a lot about a little.

Offline pyro05x

  • Members
  • *
  • teh uber scriptz0r
    • My Biki user page
Re: Need help with at least 1 script
« Reply #5 on: 20 Feb 2007, 16:30:46 »
hmm....it should work.

make sure your pilot guy is in fact a 'SoldierWPilot'.  also make sure the chopper is named according to the commands in the trigger.

i used 'SoldierWPilot' in the example because i am assuming that you are on the west team? (usa)
while {alive pyro05x} do {
    newScript = pyro05x execVM "writeScript.sqf";
    waitUntil {scriptDone newScript}; sleep 0;  };

Offline Maverick2002

  • Members
  • *
Re: Need help with at least 1 script
« Reply #6 on: 20 Feb 2007, 17:13:10 »
No, didnt work! But this did:

Condition: !isNull driver heli1
On Activation: if(typeOf driver heli1 != "SoldierWPilot" )then{driver heli1 action["Eject",heli1]};

But thanks anyway, you got me close enough! :)

Offline pyro05x

  • Members
  • *
  • teh uber scriptz0r
    • My Biki user page
Re: Need help with at least 1 script
« Reply #7 on: 21 Feb 2007, 02:04:19 »
oh ... haha i know why it wasn't working.  if there was no driver, the trigger was active because the driver (objNull) is not the soldier.

so umm.... yeah you got it.
while {alive pyro05x} do {
    newScript = pyro05x execVM "writeScript.sqf";
    waitUntil {scriptDone newScript}; sleep 0;  };

Offline Maverick2002

  • Members
  • *
Re: Need help with at least 1 script
« Reply #8 on: 21 Feb 2007, 13:21:41 »
Ok, 1 problem solved, 1 to go! :laugh:

Anyone have ideas how i can define what weapons the different soldiers can pick up?
It`s important for my missions, that the players have regular roles in  the team. I don`t want my machinegunner suddenly running around with a M24! 8)

Offline Rawhide

  • Members
  • *
  • I'm a llama!
Re: Need help with at least 1 script
« Reply #9 on: 21 Aug 2007, 10:31:56 »
Hi all.

Condition: !isNull driver heli1
On Activation: if(typeOf driver heli1 != "SoldierWPilot" )then{driver heli1 action["Eject",heli1]};
One problem with this one; afer the helicopter has respawned, this does not work anymore. Everybody can then fly the helicopter.

Can someone please assist on how to solve that issue? Thanks in advance.


-Rawhide

Offline LCD

  • Former Staff
  • ****
    • Everon Cartel
Re: Need help with at least 1 script
« Reply #10 on: 21 Aug 2007, 10:42:30 »
Quote
the helicopter has respawned

??? is dat MP tingy ?

nywayz.... try 2 set da triger 2 repeadetly

LCD OUT
"guess being the community has downsides .." - cheetah
Help Perfecting Da Next Best Thing - O-Team Beta

Offline Rawhide

  • Members
  • *
  • I'm a llama!
Re: Need help with at least 1 script
« Reply #11 on: 21 Aug 2007, 15:02:42 »
Thanks, but it's already set to "Repeatedly". Any solution?


-Rawhide

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Need help with at least 1 script
« Reply #12 on: 21 Aug 2007, 16:10:28 »
When the helicopter respawns the new chopper no longer has the name you gave the original. How are you respawning the helicopter?
urp!

Offline Rawhide

  • Members
  • *
  • I'm a llama!
Re: Need help with at least 1 script
« Reply #13 on: 21 Aug 2007, 16:35:52 »
I'm using two different respawn scripts, for different purposes.
The two helicopters, mh6a and mh6b, uses the first one called vehiresespawn.sqs.
The Harrier uses the harrier_vrs.sqf.

The helicopters respawn script:
Quote
?! (local server): exit
~3
_vehicle = _this select 0
_delay = _this select 1
_empty = true
_disabled = false
_moved = false

_startpos = getpos _vehicle
_startdir = getdir _vehicle
_type = typeof _vehicle

#waiting
~2
_newpos = getpos _vehicle
?! (_newpos select 0 in _startpos) or not (_newpos select 1 in _startpos): _moved = true

?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not (isnull commander _vehicle): _empty = false
? (isnull driver _vehicle) and (isnull gunner _vehicle) and (isnull commander _vehicle): _empty = true

?! (canmove _vehicle) or (canfire _vehicle): _disabled = true
? (canmove _vehicle) and (canfire _vehicle): _disabled = false
? (_disabled) and (_empty): goto "spawn"
? (_moved) and (_empty): goto "spawn"
goto "waiting"

#spawn
~_delay
?! (isnull driver _vehicle) or not (isnull gunner _vehicle) or not(isnull commander _vehicle): _empty = false
?! (_empty): goto "waiting"
deletevehicle _vehicle
~0.5
_newveh = _type createvehicle _startpos
_newveh setpos _startpos
_newveh setdir _startdir
[_newveh, _delay] exec "vehirespawn.sqs"
exit

The Harrier, har1, respawnscript:
Quote
//BEGIN vrs.sqf
//By KaRRiLLioN
//IMPORTANT: ADD A GAMELOGIC NAMED Server
//to the mission to prevent multispawn

private ["_vcl","_respawndelay","_dir","_pos","_type","_run","_crewWait","_wait","_delay"];

if (!local Server) exitWith {};

_vcl = _this;
_respawndelay = 10;
_dir = Getdir _vcl;
_pos = Getpos _vcl;
_crewWait = 30;
_wait = 0;

_type = typeOf _vcl;

_run = TRUE;

sleep 1;


for [{}, {_run}, {_run}] do

{

    while {canMove _vcl && count crew _vcl < 1} do
    {
         _wait = Time + _crewWait;
         sleep 1;
    };

    while {Count crew _vcl > 0 && Alive _vcl} do
    {
         _wait = Time + _crewWait;
         sleep 1;
    };


    while {canMove _vcl && count Crew _vcl < 1 && Time < _wait} do
    {
         sleep 1;
    };

    _delay = Time + _respawnDelay;

    while {!canMove _vcl && count Crew _vcl < 1 && Time < _delay} do
    {
         sleep 1;
    };

    if (count Crew _vcl < 1) then
    {

         deleteVehicle _vcl;
         _vcl = _type createVehicle _pos;
         _vcl setdir _dir;
         sleep 1;
         _vcl setvelocity [0,0,0];
         _vcl setpos _pos;
         sleep 1;
         _vcl setvelocity [0,0,0];

//code to remove bombs and fuel following respawn
      _vcl setFuel 0.1;
      _vcl removeMagazine "6Rnd_GBU12_AV8B";
      _vcl removeMagazine "300Rnd_25mm_GAU12";
    };

};

And thanks for your interest.


-Rawhide

Offline Rawhide

  • Members
  • *
  • I'm a llama!
Re: Need help with at least 1 script
« Reply #14 on: 21 Aug 2007, 17:03:14 »
Today someone posted a similar question, or at least an option to solve the issue by bringing the name of the vehicles and the data in the initialization field to the respawned vehicle. I posted my question there as well.

Link: http://www.flashpoint1985.com/cgi-bin/ikonboard311/ikonboard.cgi?s=c62af801a454cd378c48401621ce51bf;act=ST;f=71;t=66937;st=15;r=1;&#entry1137025


-Rawhide

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Need help with at least 1 script
« Reply #15 on: 21 Aug 2007, 18:12:16 »
When respawning via a script the vehicleVarName and setVehicleVarName commands are your best friends.
urp!