[Include] [New Player Callbacks] Version 1.4 - BigETI
#1

Here I want to introduce you an include, where you'll be able to write inside more callbacks

What are callbacks?
Callbacks are functions which will be called if something performed an action.

What are now the callbacks which includes in this include?

pawn Код:
public OnPlayerEnteredVehicle(playerid, vehicleid, seatid)
public OnPlayerExitedVehicle(playerid, vehicleid)
public OnPlayerSkinChange(playerid, oldskin, newskin)
public OnPlayerHoldWeaponChange(playerid, oldslot, oldweapon, newslot, newweapon)
public OnPlayerWeaponStateChange(playerid, oldstate, newstate)
public OnPlayerWeaponDataChange(playerid, slot, oldweapon, newweapon)
public OnPlayerAmmoDataChange(playerid, slot, oldammo, newammo)
public OnPlayerMoneyChange(playerid, oldmoney, newmoney)
public OnPlayerHealthChange(playerid, Float:oldhealth, Float:newhealth)
public OnPlayerArmourChange(playerid, Float:oldarmour, Float:newarmour)
public OnPlayerAnimationIndexChange(playerid, oldindex, newindex)
public OnPlayerTargetPlayer(playerid, oldtarget, newtarget, bool:istargeting)
public OnPlayerSpecialActionChange(playerid, oldsaction, newsaction)
public OnPlayerAnalogKeysChange(playerid, oldy, newy, oldx, newx)
public OnPlayerXYZChange(playerid, Float:oldx, Float:oldy, Float:oldz, Float:newx, Float:newy, Float:newz)
public OnPlayerVehicleHealthChange(playerid, vehicleid, Float:oldhealth, Float:newhealth, bool:isissuer)
public OnPlayerVirtualWorldChange(playerid, oldworld, newworld)
//Optional callbacks below
public OnPVarDelete(playerid, varname[], oldtype)
public OnPVarCreate(playerid, varname[], type)
public OnPVarTypeChange(playerid, varname[], oldtype, newtype)
public OnPVarIntChange(playerid, varname[], oldint_value, newint_value)
public OnPVarStringChange(playerid, varname[], oldstring_value[], newstring_value[])
public OnPVarFloatChange(playerid, varname[], Float:oldfloat_value, Float:newfloat_value)
Usage:
Just add ncbs.inc in one of your script (For example a filterscript). Do not use this include more than one time. Use ncbs_forwads.inc at another scripts to get the remoted callbacks called in your scripts.
To remote callbacks you have to keep defined USE_IN_ALL_SCRIPTS.
ncbs_defines.inc makes you able to define parameters you need.

Example of adding those includes:

Adding ncbs.inc into my filterscript:

pawn Код:
#define FILTERSCRIPT
#include <ncbs>
public OnFilterScriptInit()
{
    print("\n------------------------");
    print(" Example Filterscript...");
    print("------------------------\n");
    return 1;
}
Adding ncbs_forwards.inc into my gamemode:
pawn Код:
#include <ncbs_forwards>
main()
{
    print("\n--------------------");
    print(" Example Gamemode...");
    print("--------------------\n");
}
Description:
pawn Код:
public OnPlayerEnteredVehicle(playerid, vehicleid, seatid)
Gets called if the player has entered any vehicle.


pawn Код:
public OnPlayerExitedVehicle(playerid, vehicleid)
Gets called if the player has left his/her vehicle.
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerSkinChange(playerid, oldskin, newskin)
Gets called if the player changed his/her skin. (With SetPlayerSkin or mods).
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerHoldWeaponChange(playerid, oldslot, oldweapon, newslot, newweapon)
Gets called if the player changed the weapon on his/her hand.
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerWeaponStateChange(playerid, oldstate, newstate)
Gets called if the player has changed his/her weapon state (check https://sampwiki.blast.hk/wiki/Weapon_States).
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerWeaponDataChange(playerid, slot, oldweapon, newweapon)
Gets called if the player spawned/lost a weapon (Spawning mit GivePlayerWeapon or cheats).
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerAmmoDataChange(playerid, slot, oldammo, newammo)
Gets called if the player spawned ammo for a special weapon slot (Spawning with GivePlayerWeapon or cheats).
Returning 0 will deny updating the old variable.


pawn Код:
public OnPlayerMoneyChange(playerid, oldmoney, newmoney)
Gets called if the player has changed his/her money (With GivePlayerMoney oder Cheats)
Returning 0 will deny updating the old variable.


pawn Код:
public OnPlayerHealthChange(playerid, Float:oldhealth, Float:newhealth)
Gets called if the player's has been modified (Increasing at respawn, with SetPlayerHealth or cheats).
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerArmourChange(playerid, Float:oldarmour, Float:newarmour)
Gets called if the player's armour has been modified (Increasing with SetPlayerArmour or cheats).
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerAnimationIndexChange(playerid, oldindex, newindex)
Gets called if the player changed his/her animation.
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerTargetPlayer(playerid, oldtarget, newtarget, bool:istargeting)
Gets called if the player is aiming on a player or not.
Returning 0 will deny updating the old variable.


pawn Код:
public OnPlayerSpecialActionChange(playerid, oldsaction, newsaction)
Gets called if the player changed his/her special acton (with SetPlayerSpecialAction or mods/cheats).
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerAnalogKeysChange(playerid, oldy, newy, oldx, newx)
Gets called if the up, down, left and right buttons got touched.
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerVehicleHealthChange(playerid, vehicleid, Float:oldhealth, Float:newhealth, bool:isissuer)
Gets called if the player's vehicle health got changed.
Returning 0 will deny updating the old variable.



pawn Код:
public OnPlayerVirtualWorldChange(playerid, oldworld, newworld)
Gets called if the player changed properly his/her virtual world (Since virtual worlds are serversided so you can't modify it with cheats).
Returning 0 will deny using SetPlayerVirtualWorld.


Optional callbacks:
pawn Код:
public OnPVarDelete(playerid, varname[], oldtype)
Gets only called if a PVar has been deleted (check https://sampwiki.blast.hk/wiki/DeletePVar)


pawn Код:
public OnPVarCreate(playerid, varname[], type)
Gets only called if a PVar has been created.
Returning 0 will deny using SetPVarInt, SetPVarString or SetPVarFloat.



pawn Код:
public OnPVarTypeChange(playerid, varname[], oldtype, newtype)
Gets only called if the PVar type has been changed.
Returning 0 will deny using SetPVarInt, SetPVarString or SetPVarFloat.



pawn Код:
public OnPVarIntChange(playerid, varname[], oldint_value, newint_value)
Gets only called if SetPVarInt changed its own value.
Returning 0 will deny using SetPVarInt.



pawn Код:
public OnPVarStringChange(playerid, varname[], oldstring_value[], newstring_value[])
Gets only called if SetPVarString changed its own value.
Returning 0 will deny using SetPVarString.



pawn Код:
public OnPVarFloatChange(playerid, varname[], Float:oldfloat_value, Float:newfloat_value)
Gets only called if SetPVarFloat changed its own value.
Returning 0 will deny using SetPVarFloat.


Known Bugs:
  • OnPlayerWeaponDataChange and OnPlayerAmmoDataChange gets only called if another action has been also executed (SA:MP fault)
  • There are some minor issues between multiple script (gonna release soon a better version)
  • No more bugs found..
Credits:
  • Added ALS hooking (made by ******)
  • Thanks to wups telling me how to return the callbacks properly by using funcidx
  • Giving me the idea for using an OPU delay to prevent overkill (cessil)
  • The SA:MP development team
  • Myself..
Updates:
  • Version 1.5: Added OnPlayerXYZChange and OnPlayerTargetPlayer (main idea: https://sampforum.blast.hk/showthread.php?tid=293525)
    All callbacks have to return a value else their old variable won't get updated and they get recalled after next delayed player update or even some callbacks will just deny executing some functions. (For example: SetPlayerVirtualWorld, SetPVarInt, SetPVarFloat, SetPVarString, DeletePVar etc.)
  • Version 1.4: Added OnPlayerChangeMoney, OnPlayerEnteredVehicle, OnPlayerExitedVehicle, OnPlayerAnalogKeysChange and OnPlayerVehicleHealthChange.
    The callbacks are now callable at another scripts.
    new_callbacks.inc has been renamed to ncbs.inc
    Added ncbs_forwards.inc (Used to use the callbacks at another scripts)
    Added ncbs_defines.inc (Used to change changable defined parameters)
    Some major/minor bug fixes..
  • Version 1.3: Includes OnPlayerUpdate delay (idea from cessil's OPU delay for anti cheats)
    Every single (I mean really every single!) callback is now choosable.
    Improved speed for some callbacks.
    Bug fixes..
  • Version 1.2: Using the ALS hooking method (made by ******) and using the correct method of returning existing/non existing callbacks (suggestion from wups)
    OnPVar callbacks are now optional (uncomment the USE_PVAR_CALLBACKS define inside the include to make use of the PVar callbacks)
  • Version 1.1: Added OnPlayerSpecialActionChange callback.
  • Version 1: First release!
Where I can download this file?


New:
Download the 1.5 package at Solidfiles
or
Pastebin Download 1.5 (ncbs.inc)
Pastebin Download 1.5 (ncbs_forwards.inc)
Pastebin Download 1.5 (ncbs_defines.inc)

Old:
Download the 1.4 package at Solidfiles
or
Pastebin Download 1.4 (ncbs.inc)
Pastebin Download 1.4 (ncbs_forwards.inc)
Pastebin Download 1.4 (ncbs_defines.inc)

Please report for any bugs!

Regards: BigETI
Reply


Messages In This Thread
[New Player Callbacks] Version 1.5 (SA:MP 0.3d RC7 or higher required) - BigETI - by BigETI - 01.09.2011, 19:38
Re: [New Player Callbacks] Version 1 - BigETI - by LZLo - 01.09.2011, 19:44
Re: [New Player Callbacks] Version 1 - BigETI - by Improvement™ - 01.09.2011, 19:48
Re: [New Player Callbacks] Version 1 - BigETI - by Speed - 01.09.2011, 19:48
Re: [New Player Callbacks] Version 1 - BigETI - by BigETI - 01.09.2011, 20:06
Re: [New Player Callbacks] Version 1 - BigETI - by [03]Garsino - 01.09.2011, 20:10
Re: [New Player Callbacks] Version 1 - BigETI - by BigETI - 01.09.2011, 20:31
Re: [New Player Callbacks] Version 1 - BigETI - by steki. - 01.09.2011, 21:11
Re: [New Player Callbacks] Version 1 - BigETI - by Rock_Ro - 01.09.2011, 21:45
Re : [New Player Callbacks] Version 1 - BigETI - by Velko - 02.09.2011, 09:05
Re: [New Player Callbacks] Version 1 - BigETI - by IstuntmanI - 02.09.2011, 09:21
Re: [New Player Callbacks] Version 1 - BigETI - by BigETI - 02.09.2011, 11:38
Re: [New Player Callbacks] Version 1 - BigETI - by wups - 02.09.2011, 12:23
Re: [New Player Callbacks] Version 1 - BigETI - by Darnell - 02.09.2011, 12:44
Re: [New Player Callbacks] Version 1 - BigETI - by BigETI - 02.09.2011, 14:16
Re: [New Player Callbacks] Version 1 - BigETI - by wups - 02.09.2011, 14:25
Re: [New Player Callbacks] Version 1.2 - BigETI - by BigETI - 06.09.2011, 01:40
AW: [New Player Callbacks] Version 1.4 - BigETI - by BigETI - 27.09.2011, 17:45
Re: [New Player Callbacks] Version 1.2 - BigETI - by [DOG]irinel1996 - 27.09.2011, 18:27
AW: [New Player Callbacks] Version 1.4 - BigETI - by BigETI - 27.09.2011, 18:30
Re: [New Player Callbacks] Version 1.4 - BigETI - by Mikkel_Pedersen - 27.09.2011, 18:33
AW: [New Player Callbacks] Version 1.4 - BigETI - by BigETI - 27.09.2011, 18:41
[New Player Callbacks] Version 1.5 (SA:MP 0.3d RC7 or higher required) - BigETI - by BigETI - 29.10.2011, 09:43
Re: [New Player Callbacks] Version 1.4 - BigETI - by mineralo - 09.04.2012, 20:14

Forum Jump:


Users browsing this thread: 1 Guest(s)