Advertisement
Shiny_

Untitled

Sep 15th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.74 KB | None | 0 0
  1. // Includes:
  2.     #include <iostream>
  3.     #include <stdio.h>
  4.     #include <stdlib.h>
  5.  
  6.     /* SA:MP GDK: */
  7.     #include <sampgdk\a_players.hpp>
  8.     #include <sampgdk\a_samp.hpp>
  9.     #include <sampgdk\core.hpp>
  10.     #include <sampgdk\plugin.h>
  11.  
  12. // Macros:
  13.     #define STANDARD_EXPORT(class_name)         \
  14.         PLUGIN_EXPORT unsigned int PLUGIN_CALL Supports() {return SUPPORTS_VERSION | SUPPORTS_PROCESS_TICK;}\
  15.         PLUGIN_EXPORT bool PLUGIN_CALL Load(void ** ppData) {return class_name.Load(ppData) >= NULL;}\
  16.         PLUGIN_EXPORT void PLUGIN_CALL Unload() {class_name.Unload();}\
  17.         PLUGIN_EXPORT void PLUGIN_CALL ProcessTick() {class_name.ProcessTimers();}
  18.  
  19.     // Variables:
  20.     static ThisPlugin PSD;
  21.  
  22. // Public functions:
  23.     PLUGIN_EXPORT bool PLUGIN_CALL OnGameModeInit() {
  24.         FILE * File;
  25.         long Size;
  26.         char * buffer;
  27.         size_t result;
  28.  
  29.         File = fopen("F:\\Rockstar Games\\GTA San Andreas\\data\\handling.cfg", "r");
  30.         if(File == NULL) {
  31.             sampgdk_logprintf("NIE ZNALEZIONO PLIKU!");
  32.             //fputs("Nie znaleziono pliku!", stderr); exit(1);
  33.         }
  34.  
  35.         fseek(File, 0, SEEK_END);
  36.         Size = ftell(File);
  37.         rewind(File);
  38.  
  39.         buffer = (char *) malloc(sizeof(char) * Size);
  40.         if(buffer == NULL) {
  41.             sampgdk_logprintf("BRAK PAMIĘCI!");
  42.             //fputs("Brak pamięci!", stderr); exit(2);
  43.         }
  44.        
  45.         result = fread(buffer, 1, Size, File);
  46.         const char * shift[1000];
  47.         if(result != Size) {
  48.             if(strcmp("LANDSTAL", buffer)) {
  49.                 int k = 0;
  50.                 while(File >> shift[k]) {
  51.                     for(int i = 0; i < k; i++) {
  52.                         sampgdk_logprintf(shift[i]);
  53.                     }
  54.                 }
  55.                 sampgdk_logprintf("Odczytano plik.");
  56.             }
  57.             else sampgdk_logprintf("BŁĄD ODCZYTU PLIKU!");
  58.             //fputs("Błąd odczytu pliku!", stderr); exit(3);
  59.         }
  60.  
  61.         fclose(File);
  62.         free(buffer);
  63.         return false;
  64.     }
  65.  
  66.     STANDARD_EXPORT(PSD);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement