Advertisement
Day_Mito

Carregar Objetos

Jun 12th, 2015
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.51 KB | None | 0 0
  1. LoadMap(mapfile[])
  2. {
  3.     new Tempo = GetTickCount();
  4.     if(!fexist(mapfile)) return false;
  5.     new File:Arquivo;
  6.     Arquivo = fopen(mapfile, io_read);
  7.  
  8.     new Linha, Objeto[500], Objetos[2], Removidos, tipo;
  9.     while(fread(Arquivo, Objeto))
  10.     {
  11.         StripNewLine(Objeto);
  12.         if(strfind(Objeto, !"CreateObject(", true) != -1)
  13.         {
  14.             strdel(Objeto, 0, 13);
  15.             tipo = 1;
  16.         }
  17.         if(strfind(Objeto, !"CreateDynamicObject(", true) != -1)
  18.         {
  19.             strdel(Objeto, 0, 20);
  20.             tipo = 2;
  21.         }
  22.         if(strfind(Objeto, !"RemoveBuilding(", true) != -1)
  23.         {
  24.             strdel(Objeto, 0, 15);
  25.             tipo = 3;
  26.         }
  27.         if(strfind(Objeto, !");", true) != -1)
  28.         {
  29.             new local = strfind(Objeto, !");", true);
  30.             strdel(Objeto, local, 500);
  31.         }
  32.         switch(tipo)
  33.         {
  34.             case 1: // CreateObject
  35.             {
  36.                 new Float:Pos[6], ObjetoModel, Float:DDistancia = 0.0;
  37.                 sscanf(!"p<,>dfffffff", ObjetoModel, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ObjetoModel, DDistancia);
  38.                 new Foi = -1;
  39.                 Foi = CreateObject(modelid, ObjetoModel, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ObjetoModel, DDistancia);
  40.                 if(Foi != -1) Objetos[0]++;
  41.             }
  42.             case 2: // CreateDynamicObject
  43.             {
  44.                 new Float:Pos[6], ObjetoModel, World = -1, Interior = -1, playerid = -1, Float:SDistancia = 200.0, Float:DDistancia = 0.0;
  45.                 sscanf(!"p<,>dffffffdddff", ObjetoModel, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ObjetoModel, World, Interior, playerid, SDistancia, DDistancia);
  46.                 new Foi = -1;
  47.                 Foi = CreateDynamicObject(modelid, ObjetoModel, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ObjetoModel, World, Interior, playerid, SDistancia, DDistancia);
  48.                 if(Foi != -1) Objetos[1]++;
  49.             }
  50.             case 2: // RemoveBuilding
  51.             {
  52.                 new Float:Pos[3], Float:_Pos[3], Float:Radius = 0.25;
  53.                 sscanf(!"p<,>dfffffff", ObjetoModel, Pos[0], Pos[1], Pos[2], Radius, _Pos[0], _Pos[1], _Pos[2]);
  54.                 new Foi = -1;
  55.                 Foi = RemoveBuilding(ObjetoModel, Pos[0], Pos[1], Pos[2], Radius, _Pos[0], _Pos[1], _Pos[2]);
  56.                 if(Foi != -1) Removidos++;
  57.             }
  58.         }
  59.     }
  60.     fclose(Arquivo);
  61.  
  62.     printf(!"[%d] Objetos criados || [%d] DynamicObjetos criados || [%d] Objetos removidos. em %dms", Objetos[0], Objetos[1], Removidos, Tempo - GetTickCount());
  63.     return true;
  64. }
  65.  
  66. StripNewLine(string[]) //DracoBlue (bugfix idea by Y_Less)
  67. {
  68.     new len = strlen(string);
  69.     if (string[0]==0) return ;
  70.     if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) {
  71.         string[len - 1] = 0;
  72.         if (string[0]==0) return ;
  73.         if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0;
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement