SA-MP Forums Archive
Problem with NPCS - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Problem with NPCS (/showthread.php?tid=247700)



Problem with NPCS - BizzyD - 10.04.2011

Hello, i got a problem with my NPCS. I have made two npcs. They connect & spawn correctly.

This is what happends:
SCREENSHOT:


Well as you see, They get the same skin id. And they get a 3Dtextlabel twice.
And i tried alot to fix this. But i cant seem to fix it.
Here is my OnPlayerSpawn code. where the NPC has there skin id & stuff.

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(strcmp(npcname, "butler1", true))
        {
            SetPlayerSkin(playerid, 172);
            SetPlayerColor(playerid,COLOR_WHITE);
            label[playerid] = Create3DTextLabel("Butler - Press F to speak to me",COLOR_RED,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
        }
        if(strcmp(npcname, "Weapon", true))
        {
            SetPlayerSkin(playerid, 171);
            SetPlayerColor(playerid,COLOR_WHITE);
            label2[playerid] = Create3DTextLabel("Weapon Dealer - Press F to speak to me",COLOR_RED,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer(label2[playerid], playerid, 0.0, 0.0, 0.7);
        }
        return 1;
    }
    SetPlayerPos(playerid, 1477.6693,-1565.2162,23.5469);
    return 1;
}
How can i fix this?

Thanks, Alex


Re: Problem with NPCS - Admigo - 10.04.2011

I dont know what you did wrong! But it look likes that you have 4 labels!


Re: Problem with NPCS - BizzyD - 10.04.2011

It is only two labels. One for each npc


Re: Problem with NPCS - Admigo - 10.04.2011

Really strange i look for u!


Re: Problem with NPCS - BizzyD - 10.04.2011

Well i am trying to solve it. But i cant solve it :S


Re: Problem with NPCS - bigcomfycouch - 10.04.2011

The strcmp function returns 0 if the strings match, so change 'strcmp' to '!strcmp'


Re: Problem with NPCS - Admigo - 10.04.2011

You can also look to tuts about the labels! I got labels for npcs to and worked for me


Re: Problem with NPCS - BizzyD - 10.04.2011

Quote:
Originally Posted by bigcomfycouch
Посмотреть сообщение
The strcmp function returns 0 if the strings match, so change 'strcmp' to '!strcmp'
haha that didnt work at all. Look at this now.


They got CJ skin. And they dont have the text label over em.

New code:

pawn Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(!strcmp(npcname, "butler1", true))
        {
            SetPlayerSkin(playerid, 172);
            SetPlayerColor(playerid,COLOR_WHITE);
            label[playerid] = Create3DTextLabel("Butler - Press F to speak to me",COLOR_RED,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
        }
        if(!strcmp(npcname, "Weapon", true))
        {
            SetPlayerSkin(playerid, 171);
            SetPlayerColor(playerid,COLOR_WHITE);
            label2[playerid] = Create3DTextLabel("Weapon Dealer - Press F to speak to me",COLOR_RED,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer(label2[playerid], playerid, 0.0, 0.0, 0.7);
        }
        return 1;
    }
    SetPlayerPos(playerid, 1477.6693,-1565.2162,23.5469);
    return 1;
}
I did what you say, And that was what happend.


Re: Problem with NPCS - BizzyD - 10.04.2011

Updated code:
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(IsPlayerNPC(playerid))
    {
        new npcname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, npcname, sizeof(npcname));
        if(strcmp(npcname, "butler1", true))
        {
            SetPlayerSkin(playerid, 172);
            SetPlayerColor(playerid,COLOR_WHITE);
            label[playerid] = Create3DTextLabel("Butler - Press F to speak to me",COLOR_RED,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer(label[playerid], playerid, 0.0, 0.0, 0.7);
            return 1;
        }
        if(strcmp(npcname, "Weapon", true))
        {
            SetPlayerSkin(playerid, 171);
            SetPlayerColor(playerid,COLOR_WHITE);
            label2[playerid] = Create3DTextLabel("Weapon Dealer - Press F to speak to me",COLOR_RED,30.0,40.0,50.0,40.0,0);
            Attach3DTextLabelToPlayer(label2[playerid], playerid, 0.0, 0.0, 0.7);
            return 1;
        }
        return 1;
    }
    SetPlayerPos(playerid, 1477.6693,-1565.2162,23.5469);
    return 1;
}
And still not working :S


Re: Problem with NPCS - Admigo - 10.04.2011

Why Setplayerpos? And why so much returns