[Include] iBranch.inc [Useful Update Branches]
#1

Intro
I've been developing this include since yesterday, searching for bugs to fix and things to improve, and now I think that its finally done. This include is simple, it adds some useful callbacks to your gamemode by updating and doing simple comparisons to some vars, and if they aren't the same, the custom callback will be called with the needed parameters. Its quite simple, I just did this for my own gamemode and project and decided to release it here. Also, it uses ALS 4 - Hook Method 7 to deal with TogglePlayerControllable.

Features
Here are the callbacks which you can use on your gamemode if you use this include:

Code:
forward OnPlayerSkinChange(playerid, newskin, oldskin);
forward OnPlayerNameChange(playerid, newname[], oldname[]);
forward OnPlayerMoneyChange(playerid, newmoney, oldmoney);
forward OnPlayerWantedLevelChange(playerid, newlevel, oldlevel);
forward OnPlayerScoreChange(playerid, newscore, oldscore);
forward OnPlayerWeaponSlotChange(playerid, slotid, new_weapon, oldweapon);
forward OnPlayerAmmoChange(playerid, weaponid, newammo, oldammo);
forward OnPlayerCurrentWeaponChange(playerid, new_weapon, oldweapon);
forward OnPlayerVehicleChange(playerid, new_vehicle, oldvehicle);
forward OnPlayerVehicleSeatChange(playerid, newseat, oldseat);
forward OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth);
forward OnPlayerArmourChange(playerid, Float:newarmour, Float:oldarmour);[new]
forward OnPlayerVirtualWorldChange(playerid, new_world, oldworld);
forward OnPlayerPingChange(playerid, newping, oldping);
forward OnPlayerFPSChange(playerid, newfps, oldfps);
forward OnPlayerDrunkLevelChange(playerid, newlevel, oldlevel);
forward OnPlayerFreezeStateChange(playerid, newstate, oldstate);
forward OnPlayerTeamChange(playerid, newteam, oldteam);
forward OnPlayerGenderChange(playerid, newgender, oldgender); [new]
forward OnPlayerAimStateChange(playerid, weaponid, mode); [new]
Defined Prams:
Code:
//genders
#define SKIN_GENDER_NONE 0
#define SKIN_GENDER_FEMALE 1
#define SKIN_GENDER_MALE 2

//aim states
#define AIM_MODE_RELEASE	 0
#define AIM_MODE_HOLD	 1
How to use this
To use the include, you just need to include it on the top of your gamemode/filterscript:

Example:
Quote:

#include <a_samp>
#include <ibranch>

Downloads and Links
GitHub

Bugs
I didn't found any for a while, if you find a bug, please contact me by PM or reply on this topic and I will fix it as far as possible.

Check Also:

iCMD 8.0 Beta - Fastest CMD Processor! (English Topic Soon)
ipsTeam Official Server Development!

Changelog:

Quote:
[08/06]
-Added hook for OnPlayerConnect
-Fixed some switch issues
-Added gender callback
[11/06]
-Added OnPlayerArmourChange
-XoR operators changed to "!=" for better optimization
[25/06]
-Added aim callback
-Added hook for OnPlayerKeyStateChange
[27/06]
-All the call methods, forwards and update branchs has now verifications for scripting needs (defined callbacks), it means that update is now so much lighter than before and the include now is faster and consume less RAM (the variables are also created only if the scripter needs it).
-Added foreach and global timer
-Removed per-playered timers
-Update rate now is 80 by default
-Many other improvements
[22/09]
-Hooked onplayerdisconnect
-Player data is now cleared after player disconnects (to avoid desynced fake updates)

Video

Aim State Change support (pink msg = started aiming | orange msg = stopped aiming)

[ame]http://www.youtube.com/watch?v=mLBw3LNlGz8[/ame]


Credits:

-ipsLeon, ipsNan and ipsBruno;
-****** for knowledgements and ALS Hook Methods;
-Kalcor for creating SA-MP.
-Pottus and SickAttack for gender suggestion.
-Gammix for regarding me some stuff.
-Yashas and Adejair_Junior for suggesting script optimizations and #if defined to make the plugin be lighter.
Reply
#2

You forgot one.
Code:
OnPlayerSexChange(playerid, oldsex, newsex);
Reply
#3

Quote:
Originally Posted by Pottus
View Post
You forgot one.
Code:
OnPlayerSexChange(playerid, oldsex, newsex);
I swear bro I tried, but shemales caused server crash hahahaha
Reply
#4

Quote:
Originally Posted by ipsLeon
View Post
I swear bro I tried, but shemales caused server crash hahahaha
kkkkkkkkkkkkkkkkkkkk



Nice include
Reply
#5

