SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 12/05/2015, 06:06 AM   #1
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Players Library (callbacks, functions, and addons)

Players Library
Not any advance library; Just for free guys!
This library is pretty simple and straight forward but will come in great use if you see the capabilities of this. There are 4 branches of this libraries namely:
  • playerfuncs.inc
  • playercalls.inc
  • playerstates.inc
  • playerstats.inc
Each include/branch is standalone, so you may grab and use the one you require. The code is clean and user friendly. You have many features and callbacks and functions to use.

Advantages
  • Faster outputing
  • Wide range of callbacks
  • Wide range of functions
  • Player walking style settings
  • Player update blocking (return 0 in callbaks)
  • Short but effective code
  • Standalone branches
  • All in one version also available!
  • Anti-Fake kill system with callback: OnPlayerFakeKill
  • Time updater is quiet useful. You can use just one callback to update all player stuff and one callback for server as well.

List View
Functions
Quote:
//playerfuncs.inc
native GivePlayerScore(playerid, score);
native SetPlayerMoney(playerid, money);
native RemovePlayerWeapoon(playerid, weaponid);
native SetPlayerFacingPoint(playerid, Float:x, Float:y);
native IsPlayerFacingPoint(playerid, Float:x, Float:y, Float:range = 10.0);
native SetPlayerFacingPlayer(playerid, targetid);
native IsPlayerFacingPlayer(playerid, targetid, Float:range = 10.0);
native IsPlayerBehindPlayer(playerid, targetid, Float:range = 10.0);
native GetPlayerWeaponAmmo(playerid, weaponid);
native SetPlayerWeaponAmmo(playerid, weaponid, ammo);
native SetPlayerWalkingStyle(playerid, style);
native GetPlayerWalkingStyle(playerid);
native GetPlayerSkillLevel(playerid, skill);

//playercalls.inc
native IsPlayerPaused(playerid);
native GetPlayerPausedTime(playerid);

//playerstates.inc
native IsPlayerSpawned(playerid);
native IsPlayerSpectating(playerid);
native IsPlayerDriver(playerid);
native IsPlayerInClassSelection(playerid);
native IsPlayerDead(playerid);

//playerstats.inc
native GetPlayerKills(playerid);
native GetPlayerDeaths(playerid);
native GetPlayerSpree(playerid);
native GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds);
native GetPlayerHeadshots(playerid);
native GetPlayerWeaponShots(playerid);
native GetPlayerWeaponHits(playerid);
Callbacks
Quote:
//playerfuncs.inc
public public OnPlayerWalk(playerid, style)

//playercalls.inc
public OnPlayerPosChange(playerid, Float:newx, Float:newy, Float:newz, Float:oldx, Float:oldy, Float:oldz);
public OnPlayerFacingAngleChange(playerid, Float:newangle, Float:oldangle);
public OnPlayerWeaponChange(playerid, newweapon, oldweapon);
public OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth);
public OnPlayerArmourChange(playerid, Float:newarmour, Float:oldarmour);
public OnPlayerVirtualWorldChange(playerid, newworld, oldworld);
public OnPlayerSkinChange(playerid, newskin, oldskin);
public OnPlayerPingChange(playerid, newping, oldping);
public OnPlayerAmmoChange(playerid, weaponid, newammo, oldammo);
public OnPlayerKillPlayer(playerid, killerid, weaponid);
public OnPlayerPause(playerid);
public OnPlayerUnpause(playerid, time);
public OnPlayerFakeKill(playerid, count);
public OnPlayerMoneyChange(playerid, newmoney, oldmoney);
public OnPlayerScoreChange(playerid, newscore, oldscore);

//playerstates.inc
//no callbacks

//playerstats.inc
public OnPlayerHeadshot(playerid, issuerid, weaponid)
Notes
  • Setting walking style is as simple as setting fighting style:
    pawn Code:
    public OnPlayerSpawn(playerid)
    {
        SetplayerWalkingStyle(playerid, WALKING_STYLE_DRUNK);
        return 1;
    }
  • You can run the branches separately or you may use all in one version: playerlib.inc
  • The defined walking styles list can be found in playerfuncs.inc or here:
    pawn Code:
    //walking styles
    #define WALKING_STYLE_DEFAULT     0
    #define WALKING_STYLE_CIVILIAN    1
    #define WALKING_STYLE_GANGSTA     2
    #define WALKING_STYLE_GANGSTA_2   3
    #define WALKING_STYLE_OLD         4
    #define WALKING_STYLE_FAT_OLD     5
    #define WALKING_STYLE_FAT         6
    #define WALKING_STYLE_LADY        7
    #define WALKING_STYLE_LADY_2      8
    #define WALKING_STYLE_WHORE       9
    #define WALKING_STYLE_WHORE_2     10
    #define WALKING_STYLE_DRUNK       11
    #define WALKING_STYLE_BLIND       12
    #define WALKING_STYLE_ARMED       13
  • The callbacks will block the updating of players if you return 0 in them. It will not process when you haven't defined a specific callback.

    Here is all the callback list:
    pawn Code:
    public OnPlayerPosChange(playerid, Float:newx, Float:newy, Float:newz, Float:oldx, Float:oldy, Float:oldz)
    {
        return 1;
    }

    public OnPlayerFacingAngleChange(playerid, Float:newangle, Float:oldangle)
    {
        return 1;
    }

    public OnPlayerWeaponChange(playerid, newweapon, oldweapon)
    {
        return 1;
    }

    public OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth)
    {
        return 1;
    }

    public OnPlayerArmourChange(playerid, Float:newarmour, Float:oldarmour)
    {
        return 1;
    }

    public OnPlayerVirtualWorldChange(playerid, newworld, oldworld)
    {
        return 1;
    }

    public OnPlayerSkinChange(playerid, newskin, oldskin)
    {
        return 1;
    }

    public OnPlayerPingChange(playerid, newping, oldping)
    {
        return 1;
    }

    public OnPlayerAmmoChange(playerid, weaponid, newammo, oldammo)
    {
        return 1;
    }

    public OnPlayerKillPlayer(playerid, killerid, weaponid)
    {
        return 1;
    }

    public OnPlayerPause(playerid)
    {
        return 1;
    }

    public OnPlayerUnpause(playerid, time)
    {
        return 1;
    }

    public OnPlayerFakeKill(playerid, count)
    {
        return 1;
    }

    public OnPlayerMoneyChange(playerid, newmoney, oldmoney)
    {
        return 1;
    }

    public OnPlayerScoreChange(playerid, newscore, oldscore)
    {
        return 1;
    }

    public OnPlayerWalk(playerid, style)
    {
        return 1;
    }

    public OnPlayerHeadshot(playerid, issuerid, weaponid)
    {
        return 1;
    }
  • You can block player activity or updating by returning 0 in every callback. For example you have god mode:
    pawn Code:
    public OnPlayerHealthChange(playerid, Float:newhealth, Float:oldhealth)
    {
        if(GodMode[playerid])//if the player has GOD mode ON
        {
            SetPlayerHealth(playerid, 10000.0);
        }
        return 1;
    }
  • If you are making a headshot system, do all the stuff under OnPlayerHeadshot, the script already has done the coding for you(not much though).
  • GetPlayerPausedTime only shows a valid value when the player is paused or AFK. Its value is reset to 0 when the player unpauses his/her game. You can get the paused time from the callback OnPlayerUnpause(playerid, time). The param time is the paused time.
  • No ammo changing technique for snipers (NO RELOAD):
    pawn Code:
    public OnPlayerAmmoChange(playerid, weaponid, newammo, oldammo)
    {
        if(weaponid == 34) return 0;
        return 1;
    }
  • You can disable anti fake kill by commenting
    pawn Code:
    #define ANTI_FAKE_KILL //comment this if you don't want anti fake kill system

Downloads
GITHUB Page

Pastebin - playerfuncs.inc
Pastebin - playercalls.inc
Pastebin - playerstate.inc
Pastebin - playerstats.inc

Changelog
R3 - 13 May, 2015
  • Fixed some bugs in playerfuncs.inc
  • Fixed some bugs in playercalls.inc
  • Added a better method of hooking (funcidx) (thanks Lordzy)
  • Added 2 new callbacks:
    pawn Code:
    public OnPlayerMoneyChange(playerid, newmoney, oldmoney);
    public OnPlayerScoreChange(playerid, newscore, oldscore);
  • Renewed OnPlayerAmmoChange; now detects ammo change completely from internal script or from player!

R2 - 12 May, 2015
  • Added Anti-Fake kill system

R1 - 12 May, 2015
  • Initial release

Last edited by Gammix; 14/06/2015 at 03:31 AM.
Gammix is offline   Reply With Quote
Old 12/05/2015, 06:10 AM   #2
Emmet_
Guest
 
Posts: n/a
Default Re: Players Library (callbacks, functions, and addons)

pawn Code:
public OnPlayerKillPlayer(playerid, killerid, weaponid)
{
    return 1;
}

http://wiki.sa-mp.com/wiki/OnPlayerDeath

lol
  Reply With Quote
Old 12/05/2015, 06:14 AM   #3
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Re: Players Library (callbacks, functions, and addons)

Quote:
Originally Posted by Emmet_ View Post
pawn Code:
public OnPlayerKillPlayer(playerid, killerid, weaponid)
{
    return 1;
}

http://wiki.sa-mp.com/wiki/OnPlayerDeath

lol
Yeah, that a lol But just for those who dont make these checks:
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    if( killerid != INVALID_PLAYER_ID &&
        playerid != INVALID_PLAYER_ID &&
        ! IsPlayerNPC(killerid) &&
        ! IsPlayerNPC(playerid))
    {
        reason = GetPlayerWeapon(killerid);
        if(! IsValidWeapon(reason)) reason = 0;

        CallLocalFunction("OnPlayerKillPlayer", "iii", playerid, killerid, reason);
    }
        return 1;
}
__________________

Follow me on Github: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 12/05/2015, 06:23 AM   #4
$$inSane
Gangsta
 
$$inSane's Avatar
 
Join Date: Feb 2012
Location: Behind you, you cant see me!!!
Posts: 658
Reputation: 56
Default Re: Players Library (callbacks, functions, and addons)

Pretty good. I will use those callbacks
__________________
$$inSane is offline   Reply With Quote
Old 12/05/2015, 08:47 AM   #5
Emmet_
Guest
 
Posts: n/a
Default Re: Players Library (callbacks, functions, and addons)

Ah, okay. Nice btw. I have a suggestion, you can add a "fakekill" parameter to OnPlayerKillPlayer which will make it more useful.
  Reply With Quote
Old 12/05/2015, 08:50 AM   #6
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Re: Players Library (callbacks, functions, and addons)

Quote:
Originally Posted by Emmet_ View Post
Ah, okay. Nice btw. I have a suggestion, you can add a "fakekill" parameter to OnPlayerKillPlayer which will make it more useful.
Sure brother.
__________________

Follow me on Github: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 12/05/2015, 09:20 AM   #7
Alex Magaņa
High-roller
 
Alex Magaņa's Avatar
 
Join Date: Oct 2012
Location: 𝕭𝖗𝖔𝖙𝖍𝖊𝖗𝖍𝖔𝖔𝖉
Posts: 2,138
Reputation: 218
Default Re: Players Library (callbacks, functions, and addons)

This are same like other SA-MP includes. ._. nothing changed at all.!
__________________

