SA-MP Forums Archive
[Include] perplayer.inc - collection of player-based functions (ForPlayer analogues) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] perplayer.inc - collection of player-based functions (ForPlayer analogues) (/showthread.php?tid=669646)



perplayer.inc - collection of player-based functions (ForPlayer analogues) - OstGot - 28.09.2019

Per-player functions
(powered by Pawn.RakNet)
Description:
This library implements analogues of ordinary native ones like SetPlayerSkin or SetVehicleNumber, but with the possibility of applying them to one specific player, as you can do this, for example, using the existing CreateExplosion and CreateExplosionForPlayer functions. You could already see some of the functions in YSF and SKY plugins earlier (the functionality of which prompted me to create this include), but there are few of them and those plugins have a broader purpose of using that not everyone might need.

List of functions & documentation:
For the functions that have both playerid and forplayerid as their parameters you can specify for them either the same IDs or different player IDs, thus in the first case the changes will be visible only to the player to whom they are applied (and as a result, if it's possible, the player will synchronize them for others himself), while in the second case the changes applied to playerid will not be visible for him, as they are visible only to forplayerid.

Dependencies:
Pawn.RakNet plugin

Download:
v1.2: MediaFire Pastebin

Notes:
This library doesn't contain functions that can get any data for a specific player (Get<...>ForPlayer), since their implementation on Pawn would require the allocation of a really large amount of memory most of which wouldn't be used at all during the server work, which I found ineffective. So if someone wants to do this in plugin where it would be more appropriate - don't hesitate to take the code and change it as you like, I don't mind.

Changelog:
HTML Code:
v1.0
* Initial release

v1.1
* Fixed SetPlayerNameForPlayer function

v1.2
* Compatibility with the latest Pawn.RakNet plugin version
Bugs:
Not found at the moment. If you find strange behavior of any of the functions or other errors, report them in this thread.

Credits:
* KashCherry, BrunoBM16 - list of RPC IDs and parameters
* urShadow - some help with Pawn.RakNet


Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - Lokii - 28.09.2019

Nice


Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - Bolex_ - 28.09.2019

Very interesting.

I use the Pawn.RakNet plugin for a long time and this will certainly be helpful.


Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - Cycle - 28.09.2019

More one for your include. I have a lot of functions like this made by me, it was made when I was studying Pawn.RakNet with BrunoBM16.
PHP Code:
stock ToggleWidescreenForPlayer(playeridbool:enable)
{
    if(!
IsPlayerConnected(playerid))
        return 
false;
    new 
BitStream:bs BS_New();
    
BS_WriteValue(
        
bs
        
PR_BOOLenable
    
);
    
BS_RPC(bsplayerid0x6F);
    
BS_Delete(bs);
    return 
true;




Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - OstGot - 28.09.2019

Quote:
Originally Posted by Cycle
View Post
I can give you some functions.

I made an include with a lot of functions like this.

Below there's one.:
PHP Code:
stock ToggleWidescreenForPlayer(playeridbool:enable)
{
    if(!
IsPlayerConnected(playerid))
        return 
false;
    new 
BitStream:bs BS_New();
    
BS_WriteValue(
        
bs
        
PR_BOOLenable
    
);
    
BS_RPC(bsplayerid0x6F);
    
BS_Delete(bs);
    return 
true;

Thanks, but it seems that this function is unstable, therefore it's hidden and inaccessible in samp by default. As far as I remember, different players had black bars at the top and bottom of the screen, while others didn't have them and only the hood was hidden.


Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - Cycle - 28.09.2019

Quote:
Originally Posted by OstGot
View Post
Thanks, but it seems that this function is unstable, therefore it's hidden and inaccessible in samp by default. As far as I remember, different players had black bars at the top and bottom of the screen, while others didn't have them and only the hood was hidden.
uhh, I didn't know about that. The functions I've done similar to yours have been around for a long time, and even I haven't updated them.


Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - DRIFT_HUNTER - 28.09.2019

Quote:
Originally Posted by OstGot
View Post
Thanks, but it seems that this function is unstable, therefore it's hidden and inaccessible in samp by default. As far as I remember, different players had black bars at the top and bottom of the screen, while others didn't have them and only the hood was hidden.
Hood is always hidden if i remember correctly and players have black tapes over the screen due to aspect ratio (widescreen settings). Basically if you have wrong resolution and/or widescreen settings then you get tape.


Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - Autorojo - 24.10.2019

Great work!


Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - OstGot - 03.12.2019

v1.1
* Fixed SetPlayerNameForPlayer function


Re: perplayer.inc - collection of player-based functions (ForPlayer analogues) - OstGot - 03.05.2020

v1.2
* Compatibility with the latest Pawn.RakNet plugin version