Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hook Get natives #1

Open
fl0w3rs opened this issue Sep 8, 2020 · 4 comments
Open

Hook Get natives #1

fl0w3rs opened this issue Sep 8, 2020 · 4 comments

Comments

@fl0w3rs
Copy link

fl0w3rs commented Sep 8, 2020

For example, I need to hook GetPlayerPos native to replace the return value (not quite return, but I think you got the point).
How can I do this?

I've already tried

#include <pp-hooks>
hook native GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z) {
    if(admin[playerid][admin_invisible]) {
        x = admin[playerid][admin_real_pos][0];
        y = admin[playerid][admin_real_pos][1];
        z = admin[playerid][admin_real_pos][2];
        return true;
    }
    return GetPlayerPos(playerid, x, y, z);
}

But it brokes SpawnPlayer like there -> IS4Code/PawnPlus#39

@fl0w3rs
Copy link
Author

fl0w3rs commented Sep 9, 2020

hook native GetPlayerPos(playerid, &Float:x, &Float:y, &Float:z) {
    return GetPlayerPos(playerid, x, y, z);
}

With this (upper) doesn't work too, but with example (below) it perfectly works

hook native SetPlayerPos(playerid, Float:x, Float:y, Float:z)
{
    // Not recursive: calls next hook or the native
    return SetPlayerPos(playerid, x, y, z + 1.0);
}

@ADRFranklin
Copy link

Could you explain in more detail, why this doesn't work? Like what are you expecting it to do, and what are you getting instead?

@fl0w3rs
Copy link
Author

fl0w3rs commented Sep 10, 2020

Could you explain in more detail, why this doesn't work? Like what are you expecting it to do, and what are you getting instead?

With Pawn.RakNet I made invisibility for administration (z coordinate = 6666). In admin[playerid][admin_real_pos][0-2] their real coordinates are written. I hook GetPlayerPos to replace the player's position if he is invisible. In return I get a broken server.

@fl0w3rs
Copy link
Author

fl0w3rs commented Sep 10, 2020

This time everything is a little different. I use mdialog, the dialog is created but the response is not called.
https://pastebin.com/VV8yxMm6
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants