Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //FILE NAME
- $filename = "base.sqf";
- //OPEN FILE
- $handle = fopen($filename, "r");
- //GET FILE CONTENTS INTO STRING
- $contents = fread($handle, filesize($filename));
- //CLOSE FILE
- fclose($handle);
- //TEXT TO SEARCH FOR
- $findme = "AH1Z";
- //GET POSITION OF TEXT/CHECK IF EXISTS IN FILE CONTENTS STRING
- $pos = strpos($contents, $findme);
- //IF RESULT NOT FALSE
- if ($pos === false) {
- echo "The string '$findme' was not found in the string '$contents'";
- } else {
- //FOUND THE AH1Z!
- echo "The string '$findme' was found in the string!";
- echo " and exists at position $pos";
- //NOW WE NEED TO FIND THE CLOSING }; OF THIS VEHICLE
- $findme = "};";
- //THIS POSITION IS THE END OF THAT VEHICLES SECTION, USING $POS AS THE STARTING OFFSET TO START SEARCHING FROM
- $pos2 = strpos($contents, $findme2, $pos);
- //NOW WE CAN USE FSEEK TO SEEK TO 1 CHARACTER BEFORE POS2
- $file = fopen($filename, "c");
- fseek(($file, -3, ($pos2 - 1));
- fwrite($file, "VEHICLE REMOVE WEAPON BLA BLA");
- fclose($file);
- }
Advertisement
Add Comment
Please, Sign In to add comment