01.09.2011, 19:38
(
Последний раз редактировалось BigETI; 06.01.2012 в 20:27.
)
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?
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:
Adding ncbs_forwards.inc into my gamemode:
Description:
Gets called if the player has entered any vehicle.
Gets called if the player has left his/her vehicle.
Returning 0 will deny updating the old variable.
Gets called if the player changed his/her skin. (With SetPlayerSkin or mods).
Returning 0 will deny updating the old variable.
Gets called if the player changed the weapon on his/her hand.
Returning 0 will deny updating the old variable.
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.
Gets called if the player spawned/lost a weapon (Spawning mit GivePlayerWeapon or cheats).
Returning 0 will deny updating the old variable.
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.
Gets called if the player has changed his/her money (With GivePlayerMoney oder Cheats)
Returning 0 will deny updating the old variable.
Gets called if the player's has been modified (Increasing at respawn, with SetPlayerHealth or cheats).
Returning 0 will deny updating the old variable.
Gets called if the player's armour has been modified (Increasing with SetPlayerArmour or cheats).
Returning 0 will deny updating the old variable.
Gets called if the player changed his/her animation.
Returning 0 will deny updating the old variable.
Gets called if the player is aiming on a player or not.
Returning 0 will deny updating the old variable.
Gets called if the player changed his/her special acton (with SetPlayerSpecialAction or mods/cheats).
Returning 0 will deny updating the old variable.
Gets called if the up, down, left and right buttons got touched.
Returning 0 will deny updating the old variable.
Gets called if the player's vehicle health got changed.
Returning 0 will deny updating the old variable.
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:
Gets only called if a PVar has been deleted (check https://sampwiki.blast.hk/wiki/DeletePVar)
Gets only called if a PVar has been created.
Returning 0 will deny using SetPVarInt, SetPVarString or SetPVarFloat.
Gets only called if the PVar type has been changed.
Returning 0 will deny using SetPVarInt, SetPVarString or SetPVarFloat.
Gets only called if SetPVarInt changed its own value.
Returning 0 will deny using SetPVarInt.
Gets only called if SetPVarString changed its own value.
Returning 0 will deny using SetPVarString.
Gets only called if SetPVarFloat changed its own value.
Returning 0 will deny using SetPVarFloat.
Known Bugs:
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
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)
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;
}
pawn Код:
#include <ncbs_forwards>
main()
{
print("\n--------------------");
print(" Example Gamemode...");
print("--------------------\n");
}
pawn Код:
public OnPlayerEnteredVehicle(playerid, vehicleid, seatid)
pawn Код:
public OnPlayerExitedVehicle(playerid, vehicleid)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerSkinChange(playerid, oldskin, newskin)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerHoldWeaponChange(playerid, oldslot, oldweapon, newslot, newweapon)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerWeaponStateChange(playerid, oldstate, newstate)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerWeaponDataChange(playerid, slot, oldweapon, newweapon)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerAmmoDataChange(playerid, slot, oldammo, newammo)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerMoneyChange(playerid, oldmoney, newmoney)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerHealthChange(playerid, Float:oldhealth, Float:newhealth)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerArmourChange(playerid, Float:oldarmour, Float:newarmour)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerAnimationIndexChange(playerid, oldindex, newindex)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerTargetPlayer(playerid, oldtarget, newtarget, bool:istargeting)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerSpecialActionChange(playerid, oldsaction, newsaction)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerAnalogKeysChange(playerid, oldy, newy, oldx, newx)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerVehicleHealthChange(playerid, vehicleid, Float:oldhealth, Float:newhealth, bool:isissuer)
Returning 0 will deny updating the old variable.
pawn Код:
public OnPlayerVirtualWorldChange(playerid, oldworld, newworld)
Returning 0 will deny using SetPlayerVirtualWorld.
Optional callbacks:
pawn Код:
public OnPVarDelete(playerid, varname[], oldtype)
pawn Код:
public OnPVarCreate(playerid, varname[], type)
Returning 0 will deny using SetPVarInt, SetPVarString or SetPVarFloat.
pawn Код:
public OnPVarTypeChange(playerid, varname[], oldtype, newtype)
Returning 0 will deny using SetPVarInt, SetPVarString or SetPVarFloat.
pawn Код:
public OnPVarIntChange(playerid, varname[], oldint_value, newint_value)
Returning 0 will deny using SetPVarInt.
pawn Код:
public OnPVarStringChange(playerid, varname[], oldstring_value[], newstring_value[])
Returning 0 will deny using SetPVarString.
pawn Код:
public OnPVarFloatChange(playerid, varname[], Float:oldfloat_value, Float:newfloat_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..
- 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..
- 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!
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