09-01-2012, 07:26
ive been trying to make a god mode plugin..
when i try to compile it, i get an error saying: unsafe code may only appear when compiling/ with unsafe..
i dont really know what to do to fix that error.. im guessing that i have to add an exception to the addon.dll in the addon folder so that it will allow me to compile it even though it says its not safe....
im trying to make the plugin for 1.4.382 version....
i watched a vid from its mods on making plugins and they said to use 3.0 framework, but when i use that version, theres like 10 errrors, but on version 4.0 i dont get any...
sorry if im being a noob... this is my first time making a plugin
here is the soruce code:
using System;
using System.Runtime.InteropServices;
using System.Security;
using Addon;
namespace GODMODE_1_0
{
public class Program : CPlugin
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteProcessMemory(IntPtr hProcess, int lpBaseAddress, byte[] lpBuffer, int nSize, out int lpNumberOfBytesWritten);
public override void OnMapChange()
{
SetDvar(" scr_player_maxhealth", "999");
}
unsafe public override void OnServerLoad()
{
ServerPrint("Plugin: GOD MODE made by th3oolbro has been loaded");
int oP;
byte[] bytes = { 0x90, 0x90 };
WriteProcessMemory(((IntPtr)(-1)), 0x40C8D7, bytes, bytes.Length, out oP);
}
}
}
when i try to compile it, i get an error saying: unsafe code may only appear when compiling/ with unsafe..
i dont really know what to do to fix that error.. im guessing that i have to add an exception to the addon.dll in the addon folder so that it will allow me to compile it even though it says its not safe....
im trying to make the plugin for 1.4.382 version....
i watched a vid from its mods on making plugins and they said to use 3.0 framework, but when i use that version, theres like 10 errrors, but on version 4.0 i dont get any...
sorry if im being a noob... this is my first time making a plugin
here is the soruce code:
using System;
using System.Runtime.InteropServices;
using System.Security;
using Addon;
namespace GODMODE_1_0
{
public class Program : CPlugin
{
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool WriteProcessMemory(IntPtr hProcess, int lpBaseAddress, byte[] lpBuffer, int nSize, out int lpNumberOfBytesWritten);
public override void OnMapChange()
{
SetDvar(" scr_player_maxhealth", "999");
}
unsafe public override void OnServerLoad()
{
ServerPrint("Plugin: GOD MODE made by th3oolbro has been loaded");
int oP;
byte[] bytes = { 0x90, 0x90 };
WriteProcessMemory(((IntPtr)(-1)), 0x40C8D7, bytes, bytes.Length, out oP);
}
}
}