3D Label to player
#7

Quote:
Originally Posted by RealCop228
Посмотреть сообщение
Posting code isn't going to help the OP author understand what the problem is people...
I shall explain my code then.

What you're trying to do is format the string with 'GetPlayerName' with no parentheses, therefore the compiler will see this as a variable, and since that variable isn't being defined anywhere, it's throwing that error.

Now the proper way to use 'GetPlayerName' is to create a variable, then insert into that variable using 'GetPlayerName'.

The format to do so is.

pawn Код:
GetPlayerName(playerid, dest, size);
Firstly we create a new variable, let's name it something appropriate, so 'playerName' will do.

pawn Код:
new playerName[MAX_PLAYER_NAME]; //format is VariableName[VariableSize]
GetPlayerName(playerid, playerName, sizeof(playerName)); //Get the name of 'playerid' and save it to the variable 'playerName'.
And here once again is the fixed code using 'playerName'.

pawn Код:
if (strcmp("/soldier", cmdtext, true, 10) == 0)
{
    SendClientMessage(playerid, soldiercolor, "You are now a soldier.");
    pTeam[playerid] = team_soldier;
    SetPlayerSkin(playerid, 287);
    GivePlayerWeapon(playerid, 17, 10);
    GivePlayerWeapon(playerid, 27, 50);
    GivePlayerWeapon(playerid, 31, 200);
    new PlayerText3D:playertextid;
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos( playerid, X, Y, Z );
    new playerName[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, playerName, sizeof(playerName));
    format(string, sizeof(string), " %s : Soldier", playerName);
    playertextid = CreatePlayer3DTextLabel(playerid,string,X,Y,Z,40.0);
    return 1;
}
Reply


Messages In This Thread
3D Label to player - by Pawnstar - 26.11.2012, 21:14
Re: 3D Label to player - by Bicentric - 26.11.2012, 21:22
Re: 3D Label to player - by RenSoprano - 26.11.2012, 21:24
Re: 3D Label to player - by Bicentric - 26.11.2012, 21:26
Re: 3D Label to player - by Scenario - 26.11.2012, 21:27
Re: 3D Label to player - by RenSoprano - 26.11.2012, 21:28
Re: 3D Label to player - by Bicentric - 26.11.2012, 21:32
Re: 3D Label to player - by Pawnstar - 27.11.2012, 14:25

Forum Jump:


Users browsing this thread: 2 Guest(s)