Code Monkey home page Code Monkey logo

pawn-plus-hooks's Introduction

pawn-plus-hooks

sampctl

Installation

Simply install to your project:

sampctl package install AGraber/pawn-plus-commands

Include in your code and begin using the library:

#include <PawnPlusCMD>

Usage

If you're familiar with y_hooks then the syntax will be familiar:

#include <pp-hooks>
hook OnPlayerEnterDynArea(playerid, areaid)
{
    new string[145];
    format(string, sizeof string, "You entered area id %d", areaid);
    SendClientMessage(playerid, -1, string);
}


#include <pp-hooks>
hook OnPlayerEnterDynArea(playerid, areaid)
{
    printf("playerid %d entered areaid %d", playerid, areaid);
}

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);
}

hook ret OnPlayerUpdate(&ret, playerid)
{
    if(IsPlayerCheating(playerid))
    {
        // set return to 0 to desync
        ret = 0;
        // return non-zero to use that ret value
        return 1;
    }
}

You can change the default hook method (used by the hook and hook public macros) by defining PP_DEFAULT_PUBLIC_HOOK_METHOD to the desired method.

If the hook returns a non-zero value, the following hooks and the base callback won't be executed and that value (or the one at ret if it's a ret hook) will be returned.

Thanks

  • Y_Less: YSI macros used for reference
  • IllidanS4: PawnPlus

pawn-plus-hooks's People

Contributors

agraber avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

rizlone hreesang

pawn-plus-hooks's Issues

Hook Get natives

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.