22.12.2012, 12:01
a_state - Adds more callback checking change state!
Introduction
This include adds more change state callback not only just OnPlayerKeyStateChange.
Not sure but, If you are using default fightstyle. The OnPlayerFStyleChangeState will return as "Old Style: x | New Style: 4". To call the StateChange callbacks you need to modify the following functions
Код:
SetPlayerFightingStyle SetPlayerWantedLevel SetPlayerTime GivePlayerMoney ResetPlayerMoney SetPlayerPos SetPlayerHealth SetPlayerArmour SetPlayerScore SetPlayerDrunkLevel SetPlayerSkin SetPlayerName
"SetPlayerTime" change it to "SetPlayerTimeEx"
Any changes in function?
Yes, 10% of the function has been modified.
Function name has been renamed added with Ex tag.
Function works the same. But this time. They call a public callback.
Like if you use SetPlayerPos. The "OnPlayerPositionStateChange" will be called.
Callbacks and It's explanation
Код:
OnPlayerFStyleStateChange(playerid, newstyle, oldstyle)
Callback: Integer
Код:
OnPlayerWLStateChange(playerid, newwl, oldwl)
Callback: Integer
Код:
OnPlayerTimeStateChange(playerid, newtime, oldtime, newtime2, oldtime2)
Callback: Integer
Код:
OnPlayerMoneyStateChange(playerid, newcash, oldcash)
Callback: Integer
Код:
OnPlayerNameStateChange(playerid, newname[], oldname[])
Callback: String. This is the only callback who uses string.
Код:
OnPlayerSkinStateChange(playerid, newskin, oldskin)
Callback: Integer
Код:
OnPlayerDLStateChange(playerid, newdl, olddl)
Callback: Integer
Код:
OnPlayerScoreStateChange(playerid, newscore, oldscore)
Callback: Integer
Код:
OnPlayerHealthStateChange(playerid, Float:newhealth, Float:oldhealth)
Callback: Float
Код:
OnPlayerArmourStateChange(playerid, Float:newarmour, Float:oldarmour)
Callback: Float
Код:
OnPlayerPositionStateChange(playerid, Float:newposX, Float:newposY, Float:newposZ, Float:oldposX, Float:oldposY, Float:oldposZ)
Callback: Float
Examples:
pawn Код:
public OnPlayerFStyleStateChange(playerid, newstyle, oldstyle)
{
new str[128];
format(str, sizeof(str), "New Style: %i | Old Style: %i", newstyle, oldstyle);
SendClientMessage(playerid, -1, str);
return 1;
}
public OnPlayerNameStateChange(playerid, newname[], oldname[])
{
new str[128];
format(str, sizeof(str), " %s | %s", newname, oldname);
SendClientMessage(playerid, -1, str);
return 1;
}
public OnPlayerHealthStateChange(playerid, Float:newhealth, Float:oldhealth)
{
new str[128];
format(str, sizeof(str), " %f | %f", newhealth, oldhealth);
SendClientMessage(playerid, -1, str);
return 1;
}
public OnPlayerPositionStateChange(playerid, Float:newposX, Float:newposY, Float:newposZ, Float:oldposX, Float:oldposY, Float:oldposZ)
{
new str[128];
format(str, sizeof(str), " %f, %f, %f | %f, %f, %f", newposX, newposY, newposZ, oldposX, oldposY, oldposZ);
SendClientMessage(playerid, -1, str);
return 1;
}
No bugs current found.
Notes
• The state callbacks only work when you use the function. They never get called if you don't use them.
Downloadlinks
Mirrors are not allowed.
Click me to download a_state.inc
How to install it
• Download a_state.inc ^^ link is in above.
• Put a_state.inc into your pawno/include
• Open your script
Put this
pawn Код:
#include <a_state>
• Have fun!