using System;
using System.Collections.Generic;
using System.Text;
using Addon;
using System.Runtime.InteropServices;
using System.Timers;
namespace fundrop
{
public class Class1 : CPlugin
{
private static Timer random;
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteProcessMemory(IntPtr hProcess, int lpBaseAddress, byte[] lpBuffer, int nSize, out int lpNumberOfBytesWritten);
unsafe public override void OnServerLoad()
{
ServerPrint("FunDrop Plugin by YAMRAJ");
int oP;
byte[] bytes = { 0x90, 0x90, 0x90, 0x90, 0x90, 0x90 };
WriteProcessMemory(((IntPtr)(-1)), 0x0047EFD2, bytes, bytes.Length, out oP);
if (GetServerCFG("FunDrop", "Random", "-1") == "-1")
{
SetServerCFG("FunDrop", "Random", "0");
}
if (GetServerCFG("FunDrop", "Time", "-1") == "-1")
{
SetServerCFG("FunDrop", "Time", "45");
}
string Time = GetServerCFG("FunDrop", "Time", "");
int time = Convert.ToInt32(Time);
random
= new Timer
(1000 * time
); random.
Elapsed += new ElapsedEventHandler
(randomize
); if (GetServerCFG("FunDrop", "Random", "") == "1")
{
random.Start();
}
}
private void randomize(object sender, ElapsedEventArgs ea)
{
List
<string> items
= new List
<string> { "ac130_105mm_mp",
"remotemissile_projectile_mp",
"sam_projectile_mp",
"ims_projectile_mp",
"remote_mortar_missile_mp",
"remote_tank_projectile_mp" }; /* Removed the long list :-)
* just the 6 below
* ORIGINAL: List<string> items = new List<string> { "frag_grenade_mp", "semtex_mp", "flash_grenade_mp", "concussion_grenade_mp", "smoke_grenade_mp", "emp_grenade_mp", "ac130_105mm_mp", "remotemissile_projectile_mp", "rpg_mp", "stinger_mp", "javelin_mp", "sam_projectile_mp", "ims_projectile_mp", "remote_mortar_missile_mp", "remote_tank_projectile_mp" };
*/
Random items_rand
= new Random
(); int index = items_rand.Next(0, 6);
/* Modified to handle 6 choices instead of 15 :-)
* ORIGINAL: int index = items_rand.Next(0, 15);
*/
string value = items[index];
SetDvar("perk_grenadedeath", value);
// yep thats all, just enable randommode in serverconfig, and no hassle with chat and client messages <img src="https://www.itsmods.com/forum/images/smilies/tongue.gif" alt="Tongue" title="Tongue" class="smilie smilie_5" />
// all credits go to YAMRAJ i just stripped out the chat-commands and a few drop choices <img src="https://www.itsmods.com/forum/images/smilies/smile.gif" alt="Smile" title="Smile" class="smilie smilie_1" />
}
}
}