Posts: 1,323
Threads: 24
Joined: Nov 2010
Reputation:
91
03-05-2012, 07:44
(This post was last modified: 03-05-2012, 07:45 by zxz0O0.)
(03-04-2012, 13:19)zxz0O0 Wrote: Why address? Just do in your plugin
CSHARP Code
SetDvar("perk_sprintMultiplier", "999");
First Code: Add this ^ OnMapChange().
Second code:
Define
Code: perk_sprintMultiplier_var
as a string (don't convert to int) then do like this OnMapChange()
CSHARP Code
SetDvar("perk_sprintMultiplier", perk_sprintMultiplier_var);
Posts: 126
Threads: 13
Joined: Nov 2011
Reputation:
5
03-05-2012, 14:58
(This post was last modified: 03-05-2012, 15:00 by blueberry9.)
(03-05-2012, 07:44)zxz0O0 Wrote: (03-04-2012, 13:19)zxz0O0 Wrote: Why address? Just do in your plugin
CSHARP Code
SetDvar("perk_sprintMultiplier", "999");
First Code: Add this ^ OnMapChange().
Second code:
Define
Code: perk_sprintMultiplier_var
as a string (don't convert to int) then do like this OnMapChange()
CSHARP Code
SetDvar("perk_sprintMultiplier", perk_sprintMultiplier_var);
ok, i did.
it didn't work.
to clarify, the plugin changed the dvar in the server.
i checked it.
but it didn't change the sprint duration
source code:
Code: using System;
using System.Runtime.InteropServices;
using System.Security;
using Addon;
//Compile with /unsafe
//And a reference to "addon/dist/addon.dll"
namespace SprintExtend
{
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);
unsafe public override void OnMapChange()
{
ServerPrint("Plugin: SprintExtend by blueberry9 and zxz0O0 loaded.");
SetDvar("perk_sprintMultiplier", "999");
}
}
}
Posts: 1,323
Threads: 24
Joined: Nov 2010
Reputation:
91
03-05-2012, 15:23
(This post was last modified: 03-05-2012, 15:28 by zxz0O0.)
Of course it doesn't work if you removed now the stuff that changes it
You still need the WriteProcessMemory stuff, I said add not replace
CSHARP Code
using System; using System.Runtime.InteropServices; using System.Security; using Addon; //Compile with /unsafe //And a reference to "addon/dist/addon.dll" namespace SprintExtend { 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("perk_sprintMultiplier", "999"); } unsafe public override void OnServerLoad() { ServerPrint("Plugin: Sprint_Multiplier by blueberry9 and zxz0O0 loaded."); int oP; byte[] bytes = { 0x90, 0x90 }; WriteProcessMemory(((IntPtr)(-1)), 0x0040C877, bytes, bytes.Length, out oP); } } }
Just FYI: The WriteProcessMemory stuff patches the server so the server thinks everyone has Marathon Perk. If you set dvars it's better to set them OnMapChange(), it's also possible OnServerLoad() but it may crash the server.
Posts: 126
Threads: 13
Joined: Nov 2011
Reputation:
5
03-05-2012, 15:25
(This post was last modified: 03-05-2012, 15:37 by blueberry9.)
(03-05-2012, 15:23)zxz0O0 Wrote: Of course it doesn't work if you removed now the stuff that changes it
You still need the WriteProcessMemory stuff, I said add not replace
[code=csharp]using System;
using System.Runtime.InteropServices;
using System.Security;
using Addon;
//Compile with /unsafe
//And a reference to "addon/dist/addon.dll"
namespace SprintExtend
{
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("perk_sprintMultiplier", "999");
}
unsafe public override void OnServerLoad()
{
ServerPrint("Plugin: Sprint_Multiplier by blueberry9 and zxz0O0 loaded.");
int oP;
byte[] bytes = { 0x90, 0x90 };
WriteProcessMemory(((IntPtr)(-1)), 0x0040C877, bytes, bytes.Length, out oP);
}
}
}
ok.
doh.
fixing...
that worked.
finally!!!
Z, i owe you man.
no one else was willing to take the time to help me.
much appreciated!
i owe you man!
|