Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Hide dat Object by riccor
- #include <a_samp>
- #include <streamer> //http://forum.sa-mp.com/showthread.php?t=102865
- #include <sscanf2> //http://forum.sa-mp.com/showthread.php?t=120356
- #include <zcmd> //http://forum.sa-mp.com/showthread.php?t=91354
- #define OBJECTS_FILE "HDO/All_Objects.txt" //Credits to [uL]Pottus - http://forum.sa-mp.com/showthread.php?t=415397
- #define REMOVED_OBJECTS_FILE "HDO/Removed_Objects.txt"
- #define MAX_STREAM 400.0
- #define MAX_DRAW 400.0
- #define COLOR_RED 0xFF0000FF
- #define COLOR_GREEN 0x53D212FF
- #define COLOR_YELLOW 0xFFDD00FF
- #define COLOR_WHITE 0xFFFFFFFF
- #define MAX_SLOTS 36100
- new Objects[MAX_SLOTS] = {-1, ...};
- new Lods[MAX_SLOTS] = {-1, ...};
- new Text3D: Labels[MAX_SLOTS];
- public OnFilterScriptInit()
- {
- new File: file = fopen(REMOVED_OBJECTS_FILE, io_read);
- if(!file) return print("Error accessing at removed objects file!");
- new line[128], model, lod;
- while(fread(file, line, sizeof(line)))
- {
- if(sscanf(line, "p<,>dd", model, lod)) continue;
- for(new p = 0; p < MAX_PLAYERS; p++) if(IsPlayerConnected(p))
- {
- RemoveBuildingForPlayer(p, model, 0.0, 0.0, 0.0, 10000.0);
- if(lod != 65535) RemoveBuildingForPlayer(p, lod, 0.0, 0.0, 0.0, 10000.0);
- }
- }
- fclose(file);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- new File: file = fopen(REMOVED_OBJECTS_FILE, io_read);
- if(!file) return SendClientMessage(playerid, COLOR_RED, "Error accessing at removed objects file! Contact the owner.");
- new line[128], model, lod;
- while(fread(file, line, sizeof(line)))
- {
- if(sscanf(line, "p<,>dd", model, lod)) continue;
- RemoveBuildingForPlayer(playerid, model, 0.0, 0.0, 0.0, 10000.0);
- if(lod != 65535) RemoveBuildingForPlayer(playerid, lod, 0.0, 0.0, 0.0, 10000.0);
- }
- fclose(file);
- return 1;
- }
- CMD:restore(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: Only RCON admins can use this command.");
- new m;
- if(sscanf(params, "d", m)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /restore [Object Model]");
- new File: rfile = fopen(REMOVED_OBJECTS_FILE, io_read);
- if(!rfile) return SendClientMessage(playerid, COLOR_RED, "Error accessing at removed objects file! Contact the owner.");
- new line[128], model, lod, bool: flag = false;
- while(fread(rfile, line, sizeof(line)))
- {
- if(sscanf(line, "p<,>dd", model, lod)) continue;
- if(model == m)
- {
- flag = true;
- break;
- }
- }
- fclose(rfile);
- if(!flag) return SendClientMessage(playerid, COLOR_RED, "Error: The specified object model was still not removed!");
- new File: file = fopen(OBJECTS_FILE, io_read);
- if(!file) return SendClientMessage(playerid, COLOR_RED, "Error accessing at objects file! Contact the owner.");
- new Float: x, Float: y, Float: z, Float: rx, Float: ry, Float: rz, counter = 0, i = -1;
- while(fread(file, line, sizeof(line)))
- {
- i++;
- if(i >= MAX_SLOTS) break;
- if(sscanf(line, "p<,>ddffffff", model, lod, x, y, z, rx, ry, rz)) continue;
- if(model != m) continue;
- if(Objects[i] != -1) DestroyDynamicObject(Objects[i]);
- if(Lods[i] != -1) DestroyDynamicObject(Lods[i]);
- Objects[i] = CreateDynamicObject(m, x, y, z, rx, ry, rz, -1, -1, -1, MAX_STREAM);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, Objects[i], E_STREAMER_DRAW_DISTANCE, MAX_DRAW);
- if(lod != 65535)
- {
- Lods[i] = CreateDynamicObject(lod, x, y, z, rx, ry, rz, -1, -1, -1, MAX_STREAM);
- Streamer_SetFloatData(STREAMER_TYPE_OBJECT, Lods[i], E_STREAMER_DRAW_DISTANCE, MAX_DRAW);
- }
- counter++;
- }
- fclose(file);
- for(new a = 0; a < MAX_PLAYERS; a++) if(IsPlayerConnected(a)) Streamer_Update(a);
- new str[64];
- format(str, sizeof(str), "%d, %d\r\n", m, lod);
- if(fexist("tmpfile.tmp")) fremove("tmpfile.tmp");
- rfile = fopen(REMOVED_OBJECTS_FILE, io_read);
- new File: temp = fopen("tmpfile.tmp", io_write);
- while(fread(rfile, line)) if(strcmp(line, line, true)) fwrite(temp, line);
- fclose(rfile);
- fclose(temp);
- rfile = fopen(REMOVED_OBJECTS_FILE, io_write);
- temp = fopen("tmpfile.tmp", io_read);
- while(fread(temp, line)) fwrite(rfile, line);
- fclose(rfile);
- fclose(temp);
- fremove("tmpfile.tmp");
- new msg[64];
- format(msg, sizeof(msg), "Server: %d objects with model %d were restored!", counter, m);
- SendClientMessage(playerid, COLOR_YELLOW, msg);
- return 1;
- }
- CMD:remove(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: Only RCON admins can use this command.");
- new m;
- if(sscanf(params, "d", m)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /remove [Object Model]");
- new File: rfile = fopen(REMOVED_OBJECTS_FILE, io_read);
- if(!rfile) return SendClientMessage(playerid, COLOR_RED, "Error accessing at removed objects file! Contact the owner.");
- new line[128], model, lod;
- while(fread(rfile, line, sizeof(line)))
- {
- if(sscanf(line, "p<,>dd", model, lod)) continue;
- if(model == m)
- {
- fclose(rfile);
- return SendClientMessage(playerid, COLOR_RED, "Error: The specified object model was already removed!");
- }
- }
- fclose(rfile);
- new File: file = fopen(OBJECTS_FILE, io_read);
- if(!file) return SendClientMessage(playerid, COLOR_RED, "Error accessing at objects file! Contact the owner.");
- new Float: x, Float: y, Float: z, Float: rx, Float: ry, Float: rz, counter = 0, i = -1;
- while(fread(file, line, sizeof(line)))
- {
- i++;
- if(i >= MAX_SLOTS) break;
- if(sscanf(line, "p<,>ddffffff", model, lod, x, y, z, rx, ry, rz)) continue;
- if(model != m) continue;
- if(Objects[i] != -1) DestroyDynamicObject(Objects[i]);
- if(Lods[i] != -1) DestroyDynamicObject(Lods[i]);
- if(lod != 65535)
- {
- for(new p = 0; p < MAX_PLAYERS; p++) if(IsPlayerConnected(p)) RemoveBuildingForPlayer(p, lod, 0.0, 0.0, 0.0, 10000.0);
- }
- counter++;
- }
- fclose(file);
- for(new p = 0; p < MAX_PLAYERS; p++) if(IsPlayerConnected(p)) RemoveBuildingForPlayer(p, m, 0.0, 0.0, 0.0, 10000.0);
- new str[64];
- format(str, sizeof(str), "%d, %d\r\n", m, lod);
- rfile = fopen(REMOVED_OBJECTS_FILE, io_append);
- if(!rfile) return SendClientMessage(playerid, COLOR_RED, "Error accessing at removed objects file! Contact the owner.");
- fwrite(rfile, str);
- fclose(rfile);
- new msg[64];
- format(msg, sizeof(msg), "Server: %d objects with model %d were removed!", counter, m);
- SendClientMessage(playerid, COLOR_RED, msg);
- return 1;
- }
- CMD:showmodels(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: Only RCON admins can use this command.");
- new text[16];
- new File: file = fopen(OBJECTS_FILE, io_read);
- if(!file) return SendClientMessage(playerid, COLOR_RED, "Error accessing at objects file! Contact the owner.");
- new line[128], model, lod, Float: x, Float: y, Float: z, Float: rx, Float: ry, Float: rz, i = -1;
- while(fread(file, line, sizeof(line)))
- {
- i++;
- if(i >= MAX_SLOTS) break;
- if(sscanf(line, "p<,>ddffffff", model, lod, x, y, z, rx, ry, rz)) continue;
- DestroyDynamic3DTextLabel(Labels[i]);
- format(text, sizeof(text), "%d", model);
- Labels[i] = CreateDynamic3DTextLabel(text, COLOR_WHITE, x, y, z, 50.0);
- }
- fclose(file);
- SendClientMessage(playerid, COLOR_GREEN, "Server: Objects model labels on!");
- return 1;
- }
- CMD:hidemodels(playerid, params[])
- {
- if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Error: Only RCON admins can use this command.");
- for(new i = 0; i < sizeof(Labels); i++) DestroyDynamic3DTextLabel(Labels[i]);
- SendClientMessage(playerid, COLOR_RED, "Server: Objects model labels off!");
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment