Announcement

Collapse
No announcement yet.

[Help] Basic Vehicle Respawn Script [.sqf]

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [Help] Basic Vehicle Respawn Script [.sqf]

    Hi Guys.
    I need some help with scripting, I'm totally new to it, but I have basic understanding of how scripts work.

    Currently I'm trying to do a respwan script. I try to do one myself, because I want to learn, I'm not looking for a finished script.
    If somebody has one, thats fine, would be cool if you could explain the basics of that script.

    I tried writing one myself, but it doesn't works. I get no error ingame or in "arma2oa.prt"

    Code:
    private ["_vehicle","_startpos","_startdir","_type","_damage"];
    if (!isServer) exitWith{};
    
    _vehicle = vehicle _this;
    _startpos = getpos _vehicle;
    _startdir = getdir _vehicle;
    _type = typeOf _this;
    _damage = if (getDammage _vehicle > 0) then {true} else {false};
    
    
    if (_damage) then { _new = _type createvehicle _startpos };
    In the Editor, I added the scriptline to one vehicle:
    Code:
    this exec "respawn_vehicles.sqf"
    The function I want to create should be very simple (for the beginning);
    - I have vehicles on the map (lets say "vehicle1", "vehicle2", "vehicle3").
    - I want them to respawn on their original Spawnposition, if they get destroyed (maybe 15 seconds delay).
    - After respawn, I want them to have the same name, and be able to respawn again (unlimited).

    It would be really awesome if somebody can help me =)

    Thank you and greetings
    Andy

  • #2
    Re: [Help] Basic Vehicle Respawn Script [.sqf]

    There's already a script out there that does pretty much this. Or something like. Not saying use it, but might be worth looking at the coding within the file and stealing some of the stuff out of it. Just back engineered a weird vehicle respawn version of it a while ago (still not working perfectly as intended, but getting there). I think the file's in the script bin part of the forums.

    Pepper

    "If you find yourself in a fair fight, you didn't plan your mission properly." David Hackworth

    Comment


    • #3
      Re: [Help] Basic Vehicle Respawn Script [.sqf]

      http://community.bistudio.com/wiki/respawnVehicle

      ?

      Very simple. Put a marker down, put the code in the units init and set the respawn delay time and number of respawns allowed for that vehicle. (0= unlimited)
      sigpic


      Do you really want invincible bears running around raping your churches and burning your women?

      Intel i7 3930k @ 4.4ghz, 8gb RAM, 2x GTX 570 1gb, OCZ Vertex 3 120 gig SSD

      Comment


      • #4
        Re: [Help] Basic Vehicle Respawn Script [.sqf]

        Thank you for your answers!

        But I still want to try to code it "myself" xD
        I want to learn, and best way is "learning by doing" (and asking people xD)
        I have already looked in Google alot, but only found finished scripts, which I tried to "back engineer", but they stopped working. (Most use many parameters, like "is Vehicle Empty?", "is Vehicle away from Base?", "is Vehicle damaged?". My intend is to just respawn it when destroyed. Later maybe add the function to keep the wreck, and add delay etc. For the beginning, I'm fine with making a very basic respawn. Sadly my "back engineered" scripts stopped working)
        If somebody could explain me a very simple and basic script, it would help me alot!
        My intend is not to use finished script, I want to learn how they work, and want to be able to write basic stuff myself. Of course I'm aware of scripting is nothing to learn "in a few weeks", but at some point you need to start and practice :D

        Thanks for the help!


        Greetings
        Andy

        PS: Will search in the TG Forums. If somebody has the link, feel free to post it :D Thank you!

        Comment


        • #5
          Re: [Help] Basic Vehicle Respawn Script [.sqf]

          the code you posted only runs once at maps start. You need to put it in some form of loop to see if the vehicle needs to be respawned. Also a side note don't assign a bool variable a value from an if statement only to use it in another if statement, do it with only one like this.
          Code:
          if (getDammage _vehicle > 0) then { _new = _type createvehicle _startpos } ;
          and to have it run set repeatedly use put the if statement in a while statement.

          Comment


          • #6
            Re: [Help] Basic Vehicle Respawn Script [.sqf]

            Thanks for your help.

            But still doesn't works.
            Code looks currently like this:
            Code:
            private ["_vehicle","_startpos","_startdir","_type","_new"];
            if (!isServer) exitWith{};
            
            _vehicle = vehicle _this;
            _startpos = getpos _vehicle;
            _startdir = getdir _vehicle;
            _type = typeOf _this;
            
            while {true} do { if (getDammage _vehicle > 0) then { _new = _type createvehicle _startpos } ; } ;
            No Errors ingame, just don't respawns the vehicle. Have completly destroyed it, exploded, but doesn't respawn.

            Also, if I use the following code (editing with Notepad ++)...

            Code:
            while {true} do { 
            if (getDammage _vehicle > 0) then { _new = _type createvehicle _startpos } ; 
            } ;
            It shows me an error...
            Code:
            Error in expression <} ;>
              Error position: <} ;>
              Error Missing {

            Comment


            • #7
              Re: [Help] Basic Vehicle Respawn Script [.sqf]

              use execVM not exec. also there is built in functionality for this behavior http://community.bistudio.com/wiki/respawnVehicle

              Comment

              Connect

              Collapse

              TeamSpeak 3 Server

              Collapse

              Advertisement

              Collapse

              Twitter Feed

              Collapse

              Working...
              X