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, 04:46 AM   #1
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,565
Reputation: 338
Default [INCLUDE] 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,

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 include the following file after a_samp and compile it will work like a charm, nothing else needed!

Download:
Include Version (Plug N Play):-Thanks to Abagail
Pastebin: Link
Github: LINK
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


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



Last edited by RogueDrifter; 24/06/2018 at 07:17 PM.
RogueDrifter is offline   Reply With Quote
Old 13/01/2018, 05:12 AM   #2
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,517
Reputation: 437
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, 05:16 AM   #3
iLearner
Gangsta
 
iLearner's Avatar
 
Join Date: Apr 2017
Posts: 576
Reputation: 117
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, 05:25 AM   #4
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,565
Reputation: 338
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.
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


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



Last edited by RogueDrifter; 13/01/2018 at 05:56 AM.
RogueDrifter is offline   Reply With Quote
Old 13/01/2018, 06:57 AM   #5
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,537
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, 07:00 AM   #6
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,565
Reputation: 338
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?
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


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


RogueDrifter is offline   Reply With Quote
Old 13/01/2018, 07:01 AM   #7
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,537
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, 07:06 AM   #8
RogueDrifter
High-roller
 
RogueDrifter's Avatar
 
Join Date: Dec 2017
Location: SA-MP Drifting world.
Posts: 1,565
Reputation: 338
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.
__________________
Code:
I'm available to script stuff for cash PM me here or on discord @ Andy[RDZ]#0040
[Tutorial]:Anti-cheat guide ||Mini-game 101||VC/LC maps install||
Array index out of bounds


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


RogueDrifter is offline   Reply With Quote
Old 13/01/2018, 11:27 AM   #9
Locky_
High-roller
 
Locky_'s Avatar
 
Join Date: Jul 2012
Posts: 1,581
Reputation: 318
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, 11:32 AM   #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 07:49 AM
B-Dup - First Day Out (Snippet) [LSB]TheGame Screenshots and Videos 1 27/04/2013 01:29 AM
Help finishing a snippet, thanks. Andregood Help Archive 17 23/04/2011 04:41 PM
Minor help with a snippet Andregood Help Archive 3 17/04/2011 07:50 PM
Useful Snippet novox Help Archive 3 08/05/2010 11:19 PM


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


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