PDA

View Full Version : warnig..


iBots
16/04/2014, 07:31 PM
i am making formats....like string and...but when i put GetPlayerName(playerid) at the format to put the name istead of %s it shows warning,why?

format(string, sizeof(string), "%s has attempted to take control of the %s for %s, 10 minutes left.", GetPlayerName(playerid),PointInfo[PointCapturable][PointName],FamilyInfo[PlayerInfo[playerid][pFMember]][FamilyName]);

why?

Konstantinos
16/04/2014, 07:33 PM
GetPlayerName does not return the name directly but it stores it to an array by reference:

new pname[21];
GetPlayerName(playerid, pname, sizeof (pname));
format(string, sizeof(string), "%s has attempted to take control of the %s for %s, 10 minutes left.", pname,PointInfo[PointCapturable][PointName],FamilyInfo[PlayerInfo[playerid][pFMember]][FamilyName]);

S4t3K
16/04/2014, 07:36 PM
If you don't want to have to use references, simply use GetName(playerid)


stock GetName(playerid)
{
new szName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, szName, sizeof(szName));
return szName;
}

In this case, you can't directly use GetName(playerid) instead of the array which contains the PlayerName