Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- LoadMap(mapfile[])
- {
- new Tempo = GetTickCount();
- if(!fexist(mapfile)) return false;
- new File:Arquivo;
- Arquivo = fopen(mapfile, io_read);
- new Linha, Objeto[500], Objetos[2], Removidos, tipo;
- while(fread(Arquivo, Objeto))
- {
- StripNewLine(Objeto);
- if(strfind(Objeto, !"CreateObject(", true) != -1)
- {
- strdel(Objeto, 0, 13);
- tipo = 1;
- }
- if(strfind(Objeto, !"CreateDynamicObject(", true) != -1)
- {
- strdel(Objeto, 0, 20);
- tipo = 2;
- }
- if(strfind(Objeto, !"RemoveBuilding(", true) != -1)
- {
- strdel(Objeto, 0, 15);
- tipo = 3;
- }
- if(strfind(Objeto, !");", true) != -1)
- {
- new local = strfind(Objeto, !");", true);
- strdel(Objeto, local, 500);
- }
- switch(tipo)
- {
- case 1: // CreateObject
- {
- new Float:Pos[6], ObjetoModel, Float:DDistancia = 0.0;
- sscanf(!"p<,>dfffffff", ObjetoModel, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ObjetoModel, DDistancia);
- new Foi = -1;
- Foi = CreateObject(modelid, ObjetoModel, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ObjetoModel, DDistancia);
- if(Foi != -1) Objetos[0]++;
- }
- case 2: // CreateDynamicObject
- {
- new Float:Pos[6], ObjetoModel, World = -1, Interior = -1, playerid = -1, Float:SDistancia = 200.0, Float:DDistancia = 0.0;
- sscanf(!"p<,>dffffffdddff", ObjetoModel, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ObjetoModel, World, Interior, playerid, SDistancia, DDistancia);
- new Foi = -1;
- Foi = CreateDynamicObject(modelid, ObjetoModel, Pos[0], Pos[1], Pos[2], Pos[3], Pos[4], Pos[5], ObjetoModel, World, Interior, playerid, SDistancia, DDistancia);
- if(Foi != -1) Objetos[1]++;
- }
- case 2: // RemoveBuilding
- {
- new Float:Pos[3], Float:_Pos[3], Float:Radius = 0.25;
- sscanf(!"p<,>dfffffff", ObjetoModel, Pos[0], Pos[1], Pos[2], Radius, _Pos[0], _Pos[1], _Pos[2]);
- new Foi = -1;
- Foi = RemoveBuilding(ObjetoModel, Pos[0], Pos[1], Pos[2], Radius, _Pos[0], _Pos[1], _Pos[2]);
- if(Foi != -1) Removidos++;
- }
- }
- }
- fclose(Arquivo);
- printf(!"[%d] Objetos criados || [%d] DynamicObjetos criados || [%d] Objetos removidos. em %dms", Objetos[0], Objetos[1], Removidos, Tempo - GetTickCount());
- return true;
- }
- StripNewLine(string[]) //DracoBlue (bugfix idea by Y_Less)
- {
- new len = strlen(string);
- if (string[0]==0) return ;
- if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) {
- string[len - 1] = 0;
- if (string[0]==0) return ;
- if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement