What is wrong with this script => (problems with Attach3DTextLabelToPlayer)?
#1

Hi!

I want to make a script that it will put the 3D text above npc. This text should be showing a npcs name:

heres a script:
pawn Код:
#include <a_samp>

new NPC_YUGO;

public OnFilterScriptInit()
{
ConnectNPC("YUGO","yugodriver");
NPC_YUGO = AddStaticVehicle(565, 0.0, 0.0, 5.0, 0.0, 1, 1);
   
ConnectNPC("Clovek","ljudje");
ConnectNPC("Clovek1","ljudje1");
   
SetTimer("Text",10,1);
return 1;
}

public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "YUGO", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, NPC_YUGO, 0); //Putting the NPC into the vehicle we created for it.
SetSpawnInfo( playerid, 0, 33, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );//use when you want to select skin for NPCs
}
   
else if(!strcmp(npcname, "Clovek", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, NPC_YUGO, 0); //Putting the NPC into the vehicle we created for it.
SetSpawnInfo( playerid, 0, 33, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );//use when you want to select skin for NPCs
}
   
else if(!strcmp(npcname, "Clovek1", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, NPC_YUGO, 0); //Putting the NPC into the vehicle we created for it.
SetSpawnInfo( playerid, 0, 33, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0 );//use when you want to select skin for NPCs
}
return 1;
}
return 1;
}



forward Text(playerid);
public Text(playerid)
{
if(IsPlayerNPC(playerid))
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname));
if(!strcmp(npcname, "YUGO", true))
{

     
new text;
text = Create3DTextLabel("Jaz sem YUGO",GetPlayerColor(npcname),30.0,40.0,50.0,40.0,0); //line 59
new Float:x, Float:y, Float:z, string[256];
GetPlayerPos(npcname, x, y, z); //line 61
format(string, sizeof(string), "%s,%s,%s",x,y,z);
     

Attach3DTextLabelToPlayer(text, npcname, string); //line 65
}
}
}

And it says these errors
Код:
C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\NPC.pwn(59) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\NPC.pwn(59) : warning 213: tag mismatch
C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\NPC.pwn(61) : error 035: argument type mismatch (argument 1)
C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\NPC.pwn(65) : warning 213: tag mismatch
C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\NPC.pwn(65) : error 035: argument type mismatch (argument 2)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Errors.
Thank you for help
Reply
#2

pawn Код:
text = Create3DTextLabel("Jaz sem YUGO",GetPlayerColor(playerid),30.0,40.0,50.0,40.0,0); //line 59
new Float:x, Float:y, Float:z, string[256];
GetPlayerPos(playerid, x, y, z); //line 61
format(string, sizeof(string), "%s,%s,%s",x,y,z);
     

Attach3DTextLabelToPlayer(text, playerid, string); //line 65
Fixed.
Reply
#3

Try not using the same word for your callback and your variable. Also try doing something like new Text3D:npcCoords[Put the number of NPC's on your server here] so that if you have more than one npc they won't be using the same variable to store their coordinates in.
Reply
#4

I make this now

pawn Код:
forward Text(playerid);
public Text(playerid)
{
  if(IsPlayerNPC(playerid))
  {
    new npcname[MAX_PLAYER_NAME];
    GetPlayerName(playerid, npcname, sizeof(npcname));
    if(!strcmp(npcname, "YUGO", true))
    {

            new text;
      text = Create3DTextLabel("Jaz sem YUGO",GetPlayerColor(playerid),30.0,40.0,50.0,40.0,0);
      new Float:x, Float:y, Float:z, string[256];
      GetPlayerPos(playerid, x, y, z);

            new a, b, c;
        a = format(string, sizeof(string), "%s",x);
        b = format(string, sizeof(string), "%s",y);
        c = format(string, sizeof(string), "%s",z);
     
      Attach3DTextLabelToPlayer(text, playerid, a,b,c);
    }
    }
}
it says:
Код:
C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\NPC.pwn(59) : warning 213: tag mismatch
C:\Documents and Settings\Anћe Miklavčič\Desktop\sa mp server\filterscripts\NPC.pwn(68) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Reply
#5

I think you f**ked up.

I'll fix your code and make it better:
pawn Код:
forward Text(playerid);
public Text(playerid)
{
  if(!IsPlayerNPC(playerid))
    return true;

  new npcname[MAX_PLAYER_NAME];
  GetPlayerName(playerid, npcname, sizeof(npcname));
  if(!strcmp(npcname, "YUGO", true))
  {
    new Text3D:text;
    text = Create3DTextLabel("Jaz sem YUGO", GetPlayerColor(playerid), 30.0, 40.0, 50.0, 40.0, 0);
    Attach3DTextLabelToPlayer(text, playerid, 0.0, 0.0, 0.0);
  }
}
The X, Y, Z are the OFFSET coordinates, not the real coordinates!
Reply
#6

Script works very good , but when i come to my npc, it starts lagging fullllllllll!! :S

EDIT: Problem solved => i was using timer, that was making lags
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)