SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Includes

Reply
 
Thread Tools Display Modes
Old 07/06/2015, 11:16 PM   #1
n0minal
High-roller
 
n0minal's Avatar
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,154
Reputation: 728
Default iBranch.inc [Useful Update Branches]

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.*******.com/watch?v=mLBw3LNlGz8[/ame]


Credits:

-ipsLeon, ipsNan and ipsBruno;
-Y_Less 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.
__________________

Last edited by n0minal; 22/09/2015 at 07:53 PM.
n0minal is offline   Reply With Quote
Old 07/06/2015, 11:51 PM   #2
Pottus
Godfather
 
Pottus's Avatar
 
Join Date: Jun 2012
Posts: 5,420
Reputation: 1240
Default Re: iBranch.inc [Useful Update Branches]

You forgot one.
Code:
OnPlayerSexChange(playerid, oldsex, newsex);
Pottus is offline   Reply With Quote
Old 08/06/2015, 12:10 AM   #3
n0minal
High-roller
 
n0minal's Avatar
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,154
Reputation: 728
Default Re: iBranch.inc [Useful Update Branches]

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
__________________
n0minal is offline   Reply With Quote
Old 08/06/2015, 12:47 AM   #4
GM_KoDi
Gangsta
 
GM_KoDi's Avatar
 
Join Date: Oct 2012
Location: Planet Earth
Posts: 808
Reputation: 229
Default Re: iBranch.inc [Useful Update Branches]

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



Nice include
__________________
GM_KoDi is offline   Reply With Quote
Old 08/06/2015, 01:03 AM   #5
n0minal
High-roller
 
n0minal's Avatar
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,154
Reputation: 728
Default Re: iBranch.inc [Useful Update Branches]

Quote:
Originally Posted by MStyleBR View Post
kkkkkkkkkkkkkkkkkkkk



Nice include
kkkkk thank you sir :P
__________________
n0minal is offline   Reply With Quote
Old 08/06/2015, 01:35 AM   #6
SickAttack
Godfather
 
Join Date: Dec 2013
Posts: 5,113
Reputation: 754
Default Re: iBranch.inc [Useful Update Branches]

Quote:
Originally Posted by ipsLeon View Post
I swear bro I tried, but shemales caused server crash hahahaha
https://wiki.sa-mp.com/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;
}
SickAttack is offline   Reply With Quote
Old 08/06/2015, 01:47 AM   #7
n0minal
High-roller
 
n0minal's Avatar
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,154
Reputation: 728
Default Re: iBranch.inc [Useful Update Branches]

Quote:
Originally Posted by SickAttack View Post
https://wiki.sa-mp.com/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.
__________________
n0minal is offline   Reply With Quote
Old 08/06/2015, 02:12 AM   #8
n0minal
High-roller
 
n0minal's Avatar
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,154
Reputation: 728
Default Re: iBranch.inc [Useful Update Branches]

Updated, gender changes added, thanks to Mr.Pottus and Mr.SickAttack!
__________________
n0minal is offline   Reply With Quote
Old 08/06/2015, 02:44 AM   #9
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,807
Reputation: 831
Default Re: iBranch.inc [Useful Update Branches]

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?
__________________

My GitHub:

Gammix is offline   Reply With Quote
Old 08/06/2015, 03:04 AM   #10
n0minal
High-roller
 
n0minal's Avatar
 
Join Date: Mar 2013
Location: Rio de Janeiro
Posts: 4,154
Reputation: 728
Default Re: iBranch.inc [Useful Update Branches]

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

Last edited by n0minal; 08/06/2015 at 03:39 AM.
n0minal is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to update Mohamedilham Server Support 4 11/09/2014 04:03 PM
YSI Update ConnorHunter Server Support 2 05/03/2014 08:05 PM
Cant update YSI Ponii Scripting Help 2 15/04/2013 12:09 AM
[HELP] when i was trying to update.... Kristopher_Wasserman Server Support 6 14/05/2012 01:00 PM
[HELP] How can i update my r4 to r5 ? andershh Help Archive 6 23/04/2010 04:02 PM


All times are GMT. The time now is 02:26 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.