[Include] New SA-MP callbacks!

Quote:
Originally Posted by Rudy_
Посмотреть сообщение
Nice, Shouldn't OnPlayerBurning be OnPlayerStartBurning?
Well...
Код:
public OnPlayerBurning(playerid, status)
{
    if (status)
    {
        // Started burning
    }
    else
    {
        // Stopped burning
    }
    return 1;
}
Reply

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Well...
Код:
public OnPlayerBurning(playerid, status)
{
    if (status)
    {
        // Started burning
    }
    else
    {
        // Stopped burning
    }
    return 1;
}
What?
I was saying OnPlayerStartBurning (for the name) is much better ...
Reply

I decided to go with "OnPlayerBurning" and added "status" parameter (1 = burning, 0 = stopped burning). IMO, it's better to have one callback for the same action rather than having 2. I'll add it, if you want.
Reply

There will be no lag. I ran this on a server with 50+ players flawlessly. Let's take this snippet from callbacks.inc:

pawn Код:
if (g_bCallbacks & CB_OnPlayerBurning)
    {
        if (g_cbPlayers[playerid][e_cbFlags] & e_cbBurning)
        {
            if ((GetTickCount() - g_cbPlayers[playerid][e_cbLastBurn]) >= 1500)
            {
                g_cbPlayers[playerid][e_cbFlags] &= ~e_cbBurning;
                CallLocalFunction("OnPlayerBurning", "dd", playerid, 0);
            }
        }
    }
This section of code will only be called if "OnPlayerBurning" is defined in the other script, e.g:

pawn Код:
#include <a_samp>
#include <callbacks>

public OnPlayerBurning(playerid, status)
{
    // ...
}
Reply

I just noticed now that OnPlayerTakeDamage on this include isn't properly hooked. I know that Emmet_ is inactive now but since this include is being used by members, I'm posting the fixed OnPlayerTakeDamage part of it here. I've also posted a pull-request regarding it on it's GitHub repository.

pawn Код:
//Replace the old one with this
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
{
    if (g_bCallbacks & CB_OnPlayerBurning && weaponid == 37)
    {
        if (!(g_cbPlayers[playerid][e_cbFlags] & e_cbBurning))
        {
            g_cbPlayers[playerid][e_cbFlags] |= e_cbBurning;
            CallLocalFunction("OnPlayerBurning", "dd", playerid, 1);
        }
        g_cbPlayers[playerid][e_cbLastBurn] = GetTickCount();
    }
    #if defined CB_OnPlayerTakeDamage
        return CB_OnPlayerTakeDamage(playerid, issuerid, amount, weaponid, bodypart);
    #else
        return 1;
    #endif
}
Thanks to Kyance for posting an issue about this which led me to find out.
Reply

It's been more than 4 months since I've updated this..

I am planning on updating this in the next few days. I've discovered some new detection methods and found some bugs. I don't want to abandon this project because of my laziness lol. Anyway.. stay tuned for more news, and I thank everyone for using it!
Reply

Awesome, thanks Emmet!
Reply

Another update:

Код:
- Rewrote a lot of the code.

- Added better code to detect if a player is falling.

- Renamed a few callbacks:
   OnPlayerCarJack -> OnPlayerJackVehicle
   OnPlayerWeaponEmpty -> OnPlayerEmptyWeapon
   OnPlayerDisableCursor -> OnPlayerHideCursor
   OnPlayerAnimationFinish -> OnPlayerAnimationPlay

- Removed OnPlayerTakePicture. This caused some issues and didn't work properly.

- Removed the "Float:height" parameter from OnPlayerFall due to inaccuracy.
And 2 new callbacks:

pawn Код:
public OnPlayerActionChange(playerid, oldaction, newaction)
{
    return 1;
}

public OnPlayerRamPlayer(playerid, driverid, vehicleid, Float:damage)
{
    return 1;
}
Functions for the new callbacks:

pawn Код:
stock GetPlayerAction(playerid);
stock IsPlayerSkydiving(playerid);
stock IsPlayerSwimming(playerid);
Action types for OnPlayerActionChange:

pawn Код:
#define PLAYER_ACTION_NONE      (0)
#define PLAYER_ACTION_SHOOTING  (1)
#define PLAYER_ACTION_SWIMMING  (2)
#define PLAYER_ACTION_SKYDIVING (3)
#define PLAYER_ACTION_JUMPING   (4)
Example is in the first post.

Thanks for using this everybody! This update is proof that I haven't abandoned this project at all. I will update this project as long as I'm still playing SA:MP.
Reply

I might use this in the future.

+rep
Reply

Quote:
Originally Posted by Emmet_
Посмотреть сообщение
Another update:

Код:
- Rewrote a lot of the code.

- Added better code to detect if a player is falling.

- Renamed a few callbacks:
   OnPlayerCarJack -> OnPlayerJackVehicle
   OnPlayerWeaponEmpty -> OnPlayerEmptyWeapon
   OnPlayerDisableCursor -> OnPlayerHideCursor
   OnPlayerAnimationFinish -> OnPlayerAnimationPlay

- Removed OnPlayerTakePicture. This caused some issues and didn't work properly.

- Removed the "Float:height" parameter from OnPlayerFall due to inaccuracy.
And 2 new callbacks:

pawn Код:
public OnPlayerActionChange(playerid, oldaction, newaction)
{
    return 1;
}

public OnPlayerRamPlayer(playerid, driverid, vehicleid, Float:damage)
{
    return 1;
}
Functions for the new callbacks:

pawn Код:
stock GetPlayerAction(playerid);
stock IsPlayerSkydiving(playerid);
stock IsPlayerSwimming(playerid);
Action types for OnPlayerActionChange:

pawn Код:
#define PLAYER_ACTION_NONE      (0)
#define PLAYER_ACTION_SHOOTING  (1)
#define PLAYER_ACTION_SWIMMING  (2)
#define PLAYER_ACTION_SKYDIVING (3)
#define PLAYER_ACTION_JUMPING   (4)
Example is in the first post.

Thanks for using this everybody! This update is proof that I haven't abandoned this project at all. I will update this project as long as I'm still playing SA:MP.
Very nice! I'll use it
Reply

Added two more callbacks:

pawn Код:
// Called when a player uses a camera to take a picture.
public OnPlayerUseCamera(playerid);

// Called when a player sprays at a vehicle with a spraycan.
public OnPlayerSprayAtVehicle(playerid, vehicleid);
And a function for one of the two new callbacks:

pawn Код:
stock IsPlayerSprayingVehicle(playerid, vehicleid);
Now there are 23 callbacks in total!

I did some benchmarks while running this include on a public server with only 2 callbacks being used. There was barely any lag. So you shouldn't worry about that.
Reply

Why does it give me this errors?

C:\Users\Trayansh\Desktop\SAMP\pawno\include\callb acks.inc(501) : warning 219: local variable "health" shadows a variable at a preceding level
C:\Users\Trayansh\Desktop\SAMP\pawno\include\callb acks.inc(823) : warning 219: local variable "health" shadows a variable at a preceding level

i checked line 501 and 823,those lines are not related to health
Reply

You probably have a global variable called "health" in your gamemode. Rename or remove it
Reply

@EDIT: i figure out
Reply

Quote:
Originally Posted by JacobTr
Посмотреть сообщение
when I compile my gamemode, I get this error.
C:\Users\Jacob\Desktop\Pawn\pawno\include\ncbs.inc (812) : error 025: function heading differs from prototype
That is this section of code:
Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid, bodypart)
Remove it from the include u downloaded cus this callback is already added into samp

https://sampwiki.blast.hk/wiki/OnPlayerTakeDamage
Reply

OnPlayerFall does not seem to be working.
Reply

Really useful!
Reply

Fix OnPlayerFall.
Reply

Good work brother +rep
Reply

Quote:
Originally Posted by Hellman92
Посмотреть сообщение
Fix OnPlayerFall.
He left SAMP, I think he won't go back anymore.
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)