Quote:
Originally Posted by MStyleBR
View Post
kkkkkkkkkkkkkkkkkkkk



Nice include
kkkkk thank you sir :P
Reply
#6

Quote:
Originally Posted by ipsLeon
View Post
I swear bro I tried, but shemales caused server crash hahahaha
https://sampwiki.blast.hk/wiki/GetPlayerSkin

pawn Code:
#define SKIN_GENDER_NONE 0
#define SKIN_GENDER_FEMALE 1
#define SKIN_GENDER_MALE 2

stock GetSkinGender(skinid)
{
    switch(skinid)
    {
        case 74: return SKIN_GENDER_NONE;
        case 0..8, 14..30, 32..38, 42..52, 57..62, 66..68, 70..73, 78..84, 86, 94..128, 132..137, 142..144, 146, 147, 149, 153..156, 158..168, 170, 171, 173..177, 179..189, 200,
        202..204, 206..210, 212, 213, 217, 220..223, 227..230, 234..236, 239..242, 247..250, 252..255, 258..262, 264..297, 299: return SKIN_GENDER_MALE;
        default: return SKIN_GENDER_FEMALE;
    }
    return SKIN_GENDER_NONE;
}
Reply
#7

Quote:
Originally Posted by SickAttack
View Post
https://sampwiki.blast.hk/wiki/GetPlayerSkin

pawn Code:
#define SKIN_GENDER_NONE 0
#define SKIN_GENDER_FEMALE 1
#define SKIN_GENDER_MALE 2

stock GetSkinGender(skinid)
{
    switch(skinid)
    {
        case 74: return SKIN_GENDER_NONE;
        case 0..8, 14..30, 32..38, 42..52, 57..62, 66..68, 70..73, 78..84, 86, 94..128, 132..137, 142..144, 146, 147, 149, 153..156, 158..168, 170, 171, 173..177, 179..189, 200,
        202..204, 206..210, 212, 213, 217, 220.223, 227..230, 234..236, 239..242, 247..250, 252..255, 258..262, 264..297, 299: return SKIN_GENDER_MALE;
        default: return SKIN_GENDER_FEMALE;
    }
    return SKIN_GENDER_NONE;
}
Oh you guys were serious, alright I'll add it.
Reply
#8

Updated, gender changes added, thanks to Mr.Pottus and Mr.SickAttack!
Reply
#9

You can use funcidx just incase some one don't want to use few callbacks, they won't require it to be included in their code.

I don't like your Ammo change method. Looping for all slots (12) in OnPlayerUpdate. Actually you can simply use GetPlayerAmmo and store it in a variable in OnPlayerSpawn and then make checks in OnPlayerUpdate.
And just a tip, use break once you have what you want in your loop.

pawn Code:
new PlayerUpdateInfo[MAX_PLAYERS][UpdateData];
new PlayerFPSInfo[MAX_PLAYERS][FPSData];
You can use static so that no one can edit it outside from include.

OnPlayerNameChange
OnPlayerFreezeStateChange
The most useless ones i will ever use

BTW, i thought this was something new than this!



E: For some reason, i don't see your hooking?
Reply
#10

Quote:
Originally Posted by Gammix
View Post
You can use funcidx just incase some one don't want to use few callbacks, they won't require it to be included in their code.

I don't like your Ammo change method. Looping for all slots (12) in OnPlayerUpdate. Actually you can simply use GetPlayerAmmo and store it in a variable in OnPlayerSpawn and then make checks in OnPlayerUpdate.
And just a tip, use break once you have what you want in your loop.

pawn Code:
new PlayerUpdateInfo[MAX_PLAYERS][UpdateData];
new PlayerFPSInfo[MAX_PLAYERS][FPSData];
You can use static so that no one can edit it outside from include.

OnPlayerNameChange
OnPlayerFreezeStateChange
The most useless ones i will ever use
These loops didn't need breaks seeing as it will be completely processed and every single id is importtant, also, store the vars at onplayerspawn would require more hooks, more headache for scripters and has no much to do with the script in fact, seeing as I would need to continue looping at the updates to check for weapon data changes. Acessibility from outside of the include is something that I would like to keep on this include, I made this to give a bit more of support for scripters, I don't see any problem in touch the vars from outside.

Quote:
Originally Posted by Gammix
View Post
BTW, i thought this was something new than this!



E: For some reason, i don't see your hooking?
Yes I saw this one, very nice library you got there. And here is the hook for TogglePlayerControllable function:

At the bottom of the include:

Code:
#if defined _ALS_TogglePlayerControllable
    #undef TogglePlayerControllable
#else
    #define _ALS_TogglePlayerControllable
#endif
#define TogglePlayerControllable iB_TogglePlayerControllable
And the function is a bit upper.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)