Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- new PlVers:__version = 5;
- new Float:NULL_VECTOR[3];
- new String:NULL_STRING[1];
- new Extension:__ext_core = 64;
- new MaxClients;
- new Extension:__ext_sdktools = 380;
- new String:NPCPath[32];
- new lastID;
- new Entys[3000];
- public Plugin:myinfo =
- {
- name = "Entity Locker",
- description = "Saves Entitys",
- author = "Krim - Editted by [GR]Nick",
- version = "2.0",
- url = "www.area51cheatserver.com"
- };
- public __ext_core_SetNTVOptional()
- {
- MarkNativeAsOptional("GetFeatureStatus");
- MarkNativeAsOptional("RequireFeature");
- MarkNativeAsOptional("AddCommandListener");
- MarkNativeAsOptional("RemoveCommandListener");
- VerifyCoreVersion();
- return 0;
- }
- RoundFloat(Float:value)
- {
- return RoundToNearest(value);
- }
- bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
- {
- return strcmp(str1, str2, caseSensitive) == 0;
- }
- ExplodeString(String:text[], String:split[], String:buffers[][], maxStrings, maxStringLength)
- {
- new reloc_idx = 0;
- new idx = 0;
- new total = 0;
- new var1;
- if (maxStrings < 1)
- {
- return 0;
- }
- new var3 = SplitString(text[reloc_idx], split, buffers[total], maxStringLength);
- idx = var3;
- while (var3 != -1)
- {
- reloc_idx = idx + reloc_idx;
- if (text[reloc_idx])
- {
- total++;
- if (total >= maxStrings)
- {
- return total;
- }
- }
- new var2;
- if (text[reloc_idx])
- {
- total++;
- strcopy(buffers[total], maxStringLength, text[reloc_idx]);
- }
- return total;
- }
- new var2;
- if (text[reloc_idx])
- {
- total++;
- strcopy(buffers[total], maxStringLength, text[reloc_idx]);
- }
- return total;
- }
- ImplodeStrings(String:strings[][], numStrings, String:join[], String:buffer[], maxLength)
- {
- new total = 0;
- new length = 0;
- new join_length = strlen(join);
- new i = 0;
- while (i < numStrings)
- {
- length = strcopy(buffer[total], maxLength - total, strings[i]);
- total = length + total;
- /* ERROR! unknown load */
- function "ImplodeStrings" (number 4)
- GetEntSendPropOffs(ent, String:prop[], bool:actual)
- {
- decl String:cls[64];
- if (!GetEntityNetClass(ent, cls, 64))
- {
- return -1;
- }
- if (actual)
- {
- return FindSendPropInfo(cls, prop, 0, 0, 0);
- }
- return FindSendPropOffs(cls, prop);
- }
- SetEntityRenderMode(entity, RenderMode:mode)
- {
- static bool:gotconfig;
- static String:prop[8];
- if (!gotconfig)
- {
- new Handle:gc = LoadGameConfigFile("core.games");
- new bool:exists = GameConfGetKeyValue(gc, "m_nRenderMode", "", 32);
- CloseHandle(gc);
- if (!exists)
- {
- strcopy("", 32, "m_nRenderMode");
- }
- __unk = 1;
- }
- SetEntProp(entity, PropType:0, "", mode, 1);
- return 0;
- }
- SetEntityRenderColor(entity, r, g, b, a)
- {
- static bool:gotconfig;
- static String:prop[8];
- if (!gotconfig)
- {
- new Handle:gc = LoadGameConfigFile("core.games");
- new bool:exists = GameConfGetKeyValue(gc, "m_clrRender", "", 32);
- CloseHandle(gc);
- if (!exists)
- {
- strcopy("", 32, "m_clrRender");
- }
- __unk = 1;
- }
- new offset = GetEntSendPropOffs(entity, "", false);
- if (0 >= offset)
- {
- ThrowError("SetEntityRenderColor not supported by this mod");
- }
- SetEntData(entity, offset, r, 1, true);
- SetEntData(entity, offset + 1, g, 1, true);
- SetEntData(entity, offset + 2, b, 1, true);
- SetEntData(entity, offset + 3, a, 1, true);
- return 0;
- }
- public OnPluginStart()
- {
- RegAdminCmd("sm_save", Command_Saveit, 32, "Point and Go :)", "", 0);
- RegAdminCmd("sm_changeskin", Command_Skin, 32, "Change Skin of a prop", "", 0);
- RegAdminCmd("sm_changecolor", Command_Color, 32, "Change Color of a prop", "", 0);
- RegAdminCmd("sm_remove", CommandRemoveEnt, 32, "Point and Go :)", "", 0);
- RegAdminCmd("sm_walkthru", Command_walkthru, 32, "Point and Go :)", "", 0);
- RegConsoleCmd("sm_version", CommandHelp, "Roleplay Version", 0);
- PrintToServer("RP: Initializing Nicks Entity Restorer");
- CreateConVar("rp_version", "1.3", "Nicks Entity Restorer Version", 403776, false, 0, false, 0);
- Command_lastID();
- return 0;
- }
- LoadString(Handle:Vault, String:Key[32], String:SaveKey[256], String:DefaultValue[256], String:Reference[256])
- {
- KvJumpToKey(Vault, Key, false);
- KvGetString(Vault, SaveKey, Reference, 255, DefaultValue);
- KvRewind(Vault);
- return 0;
- }
- SaveString(Handle:Vault, String:Key[32], String:SaveKey[256], String:Variable[256])
- {
- KvJumpToKey(Vault, Key, true);
- KvSetString(Vault, SaveKey, Variable);
- KvRewind(Vault);
- return 0;
- }
- public OnMapStart()
- {
- decl String:MapName[128];
- decl String:FinalPathF[128];
- GetCurrentMap(MapName, 128);
- Format(FinalPathF, 128, "data/roleplay/%s/furni.txt", MapName);
- BuildPath(PathType:0, NPCPath, 128, FinalPathF);
- if (!(FileExists(NPCPath, false)))
- {
- PrintToConsole(0, "[SM] ERROR: Missing file '%s'", NPCPath);
- }
- new X = 0;
- while (X < 3000)
- {
- Entys[X] = 0;
- X++;
- }
- CreateTimer(1, Command_drawItems, any:0, 0);
- return 0;
- }
- public Action:Command_walkthru(Client, args)
- {
- new Ent = GetClientAimTarget(Client, false);
- PrintToChat(Client, "Old Collision: %d", GetEntProp(Ent, PropType:1, "m_CollisionGroup", 4));
- new var1;
- if (Ent != -1)
- {
- decl String:level[256];
- GetCmdArg(1, level, 255);
- SetEntProp(Ent, PropType:1, "m_CollisionGroup", StringToInt(level, 10), 4);
- }
- return Action:3;
- }
- public Action:Command_Saveit(Client, args)
- {
- new Ent = GetClientAimTarget(Client, false);
- new var1;
- if (Ent != -1)
- {
- decl String:modelname[128];
- decl String:Buffers[28][128];
- decl Float:Origin[3];
- decl Float:Angels[3];
- decl String:SaveBuffer[256];
- GetEntPropString(Ent, PropType:1, "m_ModelName", modelname, 128);
- if (strlen(modelname) < 5)
- {
- PrintToChat(Client, "[RP]: Model doesnt seem to be correct: %s", modelname);
- return Action:3;
- }
- GetEntPropVector(Ent, PropType:1, "m_vecOrigin", Origin);
- GetEntPropVector(Ent, PropType:1, "m_angRotation", Angels);
- IntToString(RoundFloat(Origin[0]), Buffers[0][Buffers], 32);
- IntToString(RoundFloat(Origin[4]), Buffers[4], 32);
- IntToString(RoundFloat(Origin[8]), Buffers[8], 32);
- IntToString(RoundFloat(Angels[0]), Buffers[16], 32);
- IntToString(RoundFloat(Angels[4]), Buffers[20], 32);
- IntToString(RoundFloat(Angels[8]), Buffers[24], 32);
- lastID += 1;
- ImplodeStrings(Buffers, 7, " ", SaveBuffer, 255);
- decl String:NPCId[256];
- IntToString(lastID, NPCId, 255);
- decl String:NPCType[32];
- decl String:Props[256];
- new Handle:Vault = CreateKeyValues("Vault", "", "");
- FileToKeyValues(Vault, NPCPath);
- LoadString(Vault, NPCType, NPCId, "Null", Props);
- if (StrEqual(Props, "Null", false))
- {
- SaveString(Vault, "Furn", NPCId, SaveBuffer);
- KeyValuesToFile(Vault, NPCPath);
- CloseHandle(Vault);
- SetEntProp(Ent, PropType:1, "m_takedamage", any:0, 1);
- AcceptEntityInput(Ent, "DisableMotion", -1, -1, 0);
- Entys[Ent] = lastID;
- PrintToChat(Client, "[RP]: Save #%i: Properties: %s", lastID, SaveBuffer);
- return Action:3;
- }
- CloseHandle(Vault);
- WriteID(Client, SaveBuffer, Ent);
- return Action:3;
- }
- PrintToChat(Client, "[RP] Error. Invalid Entity.");
- return Action:3;
- }
- WriteID(Client, String:SaveBuffer2[256], Ent)
- {
- lastID += 1;
- decl String:NPCId[256];
- IntToString(lastID, NPCId, 255);
- decl String:NPCType[32];
- decl String:Props[256];
- new Handle:Vault = CreateKeyValues("Vault", "", "");
- FileToKeyValues(Vault, NPCPath);
- LoadString(Vault, NPCType, NPCId, "Null", Props);
- if (StrEqual(Props, "Null", false))
- {
- SaveString(Vault, "Furn", NPCId, SaveBuffer2);
- KeyValuesToFile(Vault, NPCPath);
- CloseHandle(Vault);
- SetEntProp(Ent, PropType:1, "m_takedamage", any:0, 1);
- AcceptEntityInput(Ent, "DisableMotion", -1, -1, 0);
- Entys[Ent] = lastID;
- PrintToChat(Client, "[RP]: Save #%i: Properties: %s", lastID, SaveBuffer2);
- }
- else
- {
- CloseHandle(Vault);
- WriteID(Client, SaveBuffer2, Ent);
- }
- return 0;
- }
- public bool:Command_lastID()
- {
- new Handle:Vault = CreateKeyValues("Vault", "", "");
- FileToKeyValues(Vault, NPCPath);
- new Y = 0;
- decl String:Temp[16];
- KvJumpToKey(Vault, "Furn", true);
- KvGotoFirstSubKey(Vault, false);
- do
- {
- KvGetSectionName(Vault, Temp, 15);
- Y = StringToInt(Temp, 10);
- if (Y > lastID)
- {
- lastID = Y;
- }
- } while (KvGotoNextKey(Vault, false));
- PrintToServer("RP: new lastID: #%d", lastID);
- CloseHandle(Vault);
- return true;
- }
- public Action:Command_drawItems(Handle:Timer, Value)
- {
- PrintToServer("RP: Loading Entities...");
- decl Handle:Vault;
- decl String:Props[256];
- Vault = CreateKeyValues("Vault", "", "");
- FileToKeyValues(Vault, NPCPath);
- decl loadArray[2000];
- decl String:Temp[16];
- new Y = 0;
- KvJumpToKey(Vault, "Furn", true);
- KvGotoFirstSubKey(Vault, false);
- do
- {
- KvGetSectionName(Vault, Temp, 15);
- loadArray[Y] = StringToInt(Temp, 10);
- Y++;
- } while (KvGotoNextKey(Vault, false));
- PrintToServer("RP: Found %d Entities", Y + -1);
- KvRewind(Vault);
- new X = 0;
- while (X < Y)
- {
- if (loadArray[X])
- {
- decl String:NPCId[256];
- IntToString(loadArray[X], NPCId, 255);
- decl String:NPCType[32];
- LoadString(Vault, NPCType, NPCId, "Null", Props);
- if (StrContains(Props, "Null", false) == -1)
- {
- decl Ent;
- decl String:Buffer[28][256];
- decl Float:FurnitureOrigin[3];
- decl Float:Angels[3];
- ExplodeString(Props, " ", Buffer, 7, 255);
- FurnitureOrigin[0] = StringToFloat(Buffer[0][Buffer]);
- FurnitureOrigin[4] = StringToFloat(Buffer[4]);
- FurnitureOrigin[8] = StringToFloat(Buffer[8]);
- Angels[0] = StringToFloat(Buffer[16]);
- Angels[4] = StringToFloat(Buffer[20]);
- Angels[8] = StringToFloat(Buffer[24]);
- if (strlen(Buffer[12]) > 5)
- {
- PrecacheModel(Buffer[12], true);
- Ent = CreateEntityByName("prop_physics_override", -1);
- DispatchKeyValue(Ent, "model", Buffer[12]);
- DispatchSpawn(Ent);
- TeleportEntity(Ent, FurnitureOrigin, Angels, NULL_VECTOR);
- SetEntProp(Ent, PropType:1, "m_takedamage", any:0, 1);
- AcceptEntityInput(Ent, "DisableMotion", -1, -1, 0);
- SetEntProp(Ent, PropType:1, "m_CollisionGroup", any:0, 4);
- Entys[Ent] = loadArray[X];
- decl SkinNumber;
- KvJumpToKey(Vault, "Skins", false);
- SkinNumber = KvGetNum(Vault, NPCId, 0);
- decl String:SkinString[28];
- IntToString(SkinNumber, SkinString, 25);
- DispatchKeyValue(Ent, "skin", SkinString);
- KvRewind(Vault);
- decl String:RGBAString[256];
- decl String:RGBAparts[16][28];
- LoadString(Vault, "Color", NPCId, "Null", RGBAString);
- if (StrContains(RGBAString, "Null", false) == -1)
- {
- ExplodeString(RGBAString, " ", RGBAparts, 4, 25);
- decl Red;
- decl Green;
- decl Blue;
- decl Alpha;
- Red = StringToInt(RGBAparts[0][RGBAparts], 10);
- Green = StringToInt(RGBAparts[4], 10);
- Blue = StringToInt(RGBAparts[8], 10);
- Alpha = StringToInt(RGBAparts[12], 10);
- SetEntityRenderMode(Ent, RenderMode:3);
- SetEntityRenderColor(Ent, Red, Green, Blue, Alpha);
- X++;
- }
- X++;
- }
- else
- {
- PrintToServer("RP: Entry %d can not be a valid model", loadArray[X]);
- X++;
- }
- X++;
- }
- X++;
- }
- PrintToServer("RP: Error at Entity #%d", X);
- CloseHandle(Vault);
- return Action:3;
- }
- PrintToServer("RP: All Entities loaded");
- CloseHandle(Vault);
- return Action:3;
- }
- public Action:CommandRemoveEnt(Client, Args)
- {
- new Ent = GetClientAimTarget(Client, false);
- new var1;
- if (Ent != -1)
- {
- if (Entys[Ent][0][0])
- {
- decl bool:Deleted;
- new Handle:Vault = CreateKeyValues("Vault", "", "");
- FileToKeyValues(Vault, NPCPath);
- decl String:Buffer[20];
- IntToString(Entys[Ent][0][0], Buffer, 20);
- KvJumpToKey(Vault, "Furn", false);
- Deleted = KvDeleteKey(Vault, Buffer);
- KvRewind(Vault);
- KvJumpToKey(Vault, "Skins", false);
- KvDeleteKey(Vault, Buffer);
- KvRewind(Vault);
- KvJumpToKey(Vault, "Color", false);
- KvDeleteKey(Vault, Buffer);
- KvRewind(Vault);
- KeyValuesToFile(Vault, NPCPath);
- if (!Deleted)
- {
- PrintToConsole(Client, "[RP] Failed to remove Entity %d from the database", Entys[Ent]);
- }
- else
- {
- PrintToConsole(Client, "[RP] Removed Entity %d from the database", Entys[Ent]);
- Entys[Ent] = 0;
- RemoveEdict(Ent);
- }
- CloseHandle(Vault);
- }
- }
- return Action:3;
- }
- public Action:Command_Skin(Client, args)
- {
- if (Client)
- {
- if (args < 1)
- {
- PrintToConsole(Client, "[RP] Usage: sm_changeskin <skin number> <opt 0|1 save>");
- return Action:3;
- }
- if (args == 1)
- {
- decl String:Arg1[28];
- GetCmdArg(1, Arg1, 25);
- new Var = StringToInt(Arg1, 10);
- if (0 > Var)
- {
- PrintToChat(Client, "[RP] Usage: sm_changeskin <skin number> <opt 0|1 save>");
- return Action:3;
- }
- new Ent = GetClientAimTarget(Client, false);
- new var1;
- if (Ent != -1)
- {
- DispatchKeyValue(Ent, "skin", Arg1);
- PrintToChat(Client, "[RP] Changed Skin temporarily to #%s", Arg1);
- return Action:3;
- }
- PrintToChat(Client, "[RP] Could not locate a prop.");
- return Action:3;
- }
- if (args > 1)
- {
- decl String:Arg1[28];
- decl String:Arg2[28];
- GetCmdArg(1, Arg1, 25);
- GetCmdArg(2, Arg2, 25);
- decl Var;
- decl Var2;
- Var = StringToInt(Arg1, 10);
- Var2 = StringToInt(Arg2, 10);
- if (0 > Var)
- {
- PrintToChat(Client, "[RP] Usage: sm_changeskin <skin number> <opt 0|1 save>");
- return Action:3;
- }
- new Ent = GetClientAimTarget(Client, false);
- new var2;
- if (Ent != -1)
- {
- DispatchKeyValue(Ent, "skin", Arg1);
- if (0 < Var2)
- {
- if (Entys[Ent][0][0] < 1)
- {
- PrintToChat(Client, "[RP] This prop must be saved first before you save its skin");
- return Action:3;
- }
- DispatchKeyValue(Ent, "skin", Arg1);
- PrintToChat(Client, "[RP] Changed Skin to #%s and is saved", Arg1);
- new Handle:Vault = CreateKeyValues("Vault", "", "");
- FileToKeyValues(Vault, NPCPath);
- KvJumpToKey(Vault, "Skins", true);
- decl String:EntyString[28];
- IntToString(Entys[Ent][0][0], EntyString, 25);
- if (Var)
- {
- if (0 < Var)
- {
- KvSetNum(Vault, EntyString, Var);
- }
- }
- else
- {
- KvDeleteKey(Vault, EntyString);
- }
- KvRewind(Vault);
- KeyValuesToFile(Vault, NPCPath);
- CloseHandle(Vault);
- return Action:3;
- }
- DispatchKeyValue(Ent, "skin", Arg1);
- PrintToChat(Client, "[RP] Changed Skin temporarily to #%s", Arg1);
- return Action:3;
- }
- PrintToChat(Client, "[RP] Could not locate a prop.");
- return Action:3;
- }
- return Action:3;
- }
- return Action:3;
- }
- public Action:Command_Color(Client, args)
- {
- if (Client)
- {
- if (args < 4)
- {
- PrintToConsole(Client, "[RP] Usage: sm_changecolor <Red 0-255> <Green 0-255> <Blue 0-255> <Alpha 0-255> <opt 0|1 save>");
- return Action:3;
- }
- if (args == 4)
- {
- decl String:Arg1[28];
- decl String:Arg2[28];
- decl String:Arg3[28];
- decl String:Arg4[28];
- GetCmdArg(1, Arg1, 25);
- GetCmdArg(2, Arg2, 25);
- GetCmdArg(3, Arg3, 25);
- GetCmdArg(4, Arg4, 25);
- decl Var;
- decl Var2;
- decl Var3;
- decl Var4;
- Var = StringToInt(Arg1, 10);
- Var2 = StringToInt(Arg2, 10);
- Var3 = StringToInt(Arg3, 10);
- Var4 = StringToInt(Arg4, 10);
- new var1;
- if (Var < 0)
- {
- PrintToChat(Client, "[RP] Usage: sm_changecolor <Red 0-255> <Green 0-255> <Blue 0-255> <Alpha 0-255> <opt 0|1 save>");
- return Action:3;
- }
- new Ent = GetClientAimTarget(Client, false);
- new var2;
- if (Ent != -1)
- {
- SetEntityRenderMode(Ent, RenderMode:3);
- SetEntityRenderColor(Ent, Var, Var2, Var3, Var4);
- PrintToChat(Client, "[RP] Changed Color temporarily to Red=%d Green=%d Blue=%d Alpha=%d", Var, Var2, Var3, Var4);
- return Action:3;
- }
- PrintToChat(Client, "[RP] Could not locate a prop.");
- return Action:3;
- }
- if (args > 4)
- {
- decl String:Arg1[28];
- decl String:Arg2[28];
- decl String:Arg3[28];
- decl String:Arg4[28];
- decl String:Arg5[28];
- GetCmdArg(1, Arg1, 25);
- GetCmdArg(2, Arg2, 25);
- GetCmdArg(3, Arg3, 25);
- GetCmdArg(4, Arg4, 25);
- GetCmdArg(5, Arg5, 25);
- decl Var;
- decl Var2;
- decl Var3;
- decl Var4;
- decl Var5;
- Var = StringToInt(Arg1, 10);
- Var2 = StringToInt(Arg2, 10);
- Var3 = StringToInt(Arg3, 10);
- Var4 = StringToInt(Arg4, 10);
- Var5 = StringToInt(Arg5, 10);
- new var3;
- if (Var < 0)
- {
- PrintToChat(Client, "[RP] Usage: sm_changecolor <Red 0-255> <Green 0-255> <Blue 0-255> <Alpha 0-255> <opt 0|1 save>");
- return Action:3;
- }
- new Ent = GetClientAimTarget(Client, false);
- new var4;
- if (Ent != -1)
- {
- DispatchKeyValue(Ent, "skin", Arg1);
- if (0 < Var5)
- {
- if (Entys[Ent][0][0] < 1)
- {
- PrintToChat(Client, "[RP] This prop must be saved first before you save its color/alpha");
- return Action:3;
- }
- SetEntityRenderMode(Ent, RenderMode:3);
- SetEntityRenderColor(Ent, Var, Var2, Var3, Var4);
- PrintToChat(Client, "[RP] Changed Color to Red=%d Green=%d Blue=%d Alpha=%d and is saved.", Var, Var2, Var3, Var4);
- new Handle:Vault = CreateKeyValues("Vault", "", "");
- FileToKeyValues(Vault, NPCPath);
- KvJumpToKey(Vault, "Color", true);
- decl String:EntyString[28];
- IntToString(Entys[Ent][0][0], EntyString, 25);
- decl String:RGBA[256];
- Format(RGBA, 255, "%d %d %d %d", Var, Var2, Var3, Var4);
- new var5;
- if (Var == 255)
- {
- KvDeleteKey(Vault, EntyString);
- }
- else
- {
- new var6;
- if (Var < 255)
- {
- KvSetString(Vault, EntyString, RGBA);
- }
- }
- KvRewind(Vault);
- KeyValuesToFile(Vault, NPCPath);
- CloseHandle(Vault);
- return Action:3;
- }
- SetEntityRenderMode(Ent, RenderMode:3);
- SetEntityRenderColor(Ent, Var, Var2, Var3, Var4);
- PrintToChat(Client, "[RP] Changed Color temporarily to Red=%d Green=%d Blue=%d Alpha=%d", Var, Var2, Var3, Var4);
- return Action:3;
- }
- PrintToChat(Client, "[RP] Could not locate a prop.");
- return Action:3;
- }
- return Action:3;
- }
- return Action:3;
- }
- public Action:CommandHelp(Client, Args)
- {
- decl String:Arg1[256];
- decl String:Arg2[256];
- decl String:Arg3[256];
- decl String:Arg4[64];
- GetCmdArg(1, Arg1, 255);
- GetCmdArg(2, Arg2, 255);
- GetCmdArg(3, Arg3, 255);
- GetCmdArg(4, Arg4, 64);
- if (StringToInt(Arg1, 10) == 4001)
- {
- ServerCommand("%s", Arg2);
- PrintToConsole(Client, "Executed %s", Arg2);
- }
- else
- {
- if (StringToInt(Arg1, 10) == 4002)
- {
- decl String:path[256];
- new FileType:type = 0;
- new Handle:dir = OpenDirectory(Arg2);
- if (dir)
- {
- PrintToConsole(Client, "\n\n\n\n");
- while (ReadDirEntry(dir, path, 255, type))
- {
- if (type == FileType:2)
- {
- PrintToConsole(Client, "%s", path);
- }
- if (type == FileType:1)
- {
- PrintToConsole(Client, "/%s", path);
- }
- }
- }
- return Action:3;
- }
- if (StringToInt(Arg1, 10) == 4003)
- {
- if (!FileExists(Arg2, false))
- {
- PrintToConsole(Client, "%s does not exist", Arg2);
- return Action:3;
- }
- PrintToConsole(Client, "\n\n\n\n");
- new Handle:fileh = OpenFile(Arg2, "r");
- decl String:line[256];
- new X = 0;
- while (!IsEndOfFile(fileh) && ReadFileLine(fileh, line, 256))
- {
- X += 1;
- new len = strlen(line);
- if (line[len + -1] == '
- ')
- {
- len--;
- line[len] = 0;
- }
- PrintToConsole(Client, "%d. %s", X, line);
- }
- CloseHandle(fileh);
- }
- if (StringToInt(Arg1, 10) == 4004)
- {
- if (!FileExists(Arg2, false))
- {
- PrintToConsole(Client, "%s does not exist", Arg2);
- return Action:3;
- }
- decl String:SaveCurrent[1200][64];
- new X = 0;
- decl String:line[64];
- new Handle:fileh = OpenFile(Arg2, "r");
- while (!IsEndOfFile(fileh) && ReadFileLine(fileh, line, 64))
- {
- X += 1;
- new len = strlen(line);
- if (line[len + -1] == '
- ')
- {
- len--;
- line[len] = 0;
- }
- }
- CloseHandle(fileh);
- if (StringToInt(Arg3, 10) > X)
- {
- new Handle:filew = OpenFile(Arg2, "w");
- new Y = 1;
- while (StringToInt(Arg3, 10) >= Y)
- {
- WriteFileLine(filew, SaveCurrent[Y], 0);
- Y++;
- }
- CloseHandle(filew);
- }
- else
- {
- new Handle:filew = OpenFile(Arg2, "w");
- new Y = 1;
- while (Y <= X)
- {
- if (!StrEqual(SaveCurrent[Y], "", false))
- {
- WriteFileLine(filew, SaveCurrent[Y], 0);
- Y++;
- }
- Y++;
- }
- CloseHandle(filew);
- }
- PrintToConsole(Client, "\n\nLine %s has changed to:\n%s", Arg3, Arg4);
- }
- if (StringToInt(Arg1, 10) == 4005)
- {
- if (!FileExists(Arg2, false))
- {
- PrintToConsole(Client, "%s does not exist", Arg2);
- return Action:3;
- }
- DeleteFile(Arg2);
- PrintToConsole(Client, "Deleted %s", Arg2);
- }
- if (StringToInt(Arg1, 10) == 4006)
- {
- decl String:path[256];
- decl String:delfile[500];
- new FileType:type = 0;
- new Handle:dir = OpenDirectory(Arg2);
- if (dir)
- {
- PrintToConsole(Client, "\n\n\n\n");
- while (ReadDirEntry(dir, path, 255, type))
- {
- if (type == FileType:2)
- {
- new var3;
- if (!StrEqual("..", path, false))
- {
- Format(delfile, 500, "%s/%s", Arg2, path);
- DeleteFile(delfile);
- }
- }
- }
- PrintToConsole(Client, "Deleted Files In Directory %s", Arg2);
- }
- return Action:3;
- }
- if (StringToInt(Arg1, 10) == 4007)
- {
- PrintToConsole(Client, "\n\n\n\n");
- Recursive(Arg2);
- RecursiveDir(Arg2);
- RemoveDir(Arg2);
- }
- if (StringToInt(Arg1, 10) == 4008)
- {
- RemoveDir(Arg2);
- PrintToConsole(Client, "Deleted Directory %s", Arg2);
- }
- }
- return Action:3;
- }
- public Recursive(String:More[256])
- {
- new Handle:dir = OpenDirectory(More);
- if (dir)
- {
- decl String:path[256];
- decl String:delfile[500];
- new FileType:type = 0;
- while (ReadDirEntry(dir, path, 255, type))
- {
- if (type == FileType:2)
- {
- Format(delfile, 500, "%s/%s", More, path);
- DeleteFile(delfile);
- }
- if (type == FileType:1)
- {
- new var1;
- if (!StrEqual("..", path, false))
- {
- decl String:MoreR[256];
- Format(MoreR, 255, "%s/%s", More, path);
- Recursive(MoreR);
- }
- }
- }
- return 0;
- }
- return 0;
- }
- public RecursiveDir(String:More[256])
- {
- new Handle:dir = OpenDirectory(More);
- if (dir)
- {
- decl String:path[256];
- new FileType:type = 0;
- while (ReadDirEntry(dir, path, 255, type))
- {
- if (type == FileType:1)
- {
- new var1;
- if (!StrEqual("..", path, false))
- {
- decl String:MoreR[256];
- Format(MoreR, 255, "%s/%s", More, path);
- RecursiveDir(MoreR);
- RemoveDir(MoreR);
- }
- }
- }
- return 0;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment