3D Label to player
#1

So i made my code...

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 string[128];
    format(string, sizeof(string), " %s : Soldier", GetPlayerName);
    playertextid = CreatePlayer3DTextLabel(playerid,string,X,Y,Z,40.0);
    return 1;
}
I tried to format it to grab the players name etc.. not sure if i did it right, But i get a few errors and may need some help adjusting my script.

Код:
C:\Users\Scripting.Ash-PC\Desktop\Tribal Gaming\Team Deathmatch\gamemodes\test.pwn(141) : error 076: syntax error in the expression, or invalid function call
C:\Users\Scripting.Ash-PC\Desktop\Tribal Gaming\Team Deathmatch\gamemodes\test.pwn(142) : warning 213: tag mismatch
C:\Users\Scripting.Ash-PC\Desktop\Tribal Gaming\Team Deathmatch\gamemodes\test.pwn(142) : warning 202: number of arguments does not match definition
C:\Users\Scripting.Ash-PC\Desktop\Tribal Gaming\Team Deathmatch\gamemodes\test.pwn(142) : warning 204: symbol is assigned a value that is never used: "playertextid"
C:\Users\Scripting.Ash-PC\Desktop\Tribal Gaming\Team Deathmatch\gamemodes\test.pwn(147) : error 010: invalid function or declaration
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#2

Try this.

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
#3

pawn Код:
if (strcmp("/soldier", cmdtext, true, 10) == 0)
    {
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos( playerid, X, Y, Z );
    new string[128], name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    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);
    format(string, sizeof(string), " %s : Soldier", name);
    new Text3D:playertextid = Create3DTextLabel(string, soldiercolor, 30.0, 40.0, 50.0, 40.0, 0, 0);
    Attach3DTextLabelToPlayer(playertextid[playerid], playerid, 0.0, 0.0, 0.7); // labels attaches it.
    return 1;
}
Edit: The problem was there isn't PlayerText3D and you can't use GetPlayerName without declarating it.
You must first create a 3DTextLabel then to try to attach it on the player
Reply
#4

Quote:
Originally Posted by RenSoprano
Посмотреть сообщение
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 Text3D:playertextid;
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos( playerid, X, Y, Z );
    new string[128];
    format(string, sizeof(string), " %s : Soldier", GetPlayerName(playerid));
    playertextid = CreatePlayer3DTextLabel(playerid,string,X,Y,Z,40.0);
    return 1;
}
How are you expecting this to work? You can't use 'GetPlayerName' directly like that, unless you create a function to do so. You save the player name into a variable using 'GetPlayerName'.
Reply
#5

Posting code isn't going to help the OP author understand what the problem is people...
Reply
#6

I edited my post now it will work 100%
Reply
#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
#8

Код:
C:\Users\Scripting.Ash-PC\Desktop\Tribal Gaming\Team Deathmatch\gamemodes\test.pwn(141) : warning 213: tag mismatch
C:\Users\Scripting.Ash-PC\Desktop\Tribal Gaming\Team Deathmatch\gamemodes\test.pwn(141) : warning 202: number of arguments does not match definition
C:\Users\Scripting.Ash-PC\Desktop\Tribal Gaming\Team Deathmatch\gamemodes\test.pwn(141) : warning 204: symbol is assigned a value that is never used: "playertextid"
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.
Thanks for the help all, only get this now
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)