[Include] Simple get player sex
#1

Get player sex
Код:
if(IsPlayerFemale(playerid)) SendClientMessage(playerid,-1,"You are Female");
if(IsPlayerMale(playerid)) SendClientMessage(playerid,-1,"You are Man");
Exemple using zcmd.ini
PHP код:
CMD:wank(playeridparams[])
{
    if(
IsPlayerFemale(playerid)) return SendClientMessage(playerid,-1,"You can't beacause you dont have &!#а~а");
    
ApplyAnimation(playerid"PAULNMAC""wank_loop"4.1111111);
    return 
1;

Download DLGS version2
DLGS.ini
Reply
#2

Quote:
Код:
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected");
So you're sending the player, who isn't connected, a message telling them that they aren't connected?

Quote:
Код:
stock IsPlayerMale(playerid){
if(!IsPlayerMale(playerid)) return true;
return false;}
Wait what? The player is a male if the player isn't a male?

Quote:
Код:
stock IsPlayerFemale(playerid){
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected");
if(GetPlayerSkin(playerid) == 9) return true;
else if(GetPlayerSkin(playerid) == 10) return true;
else if(GetPlayerSkin(playerid) == 11) return true;
else if(GetPlayerSkin(playerid) == 12) return true;
else if(GetPlayerSkin(playerid) == 13) return true;
else if(GetPlayerSkin(playerid) == 31) return true;
else if(GetPlayerSkin(playerid) == 39) return true;
else if(GetPlayerSkin(playerid) == 40) return true;
else if(GetPlayerSkin(playerid) == 41) return true;
else if(GetPlayerSkin(playerid) == 53) return true;
else if(GetPlayerSkin(playerid) == 54) return true;
else if(GetPlayerSkin(playerid) == 55) return true;
else if(GetPlayerSkin(playerid) == 56) return true;
else if(GetPlayerSkin(playerid) == 63) return true;
else if(GetPlayerSkin(playerid) == 64) return true;
else if(GetPlayerSkin(playerid) == 65) return true;
else if(GetPlayerSkin(playerid) == 69) return true;
else if(GetPlayerSkin(playerid) == 75) return true;
else if(GetPlayerSkin(playerid) == 76) return true;
else if(GetPlayerSkin(playerid) == 77) return true;
else if(GetPlayerSkin(playerid) == 85) return true;
else if(GetPlayerSkin(playerid) == 87) return true;
else if(GetPlayerSkin(playerid) == 88) return true;
else if(GetPlayerSkin(playerid) == 89) return true;
else if(GetPlayerSkin(playerid) == 90) return true;
else if(GetPlayerSkin(playerid) == 91) return true;
else if(GetPlayerSkin(playerid) == 92) return true;
else if(GetPlayerSkin(playerid) == 93) return true;
else if(GetPlayerSkin(playerid) == 129) return true;
else if(GetPlayerSkin(playerid) == 130) return true;
else if(GetPlayerSkin(playerid) == 131) return true;
else if(GetPlayerSkin(playerid) == 138) return true;
else if(GetPlayerSkin(playerid) == 139) return true;
else if(GetPlayerSkin(playerid) == 140) return true;
else if(GetPlayerSkin(playerid) == 141) return true;
else if(GetPlayerSkin(playerid) == 145) return true;
else if(GetPlayerSkin(playerid) == 148) return true;
else if(GetPlayerSkin(playerid) == 150) return true;
else if(GetPlayerSkin(playerid) == 151) return true;
else if(GetPlayerSkin(playerid) == 152) return true;
else if(GetPlayerSkin(playerid) == 157) return true;
else if(GetPlayerSkin(playerid) == 169) return true;
else if(GetPlayerSkin(playerid) == 172) return true;
else if(GetPlayerSkin(playerid) == 178) return true;
else if(GetPlayerSkin(playerid) == 190) return true;
else if(GetPlayerSkin(playerid) == 191) return true;
else if(GetPlayerSkin(playerid) == 192) return true;
else if(GetPlayerSkin(playerid) == 193) return true;
else if(GetPlayerSkin(playerid) == 194) return true;
else if(GetPlayerSkin(playerid) == 195) return true;
else if(GetPlayerSkin(playerid) == 196) return true;
else if(GetPlayerSkin(playerid) == 197) return true;
else if(GetPlayerSkin(playerid) == 198) return true;
else if(GetPlayerSkin(playerid) == 199) return true;
else if(GetPlayerSkin(playerid) == 201) return true;
else if(GetPlayerSkin(playerid) == 205) return true;
else if(GetPlayerSkin(playerid) == 207) return true;
else if(GetPlayerSkin(playerid) == 211) return true;
else if(GetPlayerSkin(playerid) == 214) return true;
else if(GetPlayerSkin(playerid) == 215) return true;
else if(GetPlayerSkin(playerid) == 216) return true;
else if(GetPlayerSkin(playerid) == 218) return true;
else if(GetPlayerSkin(playerid) == 219) return true;
else if(GetPlayerSkin(playerid) == 224) return true;
else if(GetPlayerSkin(playerid) == 225) return true;
else if(GetPlayerSkin(playerid) == 226) return true;
else if(GetPlayerSkin(playerid) == 231) return true;
else if(GetPlayerSkin(playerid) == 232) return true;
else if(GetPlayerSkin(playerid) == 233) return true;
else if(GetPlayerSkin(playerid) == 237) return true;
else if(GetPlayerSkin(playerid) == 238) return true;
else if(GetPlayerSkin(playerid) == 243) return true;
else if(GetPlayerSkin(playerid) == 244) return true;
else if(GetPlayerSkin(playerid) == 245) return true;
else if(GetPlayerSkin(playerid) == 246) return true;
else if(GetPlayerSkin(playerid) == 251) return true;
else if(GetPlayerSkin(playerid) == 256) return true;
else if(GetPlayerSkin(playerid) == 257) return true;
else if(GetPlayerSkin(playerid) == 263) return true;
else if(GetPlayerSkin(playerid) == 298) return true;
else if(GetPlayerSkin(playerid) == 306) return true;
else if(GetPlayerSkin(playerid) == 307) return true;
else if(GetPlayerSkin(playerid) == 308) return true;
else if(GetPlayerSkin(playerid) == 309) return true;
return false;}
First of all, those are male skins, but the function is "IsPlayerFemale"

Let's say the player's skin is 309, you'd be calling GetPlayerSkin 84 times.
That's a very bad thing to do.
https://sampwiki.blast.hk/wiki/Control_Structures#switch
Do that instead.
Reply
#3

Just nooo, don't use else if. Use switch().
You could do something like:
Код:
switch()
{
	case 10..13: return true;
	case 20..28: return true;
	case default: return false;
}
or this:
Код:
Skins[311] = {1, 1, 0, 0, 1, 1, ...};
 
IsPlayerMale(playerid)
{
    if(Skins[GetPlayerSkin(playerid)] == 0) return 1;
    return 0;
}
 
IsPlayerFemale(playerid)
{
    if(Skins[GetPlayerSkin(playerid)] == 1) return 1;
    return 0;
}
Reply
#4

Код:
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid, 0xFF0000AA, "ERROR: Player is not connected");
ُُُExemple using zcmd
PHP код:
CMD:getsex(playerid,params[])
{
//but  "strval(params)" <== this player can be not connected
if(IsPlayerFemale(strval(params))) SendClientMessage(playerid0xFF0000AA"this player is female");
else   
SendClientMessage(playerid0xFF0000AA"this player is male");
return 
1;

You are right in this lool i fix it
PHP код:
stock IsPlayerMale(playerid){
if(
IsPlayerFemale(playerid)) return false;
return 
true;} 
Thanks any way
Reply
#5

Don't judge on him, he is atleast trying.
Reply
#6

Quote:
Originally Posted by ExTaZZ69
Посмотреть сообщение
Just nooo, don't use else if. Use switch().
You could do something like:
Код:
switch()
{
	case 10..13: return true;
	case 20..28: return true;
	case default: return false;
}
or this:
Код:
Skins[311] = {1, 1, 0, 0, 1, 1, ...};
 
IsPlayerMale(playerid)
{
    if(Skins[GetPlayerSkin(playerid)] == 0) return 1;
    return 0;
}
 
IsPlayerFemale(playerid)
{
    if(Skins[GetPlayerSkin(playerid)] == 1) return 1;
    return 0;
}
thx i will try
Reply
#7

I made one a week or two ago for a script I'm working on, if you wanna use it

PHP код:
new SkinRace[] = // 0 = Caucasian / 1 = African American / 2 = Asian / 3 = Latino
{
    
0,0,0,0,1,1,1,
    
1,3,1,1,1,1,1,
    
1,1,1,1,1,1,1,
    
1,1,0,1,1,0,0,
    
1,0,3,0,0,0,0,
    
3,3,0,0,0,1,3,
    
0,3,3,0,3,3,3,
    
2,0,1,0,0,0,0,
    
0,0,0,2,0,0,0,
    
1,1,1,1,1,0,1,
    
0,0,0,0,1,0,1,
    
0,0,0,1,0,1,1,
    
1,0,1,0,0,0,0,
    
0,0,0,0,0,0,0,
    
3,0,0,0,1,1,1,
    
1,1,1,3,3,3,0,
    
0,0,3,3,3,2,2,
    
0,2,2,2,2,0,0,
    
0,0,0,0,0,0,0,
    
0,1,0,1,0,0,1,
    
0,0,1,1,1,0,0,
    
0,1,1,0,0,0,0,
    
0,0,1,0,0,0,0,
    
0,0,1,0,0,1,0,
    
1,2,0,0,0,3,3,
    
3,1,0,0,0,1,0,
    
1,1,3,1,2,2,0,
    
0,1,0,0,0,0,1,
    
0,0,0,0,0,0,0,
    
0,0,0,0,0,2,0,
    
2,0,0,0,0,1,0,
    
0,1,1,1,1,1,3,
    
2,2,0,0,2,2,0,
    
0,0,0,0,0,0,0,
    
1,0,0,0,0,1,1,
    
1,0,0,0,1,0,0,
    
0,1,0,0,1,0,0,
    
0,1,0,1,2,0,1,
    
0,3,0,1,1,1,0,
    
3,1,3,0,0,1,0,
    
0,0,0,0,1,0,0,
    
0,0,0,0,0,3,1,
    
2,0,1,1,3,0,0,
    
0,0,0,0,0,0,1,
    
0,0,0,0
};
new 
SkinGender[] = // 0 = Male / 1 = Female
{
    
0,0,0,0,0,0,0,
    
0,0,1,1,1,1,1,
    
0,0,0,0,0,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,1,0,0,0,
    
0,0,0,1,1,1,1,
    
0,0,0,0,0,0,0,
    
0,0,0,0,1,1,1,
    
1,0,0,0,0,0,0,
    
1,1,1,0,0,0,1,
    
0,0,0,0,0,1,1,
    
1,0,0,0,0,0,0,
    
0,1,0,1,1,1,1,
    
1,1,1,0,0,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,1,1,1,0,
    
0,0,0,0,0,1,1,
    
1,1,0,0,0,1,0,
    
0,1,0,1,1,1,0,
    
0,0,0,1,0,0,0,
    
0,0,0,0,0,0,0,
    
0,1,0,0,1,0,0,
    
0,0,0,1,0,0,0,
    
0,0,0,0,0,0,0,
    
0,1,1,1,1,1,1,
    
1,1,1,1,0,1,0,
    
0,0,1,0,1,0,0,
    
0,1,0,0,1,1,1,
    
0,1,1,0,0,0,0,
    
1,1,1,0,0,0,0,
    
1,1,1,0,0,0,1,
    
1,0,0,0,0,1,1,
    
1,1,0,0,0,0,1,
    
0,0,0,0,1,1,0,
    
0,0,0,0,1,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,0,0,0,0,
    
0,0,0,0,1,0,0,
    
0,0,0,0,0,1,1,
    
1,1,0,0,0,0,0,
    
0
}; 
PHP код:
GetSkinGender(skinid)
{
    new 
string[20];
    
format(string,sizeof(string), "Invalid");
    if(
skinid || skinid 311) return string;
 
    new 
genderid;
    
genderid SkinGender[skinid];
 
    switch(
raceid)
    {
        case 
0format(string,sizeof(string), "Male");
        case 
1format(string,sizeof(string), "Female");
    }
    return 
string;
}
GetSkinEthnicity(skinid)
{
    new 
string[20];
    
format(string,sizeof(string), "Invalid");
    if(
skinid || skinid 311) return string;
 
    new 
raceid;
    
raceid SkinRace[skinid];
  
    switch(
raceid)
    {
        case 
0format(string,sizeof(string), "Caucasian");
        case 
1format(string,sizeof(string), "African American");
        case 
2format(string,sizeof(string), "Asian");
        case 
3format(string,sizeof(string), "Latino");
    }
    return 
string;

PHP код:
// Example function
public Function(playerid) {
    new 
string[20];
    new 
skin GetPlayerSkin(playerid); // skin = 21
    
format(string,sizeof(string), "You are a(n) %s %s."GetSkinEthnicity(skin), GetSkinGender(skin));
    
SendClientMessage(playerid, -1string);
    
// Will output "You are a(n) African American Male."
    
return 1;

Reply
#8

Not to sound like a cunt here, but this could do with some improvement.

Firstly, I think GetPlayerSex would be a better alternative. It's unnecessary to have two functions for something which is better off having just one function. Maybe have it return one for male and two for female for instance.

Secondly, your switch statements don't need to be expanded over multiple lines. They can all be merged together to form one line. If you're getting a "input line too long" error then you can split them without creating another statement in the switch.

These are just some general methods of improving your code, but I do like the idea of this include though.
Reply
#9

Quote:
Originally Posted by Chump
Посмотреть сообщение
Not to sound like a cunt here, but this could do with some improvement.

Firstly, I think GetPlayerSex would be a better alternative. It's unnecessary to have two functions for something which is better off having just one function. Maybe have it return one for male and two for female for instance.

Secondly, your switch statements don't need to be expanded over multiple lines. They can all be merged together to form one line. If you're getting a "input line too long" error then you can split them without creating another statement in the switch.

These are just some general methods of improving your code, but I do like the idea of this include though.
Why would you even say yourself a cunt, when your suggestion is pretty useful.
Reply
#10

I have to give you credit for the name though
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)