The interaction between AMX and DLL
#1

Hey guys.

I have a problem. But im not sure whether the SAMP structure allows me to solve this problem:
I want to have a callback in my plugin that is called anytime the server changes a player's health using SetPlayerHealth();

Код:
// Short problem demonstration
// native plugin_SetPlayerHealth(..); is defined

public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger)
{
     SetPlayerHealt(playerid,50.0f);
     plugin_SetPlayerHealth(...); // that sucks. I want to recognize it automaticly! :)
     return 1;
}
OK. How can I archieve that?
__________________________________________________ _____________________________________________
1st idea:

I register a callback in my DLL and name it "SetPlayerHealth":

Код:
AMX_NATIVE_INFO HelloWorldNatives[ ] =
{
	{ "SetPlayerHealth",    PlayerHealthSet},
	{ 0,                    0}
};

static long AMX_NATIVE_CALL PlayerHealthSet( AMX* amx, cell* params )
{
    // Do something here
	return 1;
}
That does not work: The SAMP Server functions (SetPlayerHealth,...) have a higher priority.

Well can anyone please help me?

Thank you.
Reply
#2

Do you have access to the gamemode / include files or needs it be done ONLY through a plugin?
if ONLY through a plugin you're be likely needing to do some memory hacking which I cannot help you much with ;P
Reply
#3

I may have misunderstood your question as I'm reading quickly, however;
Why don't you just make yourself a separate function, then call your callback from there via hooking SetPlayerHealth(..) (the SAMP native).

I'm not a plugin scripter, though this is achievable in PAWN:
pawn Код:
forward MyNewCallback();

stock _SetPlayerHealth(playerid, Float:health)
{
     SetPlayerHealth(playerid, health);
     if(funcidx("MyNewCallback") != -1) MyNewCallback();
     //Ensure it exists, if so then call it.
     return 1;
}
#define SetPlayerHealth _SetPlayerHealth

public MyNewCallback()
{
     //The end-user can enter there stuff in here?
}
Reply
#4

I want to make an anticheat-plugin which automaticly recognizes server-side healthchanges.
(Thats neccesary to avoid false alarms)

My main goal is to create a plugin that is very simple to use, you just have to laod the plugin and then it acts on its own. (Kick,Ban,Ignore.. and so on can be defined by changing the configuration file).

I think a modern cheat-detection system should be abled to act on its own

The problem is that I dont want users to add all my callback definitions in their source code.
@Gamer_Z: No, I dont have access , btw I know about your anti-cheat plugin.
Reply
#5

Quote:
Originally Posted by webcode421F
Посмотреть сообщение
I want to make an anticheat-plugin which automaticly recognizes server-side healthchanges.
(Thats neccesary to avoid false alarms)

My main goal is to create a plugin that is very simple to use, you just have to add the name in the config and then it acts on his own. How my system finally will deal with detected cheaters can be defined in a config file.

The problem is that I dont want users to add all my callback definitions in their source code.
@Gamer_Z: No, I dont have access , btw I know about your anti-cheat plugin; This plugin is just a test...
Hmm you would need to catch all SetPlayerHealth Calls , which is very possible but I do not have the C++ skill to help you with that (yes yes, BUT I KNOW IT IS POSSIBLE xD).
Reply
#6

Quote:
Originally Posted by webcode421F
Посмотреть сообщение
The problem is that I dont want users to add all my callback definitions in their source code.
They don't have to with my example, all they have to do is add an #include <inc_name> in their script, which they'd probably have to do anyway to get everything 'hooked' so you can forward the data to your plugin, if you really want it to be 'instant'.
Reply
#7

Thanks funky1234! I got it!
Reply
#8

Quote:
Originally Posted by webcode421F
Посмотреть сообщение
Thanks funky1234! I got it!
Good!
Happy scripting!
(*Note: I'm not actually a plugin developer, but my method should work!)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)