Need a hand guys -
kujox222 - 17.06.2012
pawn Код:
public ShowStats(playerid,targetid)
{
new string[250],pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
format(string,sizeof(string),""embed_blue"%s "embed_white"stats\n\
"embed_blue"Age:"embed_white"%d\n\
"embed_blue"Gender:"embed_white"%s\n\
"embed_blue"Test:"embed_white"%s\n\
"embed_blue"Money:"embed_white"$%d\n\
"embed_blue"Kills:"embed_white"%d\n\
"embed_blue"Deaths:"embed_white"%d",
pName,
pInfo[playerid][Age],
GetPlayerGender(playerid),
pInfo[playerid][test],
GetPlayerMoney(playerid),
pInfo[playerid][Kills],
pInfo[playerid][Deaths]);
ShowPlayerDialog(playerid,1234,DIALOG_STYLE_MSGBOX,""embed_white"Stats",string,"Ok","");
return 1;
}
stock GetPlayerGender(playerid)
{
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,MAX_PLAYER_NAME);
format(file,sizeof(file),PlayerFile,Name);
if(strcmp(dini_Get(file,"Gender"),"Male") == 1)
{
pInfo[playerid][Gender] = Male;
}
else if(strcmp(dini_Get(file,"Gender"),"Female") == 2)
{
pInfo[playerid][Gender] = Female;
}
return 1;
}
Alright guys I got it to say Gender: ale in game when you type /stats I don't know why its not showing the M, any thoughts?
AW: Need a hand guys -
Nero_3D - 17.06.2012
If you could tell us where you actually return the "M" or the "F"
The only thing I see is that you call "GetPlayerGender" which is actually a very bad function
Because you could call the code at OnPlayerConnect and only return the gender
pawn Код:
//OnPlayerConnect
new
tmp[64],
;
GetPlayerName(playerid, tmp, MAX_PLAYER_NAME);
format(tmp, sizeof tmp, PlayerFile, tmp);
// you just could save 1 or 2 instead of "Male" or "Female"...
if(strcmp(dini_Get(file,"Gender"), "Male") == 0) {
pInfo[playerid][Gender] = Male;
} else {
pInfo[playerid][Gender] = Female;
}
// the function
stock GetPlayerGender(playerid) {
// you could use an array but I am not sure which numbers you assigned to "Male" and "Female"
switch(pInfo[playerid][Gender]) {
case Male: return "Male";
case Female: return "Female";
}
return "Unknown";
}
And switch to a more up to date file system like y_ini
Or use the natives which is always the fastest methode
Re: AW: Need a hand guys -
kujox222 - 17.06.2012
Quote:
Originally Posted by Nero_3D
If you could tell us where you actually return the "M" or the "F"
The only thing I see is that you call "GetPlayerGender" which is actually a very bad function
Because you could call the code at OnPlayerConnect and only return the gender
pawn Код:
//OnPlayerConnect new tmp[64], ; GetPlayerName(playerid, tmp, MAX_PLAYER_NAME); format(tmp, sizeof tmp, PlayerFile, tmp); // you just could save 1 or 2 instead of "Male" or "Female"... if(strcmp(dini_Get(file,"Gender"), "Male") == 0) { pInfo[playerid][Gender] = Male; } else { pInfo[playerid][Gender] = Female; } // the function stock GetPlayerGender(playerid) { // you could use an array but I am not sure which numbers you assigned to "Male" and "Female" switch(pInfo[playerid][Gender]) { case Male: return "Male"; case Female: return "Female"; } return "Unknown"; }
And switch to a more up to date file system like y_ini
Or use the natives which is always the fastest methode
|
pawn Код:
stock GetPlayerGender(playerid)
{
// you could use an array but I am not sure which numbers you assigned to "Male" and "Female"
switch(pInfo[playerid][Gender])
case 1: return "Male";
case 2: return "Female";
}
return 1;
}
Crashes Pawno. The the assigned numbers are 1 and 2 in the #define area, also I rather prefer dini I don't know why. It already has a Male and Female area in connect. Thats not the issue. The issue is that it ignores the M in Male and am sure it will ignore the Fe in Female.
AW: Re: AW: Need a hand guys -
Nero_3D - 17.06.2012
Quote:
Originally Posted by kujox222
pawn Код:
stock GetPlayerGender(playerid) { // you could use an array but I am not sure which numbers you assigned to "Male" and "Female" switch(pInfo[playerid][Gender]) case 1: return "Male"; case 2: return "Female"; } return 1; }
Crashes Pawno. The the assigned numbers are 1 and 2 in the #define area, also I rather prefer dini I don't know why. It already has a Male and Female area in connect. Thats not the issue. The issue is that it ignores the M in Male and am sure it will ignore the Fe in Female.
|
I thought it was possible to return plain strings :/, hope thats better
pawn Код:
stock GetPlayerGender(playerid) {
new
text[8] = "Hybrid"
;
switch(pInfo[playerid][Gender]) {
case Male: text = "Male";
case Female: text = "Female";
}
return text;
}
Re: Need a hand guys -
Revo - 17.06.2012
Why not debug your code?
pawn Код:
stock GetPlayerGender(playerid)
{
printf("%s", PlayerInfo[playerid][Gender]);
switch(PlayerInfo[playerid][Gender])
{
case 1: print("1");
case 2: print("2");
case Male: print("male");
case Female: print("female");
default: print("Unknown");
}
}
Going from there I'm sure something will turn up and give you a clue on what to do to fix it.
Re: AW: Re: AW: Need a hand guys -
kujox222 - 17.06.2012
Quote:
Originally Posted by Nero_3D
I thought it was possible to return plain strings :/, hope thats better
pawn Код:
stock GetPlayerGender(playerid) { new text[8] = "Hybrid" ; switch(pInfo[playerid][Gender]) { case 1: text = "Male"; case 2: text = "Female"; } return text; }
|
It worked! Thanks so much!