SA-MP Forums Archive
[Include] New SA-MP callbacks! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] New SA-MP callbacks! (/showthread.php?tid=490436)

Pages: 1 2 3 4 5 6 7 8 9


Re: New SA-MP callbacks! - Evocator - 02.10.2014

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



Re: New SA-MP callbacks! - Rudy_ - 02.10.2014

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 ...


Re: New SA-MP callbacks! - Emmet_ - 03.10.2014

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.


Re: New SA-MP callbacks! - Emmet_ - 10.12.2014

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)
{
    // ...
}



Re: New SA-MP callbacks! - Lordzy - 31.12.2014

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.


Re: New SA-MP callbacks! - Emmet_ - 10.02.2015

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!


Re: New SA-MP callbacks! - Luis- - 10.02.2015

Awesome, thanks Emmet!


Re: New SA-MP callbacks! - Emmet_ - 13.03.2015

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.


Re: New SA-MP callbacks! - Sellize - 13.03.2015

I might use this in the future.

+rep


Re: New SA-MP callbacks! - vannesenn - 13.03.2015

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


Re: New SA-MP callbacks! - Emmet_ - 16.03.2015

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.


Re: New SA-MP callbacks! - Nabster - 21.03.2015

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


Re: New SA-MP callbacks! - Emmet_ - 21.03.2015

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


Re: New SA-MP callbacks! - ToiletDuck - 21.04.2015

@EDIT: i figure out


Re: New SA-MP callbacks! - N0FeaR - 14.12.2015

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


Re: New SA-MP callbacks! - blackhawk871 - 16.12.2015

OnPlayerFall does not seem to be working.


Re: New SA-MP callbacks! - Lucky13 - 24.01.2016

Really useful!


Re: New SA-MP callbacks! - Hellman92 - 20.02.2016

Fix OnPlayerFall.


Re: New SA-MP callbacks! - SyS - 20.02.2016

Good work brother +rep


Re: New SA-MP callbacks! - vannesenn - 21.02.2016

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