SA-MP Forums

Go Back   SA-MP Forums > SA-MP DL Edition > SA-MP 0.3.DL

Reply
 
Thread Tools Display Modes
Old 13/01/2018, 05:46 AM   #1
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,166
Reputation: 190
Default [SNIPPET] GetPlayerCustomSkin use

Custom Skin Help for 0.3.8:
This'll help you replace all of your custom skin checks for the 0.3.8 update to avoid the original GetPlayerCustomSkin returning 0 and GetPlayerSkin returning base id,
Code:
PHP Code:
stock IsPlayerUsingCustomSkin(playerid)
{
    if(
GetPlayerCustomSkin(playerid) <=0) return 0;//<= just for sanity checks but ==0 also works.
    
else return 1;
}
stock GetPlayerSkinEx(playerid)
{
    if(
IsPlayerUsingCustomSkin(playerid)) return GetPlayerCustomSkin(playerid);
    else return 
GetPlayerSkin(playerid);

Why you should use this:
You can't keep using GetPlayerSkin alone and if you use a system that saves player skin and you give your players ability to choose custom skins if you use GetPlayerSkin alone it will return the base id and GetPlayerCustomSkin alone will return 0 if the player has no custom skin hence all players will have cj skin but with this it will check if the player is using a custom skin or not and set his skin based on that.
=====
USAGE:
Simply use Ctrl + H check right on case sensitivity and whole words, type on top GetPlayerSkin and replace with GetPlayerCustomSkinEx.<Not needed anymore you can use the include directly >>below
======
Include Version (Plug N Play):-Thanks to Abagail
Pastebin Link
====
Since there's no snippets section in 0.3.8 i'm posting it here ig, that's it, you can also use those
in other places if you may, have fun.
=====
__________________
Quote:
Originally Posted by RogueDrifter
-For fuck's sake people stop deleting your help threads you're just losing chances of ever getting help again...
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install

[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link



Quote:
Originally Posted by RogueDrifter
-I'm now available to script small scripts for payments done through paypal.

Last edited by RogueDrifter; 13/01/2018 at 07:12 PM.
RogueDrifter is offline   Reply With Quote
Old 13/01/2018, 06:12 AM   #2
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,516
Reputation: 433
Default Re: [SNIPPET] GetPlayerCustomSkin use

You could even hook GetPlayerSkin (using y_hooks or ALS hooking manually), so it's more native if this isn't implemented into the base function. Also, for cleaner code (not sure about speed in this case), you could use ternary instead of else if. This essentially does the same thing, think of "?" as if and ":" as else.

Code:
bool: IsPlayerUsingCustomSkin(playerid)
   return !GetPlayerCustomSkin(playerid) ? (false) : (true);

GetPlayerSkinEx(playerid)
  return IsPlayerUsingCustomSkin(playerid) ? GetPlayerCustomSkin(playerid) : GetPlayerSkin(playerid);
Cool snippet though!
Abagail is offline   Reply With Quote
Old 13/01/2018, 06:16 AM   #3
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 526
Reputation: 108
Default Re: [SNIPPET] GetPlayerCustomSkin use

We have a thread for snippets why did you feel the need to create a thread for yours

Anyway, well done.
iLearner is offline   Reply With Quote
Old 13/01/2018, 06:25 AM   #4
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,166
Reputation: 190
Default Re: [SNIPPET] GetPlayerCustomSkin use

Quote:
Originally Posted by iLearner View Post
We have a thread for snippets why did you feel the need to create a thread for yours :)

Anyway, well done.
I can release 0.3.8 material outside of here? had no clue, thanks.
@Abagail Thanks for the feedback i'll see what i can do :)
Edit: Uploaded a fully ready include that provides the fix and the isplayerusingcustomskin function special thanks to abagail for the help on the ternary operator i never used it before but i'll get into it thanks have fun guys.
__________________
Quote:
Originally Posted by RogueDrifter
-For fuck's sake people stop deleting your help threads you're just losing chances of ever getting help again...
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install

[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link



Quote:
Originally Posted by RogueDrifter
-I'm now available to script small scripts for payments done through paypal.

Last edited by RogueDrifter; 13/01/2018 at 06:56 AM.
RogueDrifter is offline   Reply With Quote
Old 13/01/2018, 07:57 AM   #5
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,543
Reputation: 552
Default Re: [SNIPPET] GetPlayerCustomSkin use

You can even simplify this line further:
Code:
return !GetPlayerCustomSkin(playerid) ? (false) : (true);
// is the same as
return !!GetPlayerCustomSkin(playerid);
// Or in case GetPlayerCustomSkin returns 0 when skin is invalid/not set then this is equivalent as well
return GetPlayerCustomSkin(playerid) > 0;
Misiur is offline   Reply With Quote
Old 13/01/2018, 08:00 AM   #6
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,166
Reputation: 190
Default Re: [SNIPPET] GetPlayerCustomSkin use

Quote:
Originally Posted by Misiur View Post
You can even simplify this line further:
Code:
return !GetPlayerCustomSkin(playerid) ? (false) : (true);
// is the same as
return !!GetPlayerCustomSkin(playerid);
// Or in case GetPlayerCustomSkin returns 0 when skin is invalid/not set then this is equivalent as well
return GetPlayerCustomSkin(playerid) > 0;
Thanks for the info but, that'll really improve anything?
__________________
Quote:
Originally Posted by RogueDrifter
-For fuck's sake people stop deleting your help threads you're just losing chances of ever getting help again...
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install

[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link



Quote:
Originally Posted by RogueDrifter
-I'm now available to script small scripts for payments done through paypal.
RogueDrifter is offline   Reply With Quote
Old 13/01/2018, 08:01 AM   #7
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,543
Reputation: 552
Default Re: [SNIPPET] GetPlayerCustomSkin use

Nah, but knowing that you can return expression returning boolean instead of doing EXPR ? (true) : (false) or !EXPR ? (false) : (true) is useful to know.
Misiur is offline   Reply With Quote
Old 13/01/2018, 08:06 AM   #8
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,166
Reputation: 190
Default Re: [SNIPPET] GetPlayerCustomSkin use

Quote:
Originally Posted by Misiur View Post
Nah, but knowing that you can return expression returning boolean instead of doing EXPR ? (true) : (false) or !EXPR ? (false) : (true) is useful to know.
I see... Okay thanks.
__________________
Quote:
Originally Posted by RogueDrifter
-For fuck's sake people stop deleting your help threads you're just losing chances of ever getting help again...
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install

[Github]:Link [Pastebin]:Link [Forum]:Link [Server]:Link [Discord]:Link



Quote:
Originally Posted by RogueDrifter
-I'm now available to script small scripts for payments done through paypal.
RogueDrifter is offline   Reply With Quote
Old 13/01/2018, 12:27 PM   #9
Locky_
High-roller
 
Join Date: Jul 2012
Posts: 1,503
Reputation: 283
Default Re: [SNIPPET] GetPlayerCustomSkin use

PHP Code:
#define GetPlayerSkinID(%0) (!GetPlayerCustomSkin(%0) ? GetPlayerSkin(%0) : GetPlayerCustomSkin(%0)) 
This way will return both the custom skin and if not being used will return the skin of the player.
Locky_ is offline   Reply With Quote
Old 13/01/2018, 12:32 PM   #10
AbyssMorgan
Banned
 
Join Date: Apr 2015
Location: Poland
Posts: 1,260
Reputation: 326
Default Re: [SNIPPET] GetPlayerCustomSkin use

Why someone need use GetPlayerCustomSkin, hooks for (Get/Set)PlayerSkin is better idea...
AbyssMorgan 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
Snippet for IP Deathlane Scripting Help 2 22/05/2015 08:49 AM
B-Dup - First Day Out (Snippet) [LSB]TheGame Screenshots and Videos 1 27/04/2013 02:29 AM
Help finishing a snippet, thanks. Andregood Help Archive 17 23/04/2011 05:41 PM
Minor help with a snippet Andregood Help Archive 3 17/04/2011 08:50 PM
Useful Snippet novox Help Archive 3 09/05/2010 12:19 AM


All times are GMT. The time now is 12:00 AM.


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