Author Topic: onVehicleTouch  (Read 806 times)

searched on the forums, all the links are broken
apparently the old version doesn't work so if someone could make a working version that'd be great

Found Event_Vehicle, does not have onVehicleTouch, but it does have the zone input events, as well as some generic output events.
https://cdn.discordapp.com/attachments/238914176066650114/270334930637029386/Event_Vehicle.zip

I'll keep looking.

Edit: Yeah, must've been with the chunk of files I've lost. Sorry.
« Last Edit: January 15, 2017, 05:38:24 PM by Shift Kitty »

truce or eliptats did a long post a while ago why onvehicletouch was bargain binned/failbinned

its a combination of incredibly easy to forget up servers and poor support for actual vehicle contact.

thing about vehicles is there is no callback when it hits a brick, so the way it worked was it did a perpetual loop check if the vehicle bounds box intersected any bricks. this not only has it trigger onvehicletouch when the vehicle isn't actually touching the brick(s), but also makes the server lag a lot when large vehicles are on the server due to box bounds checking on a short schedule loop

nevertheless its usable, but you have to keep those issues in mind when using it

I literally found this on accident in one of my folders, it was for Xon's racing server that never took off. It has a lot of stuff you wont need in it and you probably won't understand it so you may want to talk to another modder, and have him look at, and remove the code you don't need.

Not even sure if this works 100% (as in if it's called if the vehicle is moving really slow) but figure I'd drop it anyway.


package vehicleCollisionSupport
{
   function WheeledVehicleData::OnImpact(%a,%b,%c,%d,%e,%f,%g,%h,%i)
   {
      %p = parent::OnImpact(%a,%b,%c,%d,%e,%f,%g,%h,%i);
      %vehiclePos = %b.position;
      initContainerRadiusSearch(%vehiclePos, 4, $Typemasks::fxBrickAlwaysObjectType); //Initialize container search
         
      while(isObject(%obj = containerSearchNext()))
      {
         if (%obj.getName() $= "_finishline")
         {
            %clientDriver = %b.getMountedObject(0).client;
            %score = %clientDriver.score;
            %b.spawnbrick.respawnVehicle();
            %c = getFileLineCount("config/server/Drifting/Stats.txt");
            if(%c < 20)
            {
               %hasUser = isUserInDriftFile(%clientDriver.bl_id);
               if(%hasUser > 0)
               {
                  driftFileReplaceLine(%hasUser,%score SPC %clientDriver.bl_id SPC %clientDriver.name);
               }
               else
               {
                  %f = new fileObject();
                  %f.openForAppend("config/server/Drifting/stats.txt");
                  %f.writeLine(%score SPC %clientDriver.bl_id SPC %clientDriver.name);
                  %f.close();
                  %f.delete();
               }
            }
            else
            {
               %hasUser = isUserInDriftFile(%clientDriver.bl_id);
               if(%hasUser > 0)
               {
                  %f = new fileObject();
                  %f.openForRead("config/server/Drifting/stats.txt");
                  %l=0;
                  while(!%f.isEOF())
                  {
                     %l++;
                     %line = %f.readLine();
                     if(%l == %hasUser)
                     {
                        %storedScore = getWord(%line,0);
                        if(%score > %storedScore)
                        {
                           driftFileReplaceLine(%hasUser,%score SPC %clientDriver.bl_id SPC %clientDriver.name);                           
                        }
                     }
                  }
                  %f.close();
                  %f.delete();
               }
               else
               {
                  %lowestScore = getLowestHighestScore();
                  if(%score > %lowestScore)
                  {
                     driftFileReplaceLine($lowestHighestScoreLine,%score SPC %clientDriver.bl_id SPC %clientDriver.name);
                     deleteVariables($lowestHighestScoreLine);
                  }
               }
            }
         }
      }
      return %p;
   }
};
activatePackage(vehicleCollisionSupport);