Script to repair/refuel all vehicles

pegruder

Member
Is there a script to repair/refuel all vehicles? I like when I start a new "Dayz" world that all the vehicles are working with at least some gas, and then let the world run its course of destruction. Is there a custom function to implement this?
 
I've added this before last "END" in pMain:

#repair all vehicles
update object_data set hitpoints="[]", fuel=1, damage=0.01;
So, my pMain now looks like (see at bottom):
Code:
CREATE DEFINER=`dayz`@`localhost` PROCEDURE `pMain`(IN `i` INT)
    MODIFIES SQL DATA
BEGIN

# maximum number of INSTANCE id's USED.
#-----------------------------------------------
    DECLARE sInstance VARCHAR(8) DEFAULT i;
#-----------------------------------------------
#maximum number of vehicles allowed !!! theoretical max. amount
#-----------------------------------------------
    DECLARE iVehSpawnMax INT DEFAULT 300;
#-----------------------------------------------  

# DECLARE iVehSpawnMin                INT DEFAULT 0;        #ToDo !!!
    DECLARE iTimeoutMax                 INT DEFAULT 250;    #number of loops before timeout
    DECLARE iTimeout                         INT DEFAULT 0;        #internal counter for loops done; used to prevent infinite loops - DO NOT CHANGE
    DECLARE iNumVehExisting         INT DEFAULT 0;        #internal counter for already existing vehicles - DO NOT CHANGE
    DECLARE iNumClassExisting     INT DEFAULT 0;        #internal counter for already existing class types - DO NOT CHANGE
    DECLARE i INT DEFAULT 1; #internal counter for vehicles spawns - DO NOT CHANGE

#Starts Cleanup
    CALL pCleanup();
  
        SELECT COUNT(*)                 #retrieve the amount of already spawned vehicles...
            INTO iNumVehExisting
            FROM Object_DATA
            WHERE Instance = sInstance
            AND Classname != '-'                        #exclude dummys
            AND Classname != 'Hedgehog_DZ'            #exclude hedgehog
            AND Classname != 'Wire_cat1'                #exclude wirecat
            AND Classname != 'Sandbag1_DZ'            #exclude Sanbag
            AND Classname != 'BearTrap_DZ'            #exclude trap
            AND Classname != 'TentStorage';        #exclude TentStorage

        WHILE (iNumVehExisting < iVehSpawnMax) DO        #loop until maximum amount of vehicles is reached

            #select a random vehicle class
            SELECT Classname, Chance, MaxNum, Damage
                INTO @rsClassname, @rsChance, @rsMaxNum, @rsDamage
                FROM object_classes ORDER BY RAND() LIMIT 1;

            #count number of same class already spawned
            SELECT COUNT(*)
                INTO iNumClassExisting
                FROM Object_DATA
                WHERE Instance = sInstance
                AND Classname = @rsClassname;

            IF (iNumClassExisting < @rsMaxNum) THEN

                IF (rndspawn(@rschance) = 1) THEN
              
                    INSERT INTO Object_DATA (ObjectUID, Instance, Classname, Damage, CharacterID, Worldspace, Inventory, Hitpoints, Fuel, Datestamp)
                        SELECT ObjectUID, sInstance, Classname, RAND(@rsDamage), '0', Worldspace, Inventory, Hitpoints, RAND(1), SYSDATE()
                            FROM object_spawns
                            WHERE Classname = @rsClassname
                                AND NOT ObjectUID IN (select objectuid from Object_DATA where instance = sInstance)
                            ORDER BY RAND()
                            LIMIT 0, 1;
                          
                    SELECT COUNT(*)
                        INTO iNumVehExisting
                        FROM Object_DATA
                        WHERE Instance = sInstance
                            AND Classname != '-'                        #exclude dummys
                            AND Classname != 'Hedgehog_DZ'            #exclude hedgehog
                            AND Classname != 'Wire_cat1'                #exclude wirecat
                            AND Classname != 'Sandbag1_DZ'            #exclude Sanbag
                            AND Classname != 'BearTrap_DZ'            #exclude trap
                            AND Classname != 'TentStorage';        #exclude TentStorage
      
                    #update number of same class already spawned
                    SELECT COUNT(*)
                        INTO iNumClassExisting
                        FROM Object_DATA
                        WHERE Instance = sInstance
                        AND Classname = @rsClassname;
              
                END IF;
            END IF;  
          
            SET iTimeout = iTimeout + 1; #raise timeout counter
            IF (iTimeout >= iTimeoutMax) THEN
                SET iNumVehExisting = iVehSpawnMax;
            END IF;
        END WHILE;
    SET i = i + 1;
#repair all vehicles
update object_data set hitpoints="[]", fuel=1, damage=0.01;
END
 
Back
Top