HOME --- FORUMS --- DISCORD --- SERVER
SAMH: Prop Hunt server is coming soon!
Alex Magaņa is offline   Reply With Quote
Old 12/05/2015, 09:30 AM   #8
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,773
Reputation: 858
Default Re: Players Library (callbacks, functions, and addons)

Quote:
Originally Posted by Alex Magaņa View Post
This are same like other SA-MP includes. ._. nothing changed at all.!
Link of those other relevant includes?

Update:
R2 - 12 May, 2015
  • Added Anti-Fake kill system
__________________

Follow me on Github: Donate on Paypal:

Gammix is offline   Reply With Quote
Old 12/05/2015, 10:52 AM   #9
Yashas
Gangsta
 
Join Date: Jun 2012
Location: India
Posts: 882
Reputation: 317
Default Re: Players Library (callbacks, functions, and addons)

Are the functions inline?

The script will be much faster without using this include.


Make these macros:
GetPlayerPausedTime(playerid)
IsPlayerPaused(playerid)
GivePlayerScore(playerid, score) - Set Player Score already has an internal IsPlayerConnected
SetPlayerMoney(playerid, money)
.
.
.

Update your ALS Hook Method

If a bullet was shot then the ammo will obviously change unless its a hacker.I don't see any use of OnPlayerAmmoChange.

IsPlayerBehindPlayer(playerid, targetid, Float:range = 10.0)
This won't work.

GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds)
There is an equivalent function https://wiki.sa-mp.com/wiki/NetStats_GetConnectedTime

Anyway there are some useful functions in the include.
Good Work!!
Yashas is offline   Reply With Quote
Old 12/05/2015, 11:26 AM   #10
Crayder
Banned
 
Join Date: Sep 2013
Location: Flames of Hell
Posts: 3,324
Reputation: 652
Default Re: Players Library (callbacks, functions, and addons)

Quote:
Originally Posted by Yashas View Post
Are the functions inline?
Why would they be? They are in a library.

Quote:
Originally Posted by Yashas View Post
The script will be much faster without using this include.
False.


Quote:
Originally Posted by Yashas View Post
Make these macros:
GetPlayerPausedTime(playerid)
IsPlayerPaused(playerid)
GivePlayerScore(playerid, score) - Set Player Score already has an internal IsPlayerConnected
SetPlayerMoney(playerid, money)
Two of those are already inside, one is already native, and the other is VERY simple.

Quote:
Originally Posted by Yashas View Post
Update your ALS Hook Method
Why? It's fine.

Quote:
Originally Posted by Yashas View Post
If a bullet was shot then the ammo will obviously change unless its a hacker.I don't see any use of OnPlayerAmmoChange.
There are other uses than anti-hack, this is NOT an anti-hack library.

Quote:
Originally Posted by Yashas View Post
IsPlayerBehindPlayer(playerid, targetid, Float:range = 10.0)
This won't work.
Yes it will. Have you thought about testing?

Quote:
Originally Posted by Yashas View Post
GetPlayerConnectedTime(playerid, &hours, &minutes, &seconds)
There is an equivalent function https://wiki.sa-mp.com/wiki/NetStats_GetConnectedTime
No, he made it easier to get the intervals (there are more newbs that need things like that).

Quote:
Originally Posted by Yashas View Post
Anyway there are some useful functions in the include.
Good Work!!
Finally, something nice!

Rep++.
Crayder 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
[Tutorial] How to hook Functions and Callbacks. Lordzy Tutorials 20 11/11/2017 09:57 PM
[Include] [INC]Area functions and callbacks. Backwardsman97 Includes 8 04/11/2011 07:09 AM
[Tutorial] Callbacks and Functions : Important difference Kwarde Tutorials 5 23/07/2011 08:35 AM
[Tutorial] How to hook FUNCTIONS (not callbacks) Luka P. Tutorials 17 13/06/2011 05:35 PM
Useful Functions and Callbacks Re-release Larcius Filterscripts 12 24/06/2010 03:34 PM


All times are GMT. The time now is 09:21 AM.


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