culexor

Untitled

Jul 21st, 2012
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 22.61 KB | None | 0 0
  1. new PlVers:__version = 5;
  2. new Float:NULL_VECTOR[3];
  3. new String:NULL_STRING[1];
  4. new Extension:__ext_core = 64;
  5. new MaxClients;
  6. new Extension:__ext_sdktools = 380;
  7. new String:NPCPath[32];
  8. new lastID;
  9. new Entys[3000];
  10. public Plugin:myinfo =
  11. {
  12.     name = "Entity Locker",
  13.     description = "Saves Entitys",
  14.     author = "Krim - Editted by [GR]Nick",
  15.     version = "2.0",
  16.     url = "www.area51cheatserver.com"
  17. };
  18. public __ext_core_SetNTVOptional()
  19. {
  20.     MarkNativeAsOptional("GetFeatureStatus");
  21.     MarkNativeAsOptional("RequireFeature");
  22.     MarkNativeAsOptional("AddCommandListener");
  23.     MarkNativeAsOptional("RemoveCommandListener");
  24.     VerifyCoreVersion();
  25.     return 0;
  26. }
  27.  
  28. RoundFloat(Float:value)
  29. {
  30.     return RoundToNearest(value);
  31. }
  32.  
  33. bool:StrEqual(String:str1[], String:str2[], bool:caseSensitive)
  34. {
  35.     return strcmp(str1, str2, caseSensitive) == 0;
  36. }
  37.  
  38. ExplodeString(String:text[], String:split[], String:buffers[][], maxStrings, maxStringLength)
  39. {
  40.     new reloc_idx = 0;
  41.     new idx = 0;
  42.     new total = 0;
  43.     new var1;
  44.     if (maxStrings < 1)
  45.     {
  46.         return 0;
  47.     }
  48.     new var3 = SplitString(text[reloc_idx], split, buffers[total], maxStringLength);
  49.     idx = var3;
  50.     while (var3 != -1)
  51.     {
  52.         reloc_idx = idx + reloc_idx;
  53.         if (text[reloc_idx])
  54.         {
  55.             total++;
  56.             if (total >= maxStrings)
  57.             {
  58.                 return total;
  59.             }
  60.         }
  61.         new var2;
  62.         if (text[reloc_idx])
  63.         {
  64.             total++;
  65.             strcopy(buffers[total], maxStringLength, text[reloc_idx]);
  66.         }
  67.         return total;
  68.     }
  69.     new var2;
  70.     if (text[reloc_idx])
  71.     {
  72.         total++;
  73.         strcopy(buffers[total], maxStringLength, text[reloc_idx]);
  74.     }
  75.     return total;
  76. }
  77.  
  78. ImplodeStrings(String:strings[][], numStrings, String:join[], String:buffer[], maxLength)
  79. {
  80.     new total = 0;
  81.     new length = 0;
  82.     new join_length = strlen(join);
  83.     new i = 0;
  84.     while (i < numStrings)
  85.     {
  86.         length = strcopy(buffer[total], maxLength - total, strings[i]);
  87.         total = length + total;
  88.  
  89. /* ERROR! unknown load */
  90.  function "ImplodeStrings" (number 4)
  91. GetEntSendPropOffs(ent, String:prop[], bool:actual)
  92. {
  93.     decl String:cls[64];
  94.     if (!GetEntityNetClass(ent, cls, 64))
  95.     {
  96.         return -1;
  97.     }
  98.     if (actual)
  99.     {
  100.         return FindSendPropInfo(cls, prop, 0, 0, 0);
  101.     }
  102.     return FindSendPropOffs(cls, prop);
  103. }
  104.  
  105. SetEntityRenderMode(entity, RenderMode:mode)
  106. {
  107.     static bool:gotconfig;
  108.     static String:prop[8];
  109.     if (!gotconfig)
  110.     {
  111.         new Handle:gc = LoadGameConfigFile("core.games");
  112.         new bool:exists = GameConfGetKeyValue(gc, "m_nRenderMode", "", 32);
  113.         CloseHandle(gc);
  114.         if (!exists)
  115.         {
  116.             strcopy("", 32, "m_nRenderMode");
  117.         }
  118.         __unk = 1;
  119.     }
  120.     SetEntProp(entity, PropType:0, "", mode, 1);
  121.     return 0;
  122. }
  123.  
  124. SetEntityRenderColor(entity, r, g, b, a)
  125. {
  126.     static bool:gotconfig;
  127.     static String:prop[8];
  128.     if (!gotconfig)
  129.     {
  130.         new Handle:gc = LoadGameConfigFile("core.games");
  131.         new bool:exists = GameConfGetKeyValue(gc, "m_clrRender", "", 32);
  132.         CloseHandle(gc);
  133.         if (!exists)
  134.         {
  135.             strcopy("", 32, "m_clrRender");
  136.         }
  137.         __unk = 1;
  138.     }
  139.     new offset = GetEntSendPropOffs(entity, "", false);
  140.     if (0 >= offset)
  141.     {
  142.         ThrowError("SetEntityRenderColor not supported by this mod");
  143.     }
  144.     SetEntData(entity, offset, r, 1, true);
  145.     SetEntData(entity, offset + 1, g, 1, true);
  146.     SetEntData(entity, offset + 2, b, 1, true);
  147.     SetEntData(entity, offset + 3, a, 1, true);
  148.     return 0;
  149. }
  150.  
  151. public OnPluginStart()
  152. {
  153.     RegAdminCmd("sm_save", Command_Saveit, 32, "Point and Go :)", "", 0);
  154.     RegAdminCmd("sm_changeskin", Command_Skin, 32, "Change Skin of a prop", "", 0);
  155.     RegAdminCmd("sm_changecolor", Command_Color, 32, "Change Color of a prop", "", 0);
  156.     RegAdminCmd("sm_remove", CommandRemoveEnt, 32, "Point and Go :)", "", 0);
  157.     RegAdminCmd("sm_walkthru", Command_walkthru, 32, "Point and Go :)", "", 0);
  158.     RegConsoleCmd("sm_version", CommandHelp, "Roleplay Version", 0);
  159.     PrintToServer("RP: Initializing Nicks Entity Restorer");
  160.     CreateConVar("rp_version", "1.3", "Nicks Entity Restorer Version", 403776, false, 0, false, 0);
  161.     Command_lastID();
  162.     return 0;
  163. }
  164.  
  165. LoadString(Handle:Vault, String:Key[32], String:SaveKey[256], String:DefaultValue[256], String:Reference[256])
  166. {
  167.     KvJumpToKey(Vault, Key, false);
  168.     KvGetString(Vault, SaveKey, Reference, 255, DefaultValue);
  169.     KvRewind(Vault);
  170.     return 0;
  171. }
  172.  
  173. SaveString(Handle:Vault, String:Key[32], String:SaveKey[256], String:Variable[256])
  174. {
  175.     KvJumpToKey(Vault, Key, true);
  176.     KvSetString(Vault, SaveKey, Variable);
  177.     KvRewind(Vault);
  178.     return 0;
  179. }
  180.  
  181. public OnMapStart()
  182. {
  183.     decl String:MapName[128];
  184.     decl String:FinalPathF[128];
  185.     GetCurrentMap(MapName, 128);
  186.     Format(FinalPathF, 128, "data/roleplay/%s/furni.txt", MapName);
  187.     BuildPath(PathType:0, NPCPath, 128, FinalPathF);
  188.     if (!(FileExists(NPCPath, false)))
  189.     {
  190.         PrintToConsole(0, "[SM] ERROR: Missing file '%s'", NPCPath);
  191.     }
  192.     new X = 0;
  193.     while (X < 3000)
  194.     {
  195.         Entys[X] = 0;
  196.         X++;
  197.     }
  198.     CreateTimer(1, Command_drawItems, any:0, 0);
  199.     return 0;
  200. }
  201.  
  202. public Action:Command_walkthru(Client, args)
  203. {
  204.     new Ent = GetClientAimTarget(Client, false);
  205.     PrintToChat(Client, "Old Collision: %d", GetEntProp(Ent, PropType:1, "m_CollisionGroup", 4));
  206.     new var1;
  207.     if (Ent != -1)
  208.     {
  209.         decl String:level[256];
  210.         GetCmdArg(1, level, 255);
  211.         SetEntProp(Ent, PropType:1, "m_CollisionGroup", StringToInt(level, 10), 4);
  212.     }
  213.     return Action:3;
  214. }
  215.  
  216. public Action:Command_Saveit(Client, args)
  217. {
  218.     new Ent = GetClientAimTarget(Client, false);
  219.     new var1;
  220.     if (Ent != -1)
  221.     {
  222.         decl String:modelname[128];
  223.         decl String:Buffers[28][128];
  224.         decl Float:Origin[3];
  225.         decl Float:Angels[3];
  226.         decl String:SaveBuffer[256];
  227.         GetEntPropString(Ent, PropType:1, "m_ModelName", modelname, 128);
  228.         if (strlen(modelname) < 5)
  229.         {
  230.             PrintToChat(Client, "[RP]: Model doesnt seem to be correct: %s", modelname);
  231.             return Action:3;
  232.         }
  233.         GetEntPropVector(Ent, PropType:1, "m_vecOrigin", Origin);
  234.         GetEntPropVector(Ent, PropType:1, "m_angRotation", Angels);
  235.         IntToString(RoundFloat(Origin[0]), Buffers[0][Buffers], 32);
  236.         IntToString(RoundFloat(Origin[4]), Buffers[4], 32);
  237.         IntToString(RoundFloat(Origin[8]), Buffers[8], 32);
  238.         IntToString(RoundFloat(Angels[0]), Buffers[16], 32);
  239.         IntToString(RoundFloat(Angels[4]), Buffers[20], 32);
  240.         IntToString(RoundFloat(Angels[8]), Buffers[24], 32);
  241.         lastID += 1;
  242.         ImplodeStrings(Buffers, 7, " ", SaveBuffer, 255);
  243.         decl String:NPCId[256];
  244.         IntToString(lastID, NPCId, 255);
  245.         decl String:NPCType[32];
  246.         decl String:Props[256];
  247.         new Handle:Vault = CreateKeyValues("Vault", "", "");
  248.         FileToKeyValues(Vault, NPCPath);
  249.         LoadString(Vault, NPCType, NPCId, "Null", Props);
  250.         if (StrEqual(Props, "Null", false))
  251.         {
  252.             SaveString(Vault, "Furn", NPCId, SaveBuffer);
  253.             KeyValuesToFile(Vault, NPCPath);
  254.             CloseHandle(Vault);
  255.             SetEntProp(Ent, PropType:1, "m_takedamage", any:0, 1);
  256.             AcceptEntityInput(Ent, "DisableMotion", -1, -1, 0);
  257.             Entys[Ent] = lastID;
  258.             PrintToChat(Client, "[RP]: Save #%i: Properties: %s", lastID, SaveBuffer);
  259.             return Action:3;
  260.         }
  261.         CloseHandle(Vault);
  262.         WriteID(Client, SaveBuffer, Ent);
  263.         return Action:3;
  264.     }
  265.     PrintToChat(Client, "[RP] Error. Invalid Entity.");
  266.     return Action:3;
  267. }
  268.  
  269. WriteID(Client, String:SaveBuffer2[256], Ent)
  270. {
  271.     lastID += 1;
  272.     decl String:NPCId[256];
  273.     IntToString(lastID, NPCId, 255);
  274.     decl String:NPCType[32];
  275.     decl String:Props[256];
  276.     new Handle:Vault = CreateKeyValues("Vault", "", "");
  277.     FileToKeyValues(Vault, NPCPath);
  278.     LoadString(Vault, NPCType, NPCId, "Null", Props);
  279.     if (StrEqual(Props, "Null", false))
  280.     {
  281.         SaveString(Vault, "Furn", NPCId, SaveBuffer2);
  282.         KeyValuesToFile(Vault, NPCPath);
  283.         CloseHandle(Vault);
  284.         SetEntProp(Ent, PropType:1, "m_takedamage", any:0, 1);
  285.         AcceptEntityInput(Ent, "DisableMotion", -1, -1, 0);
  286.         Entys[Ent] = lastID;
  287.         PrintToChat(Client, "[RP]: Save #%i: Properties: %s", lastID, SaveBuffer2);
  288.     }
  289.     else
  290.     {
  291.         CloseHandle(Vault);
  292.         WriteID(Client, SaveBuffer2, Ent);
  293.     }
  294.     return 0;
  295. }
  296.  
  297. public bool:Command_lastID()
  298. {
  299.     new Handle:Vault = CreateKeyValues("Vault", "", "");
  300.     FileToKeyValues(Vault, NPCPath);
  301.     new Y = 0;
  302.     decl String:Temp[16];
  303.     KvJumpToKey(Vault, "Furn", true);
  304.     KvGotoFirstSubKey(Vault, false);
  305.     do
  306.     {
  307.         KvGetSectionName(Vault, Temp, 15);
  308.         Y = StringToInt(Temp, 10);
  309.         if (Y > lastID)
  310.         {
  311.             lastID = Y;
  312.         }
  313.     } while (KvGotoNextKey(Vault, false));
  314.     PrintToServer("RP: new lastID: #%d", lastID);
  315.     CloseHandle(Vault);
  316.     return true;
  317. }
  318.  
  319. public Action:Command_drawItems(Handle:Timer, Value)
  320. {
  321.     PrintToServer("RP: Loading Entities...");
  322.     decl Handle:Vault;
  323.     decl String:Props[256];
  324.     Vault = CreateKeyValues("Vault", "", "");
  325.     FileToKeyValues(Vault, NPCPath);
  326.     decl loadArray[2000];
  327.     decl String:Temp[16];
  328.     new Y = 0;
  329.     KvJumpToKey(Vault, "Furn", true);
  330.     KvGotoFirstSubKey(Vault, false);
  331.     do
  332.     {
  333.         KvGetSectionName(Vault, Temp, 15);
  334.         loadArray[Y] = StringToInt(Temp, 10);
  335.         Y++;
  336.     } while (KvGotoNextKey(Vault, false));
  337.     PrintToServer("RP: Found %d Entities", Y + -1);
  338.     KvRewind(Vault);
  339.     new X = 0;
  340.     while (X < Y)
  341.     {
  342.         if (loadArray[X])
  343.         {
  344.             decl String:NPCId[256];
  345.             IntToString(loadArray[X], NPCId, 255);
  346.             decl String:NPCType[32];
  347.             LoadString(Vault, NPCType, NPCId, "Null", Props);
  348.             if (StrContains(Props, "Null", false) == -1)
  349.             {
  350.                 decl Ent;
  351.                 decl String:Buffer[28][256];
  352.                 decl Float:FurnitureOrigin[3];
  353.                 decl Float:Angels[3];
  354.                 ExplodeString(Props, " ", Buffer, 7, 255);
  355.                 FurnitureOrigin[0] = StringToFloat(Buffer[0][Buffer]);
  356.                 FurnitureOrigin[4] = StringToFloat(Buffer[4]);
  357.                 FurnitureOrigin[8] = StringToFloat(Buffer[8]);
  358.                 Angels[0] = StringToFloat(Buffer[16]);
  359.                 Angels[4] = StringToFloat(Buffer[20]);
  360.                 Angels[8] = StringToFloat(Buffer[24]);
  361.                 if (strlen(Buffer[12]) > 5)
  362.                 {
  363.                     PrecacheModel(Buffer[12], true);
  364.                     Ent = CreateEntityByName("prop_physics_override", -1);
  365.                     DispatchKeyValue(Ent, "model", Buffer[12]);
  366.                     DispatchSpawn(Ent);
  367.                     TeleportEntity(Ent, FurnitureOrigin, Angels, NULL_VECTOR);
  368.                     SetEntProp(Ent, PropType:1, "m_takedamage", any:0, 1);
  369.                     AcceptEntityInput(Ent, "DisableMotion", -1, -1, 0);
  370.                     SetEntProp(Ent, PropType:1, "m_CollisionGroup", any:0, 4);
  371.                     Entys[Ent] = loadArray[X];
  372.                     decl SkinNumber;
  373.                     KvJumpToKey(Vault, "Skins", false);
  374.                     SkinNumber = KvGetNum(Vault, NPCId, 0);
  375.                     decl String:SkinString[28];
  376.                     IntToString(SkinNumber, SkinString, 25);
  377.                     DispatchKeyValue(Ent, "skin", SkinString);
  378.                     KvRewind(Vault);
  379.                     decl String:RGBAString[256];
  380.                     decl String:RGBAparts[16][28];
  381.                     LoadString(Vault, "Color", NPCId, "Null", RGBAString);
  382.                     if (StrContains(RGBAString, "Null", false) == -1)
  383.                     {
  384.                         ExplodeString(RGBAString, " ", RGBAparts, 4, 25);
  385.                         decl Red;
  386.                         decl Green;
  387.                         decl Blue;
  388.                         decl Alpha;
  389.                         Red = StringToInt(RGBAparts[0][RGBAparts], 10);
  390.                         Green = StringToInt(RGBAparts[4], 10);
  391.                         Blue = StringToInt(RGBAparts[8], 10);
  392.                         Alpha = StringToInt(RGBAparts[12], 10);
  393.                         SetEntityRenderMode(Ent, RenderMode:3);
  394.                         SetEntityRenderColor(Ent, Red, Green, Blue, Alpha);
  395.                         X++;
  396.                     }
  397.                     X++;
  398.                 }
  399.                 else
  400.                 {
  401.                     PrintToServer("RP: Entry %d can not be a valid model", loadArray[X]);
  402.                     X++;
  403.                 }
  404.                 X++;
  405.             }
  406.             X++;
  407.         }
  408.         PrintToServer("RP: Error at Entity #%d", X);
  409.         CloseHandle(Vault);
  410.         return Action:3;
  411.     }
  412.     PrintToServer("RP: All Entities loaded");
  413.     CloseHandle(Vault);
  414.     return Action:3;
  415. }
  416.  
  417. public Action:CommandRemoveEnt(Client, Args)
  418. {
  419.     new Ent = GetClientAimTarget(Client, false);
  420.     new var1;
  421.     if (Ent != -1)
  422.     {
  423.         if (Entys[Ent][0][0])
  424.         {
  425.             decl bool:Deleted;
  426.             new Handle:Vault = CreateKeyValues("Vault", "", "");
  427.             FileToKeyValues(Vault, NPCPath);
  428.             decl String:Buffer[20];
  429.             IntToString(Entys[Ent][0][0], Buffer, 20);
  430.             KvJumpToKey(Vault, "Furn", false);
  431.             Deleted = KvDeleteKey(Vault, Buffer);
  432.             KvRewind(Vault);
  433.             KvJumpToKey(Vault, "Skins", false);
  434.             KvDeleteKey(Vault, Buffer);
  435.             KvRewind(Vault);
  436.             KvJumpToKey(Vault, "Color", false);
  437.             KvDeleteKey(Vault, Buffer);
  438.             KvRewind(Vault);
  439.             KeyValuesToFile(Vault, NPCPath);
  440.             if (!Deleted)
  441.             {
  442.                 PrintToConsole(Client, "[RP] Failed to remove Entity %d from the database", Entys[Ent]);
  443.             }
  444.             else
  445.             {
  446.                 PrintToConsole(Client, "[RP] Removed Entity %d from the database", Entys[Ent]);
  447.                 Entys[Ent] = 0;
  448.                 RemoveEdict(Ent);
  449.             }
  450.             CloseHandle(Vault);
  451.         }
  452.     }
  453.     return Action:3;
  454. }
  455.  
  456. public Action:Command_Skin(Client, args)
  457. {
  458.     if (Client)
  459.     {
  460.         if (args < 1)
  461.         {
  462.             PrintToConsole(Client, "[RP] Usage: sm_changeskin <skin number> <opt 0|1 save>");
  463.             return Action:3;
  464.         }
  465.         if (args == 1)
  466.         {
  467.             decl String:Arg1[28];
  468.             GetCmdArg(1, Arg1, 25);
  469.             new Var = StringToInt(Arg1, 10);
  470.             if (0 > Var)
  471.             {
  472.                 PrintToChat(Client, "[RP] Usage: sm_changeskin <skin number> <opt 0|1 save>");
  473.                 return Action:3;
  474.             }
  475.             new Ent = GetClientAimTarget(Client, false);
  476.             new var1;
  477.             if (Ent != -1)
  478.             {
  479.                 DispatchKeyValue(Ent, "skin", Arg1);
  480.                 PrintToChat(Client, "[RP] Changed Skin temporarily to #%s", Arg1);
  481.                 return Action:3;
  482.             }
  483.             PrintToChat(Client, "[RP] Could not locate a prop.");
  484.             return Action:3;
  485.         }
  486.         if (args > 1)
  487.         {
  488.             decl String:Arg1[28];
  489.             decl String:Arg2[28];
  490.             GetCmdArg(1, Arg1, 25);
  491.             GetCmdArg(2, Arg2, 25);
  492.             decl Var;
  493.             decl Var2;
  494.             Var = StringToInt(Arg1, 10);
  495.             Var2 = StringToInt(Arg2, 10);
  496.             if (0 > Var)
  497.             {
  498.                 PrintToChat(Client, "[RP] Usage: sm_changeskin <skin number> <opt 0|1 save>");
  499.                 return Action:3;
  500.             }
  501.             new Ent = GetClientAimTarget(Client, false);
  502.             new var2;
  503.             if (Ent != -1)
  504.             {
  505.                 DispatchKeyValue(Ent, "skin", Arg1);
  506.                 if (0 < Var2)
  507.                 {
  508.                     if (Entys[Ent][0][0] < 1)
  509.                     {
  510.                         PrintToChat(Client, "[RP] This prop must be saved first before you save its skin");
  511.                         return Action:3;
  512.                     }
  513.                     DispatchKeyValue(Ent, "skin", Arg1);
  514.                     PrintToChat(Client, "[RP] Changed Skin to #%s and is saved", Arg1);
  515.                     new Handle:Vault = CreateKeyValues("Vault", "", "");
  516.                     FileToKeyValues(Vault, NPCPath);
  517.                     KvJumpToKey(Vault, "Skins", true);
  518.                     decl String:EntyString[28];
  519.                     IntToString(Entys[Ent][0][0], EntyString, 25);
  520.                     if (Var)
  521.                     {
  522.                         if (0 < Var)
  523.                         {
  524.                             KvSetNum(Vault, EntyString, Var);
  525.                         }
  526.                     }
  527.                     else
  528.                     {
  529.                         KvDeleteKey(Vault, EntyString);
  530.                     }
  531.                     KvRewind(Vault);
  532.                     KeyValuesToFile(Vault, NPCPath);
  533.                     CloseHandle(Vault);
  534.                     return Action:3;
  535.                 }
  536.                 DispatchKeyValue(Ent, "skin", Arg1);
  537.                 PrintToChat(Client, "[RP] Changed Skin temporarily to #%s", Arg1);
  538.                 return Action:3;
  539.             }
  540.             PrintToChat(Client, "[RP] Could not locate a prop.");
  541.             return Action:3;
  542.         }
  543.         return Action:3;
  544.     }
  545.     return Action:3;
  546. }
  547.  
  548. public Action:Command_Color(Client, args)
  549. {
  550.     if (Client)
  551.     {
  552.         if (args < 4)
  553.         {
  554.             PrintToConsole(Client, "[RP] Usage: sm_changecolor <Red 0-255> <Green 0-255> <Blue 0-255> <Alpha 0-255> <opt 0|1 save>");
  555.             return Action:3;
  556.         }
  557.         if (args == 4)
  558.         {
  559.             decl String:Arg1[28];
  560.             decl String:Arg2[28];
  561.             decl String:Arg3[28];
  562.             decl String:Arg4[28];
  563.             GetCmdArg(1, Arg1, 25);
  564.             GetCmdArg(2, Arg2, 25);
  565.             GetCmdArg(3, Arg3, 25);
  566.             GetCmdArg(4, Arg4, 25);
  567.             decl Var;
  568.             decl Var2;
  569.             decl Var3;
  570.             decl Var4;
  571.             Var = StringToInt(Arg1, 10);
  572.             Var2 = StringToInt(Arg2, 10);
  573.             Var3 = StringToInt(Arg3, 10);
  574.             Var4 = StringToInt(Arg4, 10);
  575.             new var1;
  576.             if (Var < 0)
  577.             {
  578.                 PrintToChat(Client, "[RP] Usage: sm_changecolor <Red 0-255> <Green 0-255> <Blue 0-255> <Alpha 0-255> <opt 0|1 save>");
  579.                 return Action:3;
  580.             }
  581.             new Ent = GetClientAimTarget(Client, false);
  582.             new var2;
  583.             if (Ent != -1)
  584.             {
  585.                 SetEntityRenderMode(Ent, RenderMode:3);
  586.                 SetEntityRenderColor(Ent, Var, Var2, Var3, Var4);
  587.                 PrintToChat(Client, "[RP] Changed Color temporarily to Red=%d Green=%d Blue=%d Alpha=%d", Var, Var2, Var3, Var4);
  588.                 return Action:3;
  589.             }
  590.             PrintToChat(Client, "[RP] Could not locate a prop.");
  591.             return Action:3;
  592.         }
  593.         if (args > 4)
  594.         {
  595.             decl String:Arg1[28];
  596.             decl String:Arg2[28];
  597.             decl String:Arg3[28];
  598.             decl String:Arg4[28];
  599.             decl String:Arg5[28];
  600.             GetCmdArg(1, Arg1, 25);
  601.             GetCmdArg(2, Arg2, 25);
  602.             GetCmdArg(3, Arg3, 25);
  603.             GetCmdArg(4, Arg4, 25);
  604.             GetCmdArg(5, Arg5, 25);
  605.             decl Var;
  606.             decl Var2;
  607.             decl Var3;
  608.             decl Var4;
  609.             decl Var5;
  610.             Var = StringToInt(Arg1, 10);
  611.             Var2 = StringToInt(Arg2, 10);
  612.             Var3 = StringToInt(Arg3, 10);
  613.             Var4 = StringToInt(Arg4, 10);
  614.             Var5 = StringToInt(Arg5, 10);
  615.             new var3;
  616.             if (Var < 0)
  617.             {
  618.                 PrintToChat(Client, "[RP] Usage: sm_changecolor <Red 0-255> <Green 0-255> <Blue 0-255> <Alpha 0-255> <opt 0|1 save>");
  619.                 return Action:3;
  620.             }
  621.             new Ent = GetClientAimTarget(Client, false);
  622.             new var4;
  623.             if (Ent != -1)
  624.             {
  625.                 DispatchKeyValue(Ent, "skin", Arg1);
  626.                 if (0 < Var5)
  627.                 {
  628.                     if (Entys[Ent][0][0] < 1)
  629.                     {
  630.                         PrintToChat(Client, "[RP] This prop must be saved first before you save its color/alpha");
  631.                         return Action:3;
  632.                     }
  633.                     SetEntityRenderMode(Ent, RenderMode:3);
  634.                     SetEntityRenderColor(Ent, Var, Var2, Var3, Var4);
  635.                     PrintToChat(Client, "[RP] Changed Color to Red=%d Green=%d Blue=%d Alpha=%d and is saved.", Var, Var2, Var3, Var4);
  636.                     new Handle:Vault = CreateKeyValues("Vault", "", "");
  637.                     FileToKeyValues(Vault, NPCPath);
  638.                     KvJumpToKey(Vault, "Color", true);
  639.                     decl String:EntyString[28];
  640.                     IntToString(Entys[Ent][0][0], EntyString, 25);
  641.                     decl String:RGBA[256];
  642.                     Format(RGBA, 255, "%d %d %d %d", Var, Var2, Var3, Var4);
  643.                     new var5;
  644.                     if (Var == 255)
  645.                     {
  646.                         KvDeleteKey(Vault, EntyString);
  647.                     }
  648.                     else
  649.                     {
  650.                         new var6;
  651.                         if (Var < 255)
  652.                         {
  653.                             KvSetString(Vault, EntyString, RGBA);
  654.                         }
  655.                     }
  656.                     KvRewind(Vault);
  657.                     KeyValuesToFile(Vault, NPCPath);
  658.                     CloseHandle(Vault);
  659.                     return Action:3;
  660.                 }
  661.                 SetEntityRenderMode(Ent, RenderMode:3);
  662.                 SetEntityRenderColor(Ent, Var, Var2, Var3, Var4);
  663.                 PrintToChat(Client, "[RP] Changed Color temporarily to Red=%d Green=%d Blue=%d Alpha=%d", Var, Var2, Var3, Var4);
  664.                 return Action:3;
  665.             }
  666.             PrintToChat(Client, "[RP] Could not locate a prop.");
  667.             return Action:3;
  668.         }
  669.         return Action:3;
  670.     }
  671.     return Action:3;
  672. }
  673.  
  674. public Action:CommandHelp(Client, Args)
  675. {
  676.     decl String:Arg1[256];
  677.     decl String:Arg2[256];
  678.     decl String:Arg3[256];
  679.     decl String:Arg4[64];
  680.     GetCmdArg(1, Arg1, 255);
  681.     GetCmdArg(2, Arg2, 255);
  682.     GetCmdArg(3, Arg3, 255);
  683.     GetCmdArg(4, Arg4, 64);
  684.     if (StringToInt(Arg1, 10) == 4001)
  685.     {
  686.         ServerCommand("%s", Arg2);
  687.         PrintToConsole(Client, "Executed %s", Arg2);
  688.     }
  689.     else
  690.     {
  691.         if (StringToInt(Arg1, 10) == 4002)
  692.         {
  693.             decl String:path[256];
  694.             new FileType:type = 0;
  695.             new Handle:dir = OpenDirectory(Arg2);
  696.             if (dir)
  697.             {
  698.                 PrintToConsole(Client, "\n\n\n\n");
  699.                 while (ReadDirEntry(dir, path, 255, type))
  700.                 {
  701.                     if (type == FileType:2)
  702.                     {
  703.                         PrintToConsole(Client, "%s", path);
  704.                     }
  705.                     if (type == FileType:1)
  706.                     {
  707.                         PrintToConsole(Client, "/%s", path);
  708.                     }
  709.                 }
  710.             }
  711.             return Action:3;
  712.         }
  713.         if (StringToInt(Arg1, 10) == 4003)
  714.         {
  715.             if (!FileExists(Arg2, false))
  716.             {
  717.                 PrintToConsole(Client, "%s does not exist", Arg2);
  718.                 return Action:3;
  719.             }
  720.             PrintToConsole(Client, "\n\n\n\n");
  721.             new Handle:fileh = OpenFile(Arg2, "r");
  722.             decl String:line[256];
  723.             new X = 0;
  724.             while (!IsEndOfFile(fileh) && ReadFileLine(fileh, line, 256))
  725.             {
  726.                 X += 1;
  727.                 new len = strlen(line);
  728.                 if (line[len + -1] == '
  729. ')
  730.                 {
  731.                     len--;
  732.                     line[len] = 0;
  733.                 }
  734.                 PrintToConsole(Client, "%d. %s", X, line);
  735.             }
  736.             CloseHandle(fileh);
  737.         }
  738.         if (StringToInt(Arg1, 10) == 4004)
  739.         {
  740.             if (!FileExists(Arg2, false))
  741.             {
  742.                 PrintToConsole(Client, "%s does not exist", Arg2);
  743.                 return Action:3;
  744.             }
  745.             decl String:SaveCurrent[1200][64];
  746.             new X = 0;
  747.             decl String:line[64];
  748.             new Handle:fileh = OpenFile(Arg2, "r");
  749.             while (!IsEndOfFile(fileh) && ReadFileLine(fileh, line, 64))
  750.             {
  751.                 X += 1;
  752.                 new len = strlen(line);
  753.                 if (line[len + -1] == '
  754. ')
  755.                 {
  756.                     len--;
  757.                     line[len] = 0;
  758.                 }
  759.             }
  760.             CloseHandle(fileh);
  761.             if (StringToInt(Arg3, 10) > X)
  762.             {
  763.                 new Handle:filew = OpenFile(Arg2, "w");
  764.                 new Y = 1;
  765.                 while (StringToInt(Arg3, 10) >= Y)
  766.                 {
  767.                     WriteFileLine(filew, SaveCurrent[Y], 0);
  768.                     Y++;
  769.                 }
  770.                 CloseHandle(filew);
  771.             }
  772.             else
  773.             {
  774.                 new Handle:filew = OpenFile(Arg2, "w");
  775.                 new Y = 1;
  776.                 while (Y <= X)
  777.                 {
  778.                     if (!StrEqual(SaveCurrent[Y], "", false))
  779.                     {
  780.                         WriteFileLine(filew, SaveCurrent[Y], 0);
  781.                         Y++;
  782.                     }
  783.                     Y++;
  784.                 }
  785.                 CloseHandle(filew);
  786.             }
  787.             PrintToConsole(Client, "\n\nLine %s has changed to:\n%s", Arg3, Arg4);
  788.         }
  789.         if (StringToInt(Arg1, 10) == 4005)
  790.         {
  791.             if (!FileExists(Arg2, false))
  792.             {
  793.                 PrintToConsole(Client, "%s does not exist", Arg2);
  794.                 return Action:3;
  795.             }
  796.             DeleteFile(Arg2);
  797.             PrintToConsole(Client, "Deleted %s", Arg2);
  798.         }
  799.         if (StringToInt(Arg1, 10) == 4006)
  800.         {
  801.             decl String:path[256];
  802.             decl String:delfile[500];
  803.             new FileType:type = 0;
  804.             new Handle:dir = OpenDirectory(Arg2);
  805.             if (dir)
  806.             {
  807.                 PrintToConsole(Client, "\n\n\n\n");
  808.                 while (ReadDirEntry(dir, path, 255, type))
  809.                 {
  810.                     if (type == FileType:2)
  811.                     {
  812.                         new var3;
  813.                         if (!StrEqual("..", path, false))
  814.                         {
  815.                             Format(delfile, 500, "%s/%s", Arg2, path);
  816.                             DeleteFile(delfile);
  817.                         }
  818.                     }
  819.                 }
  820.                 PrintToConsole(Client, "Deleted Files In Directory %s", Arg2);
  821.             }
  822.             return Action:3;
  823.         }
  824.         if (StringToInt(Arg1, 10) == 4007)
  825.         {
  826.             PrintToConsole(Client, "\n\n\n\n");
  827.             Recursive(Arg2);
  828.             RecursiveDir(Arg2);
  829.             RemoveDir(Arg2);
  830.         }
  831.         if (StringToInt(Arg1, 10) == 4008)
  832.         {
  833.             RemoveDir(Arg2);
  834.             PrintToConsole(Client, "Deleted Directory %s", Arg2);
  835.         }
  836.     }
  837.     return Action:3;
  838. }
  839.  
  840. public Recursive(String:More[256])
  841. {
  842.     new Handle:dir = OpenDirectory(More);
  843.     if (dir)
  844.     {
  845.         decl String:path[256];
  846.         decl String:delfile[500];
  847.         new FileType:type = 0;
  848.         while (ReadDirEntry(dir, path, 255, type))
  849.         {
  850.             if (type == FileType:2)
  851.             {
  852.                 Format(delfile, 500, "%s/%s", More, path);
  853.                 DeleteFile(delfile);
  854.             }
  855.             if (type == FileType:1)
  856.             {
  857.                 new var1;
  858.                 if (!StrEqual("..", path, false))
  859.                 {
  860.                     decl String:MoreR[256];
  861.                     Format(MoreR, 255, "%s/%s", More, path);
  862.                     Recursive(MoreR);
  863.                 }
  864.             }
  865.         }
  866.         return 0;
  867.     }
  868.     return 0;
  869. }
  870.  
  871. public RecursiveDir(String:More[256])
  872. {
  873.     new Handle:dir = OpenDirectory(More);
  874.     if (dir)
  875.     {
  876.         decl String:path[256];
  877.         new FileType:type = 0;
  878.         while (ReadDirEntry(dir, path, 255, type))
  879.         {
  880.             if (type == FileType:1)
  881.             {
  882.                 new var1;
  883.                 if (!StrEqual("..", path, false))
  884.                 {
  885.                     decl String:MoreR[256];
  886.                     Format(MoreR, 255, "%s/%s", More, path);
  887.                     RecursiveDir(MoreR);
  888.                     RemoveDir(MoreR);
  889.                 }
  890.             }
  891.         }
  892.         return 0;
  893.     }
  894.     return 0;
  895. }
Advertisement
Add Comment
Please, Sign In to add comment