SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 25/12/2010, 10:22 PM   #1
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,492
Reputation: 65
Default Getting an NPCs ID.

Well Started to go back to some NPCs today and was wondering how to get the ID of a NPC.

pawn Code:
public OnPlayerUpdate(playerid)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(YOUR_NPC_ID,x,y,z);
    if(IsPlayerInRangeOfPoint(playerid,3.0,x,y,z))
    {
        SendClientMessage(playerid,0xFFFFFFFF,"NPC Says: hello, Im NPC, what can I do for you?");
    }
    return 1;
}

This was posted on one of my old topics on the same thing (3 or 4 months ago). I figured how to get it then just now I forgot. Any type help appreciated.
__________________
Fuck the system.
willsuckformoney is offline  
Old 25/12/2010, 10:27 PM   #2
propilot
Banned
 
Join Date: Mar 2009
Location: Toronto, Canada Eh' ;D
Posts: 1,087
Reputation: 0
Default Re: Getting an NPCs ID.

R, I am not sure but what I am sure about is that
NCP's start from ID 0- up to how how you made.

Sorry if it didn't help ;'(
propilot is offline  
Old 25/12/2010, 10:44 PM   #3
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,492
Reputation: 65
Default Re: Getting an NPCs ID.

No, that didn't help me. Anything else? :S
__________________
Fuck the system.
willsuckformoney is offline  
Old 25/12/2010, 10:54 PM   #4
Mauzen
High-roller
 
Mauzen's Avatar
 
Join Date: Jun 2007
Location: Western Germany
Posts: 4,878
Reputation: 1597
Default Re: Getting an NPCs ID.

The ID is returned by ConenctNPC, isnt it? Put it into a variable ad you ahve the npcs id.
YOu could also use GetPlayerName and strcmp to check, if it is the bot you need, but that wouldnt work for you your code.
Mauzen is offline  
Old 25/12/2010, 10:55 PM   #5
Infamous
Gangsta
 
Infamous's Avatar
 
Join Date: May 2009
Location: Essex, England
Posts: 663
Reputation: 65
Default Re: Getting an NPCs ID.

This is not made by me but I find it very useful.

Code:
new NPCID = GetPlayerIDFromName("Dave");
Code:
stock GetPlayerIDFromName(const playername[], partofname=0)
{
    new i;
    new playername1[64];
    for (i=0;i<MAX_PLAYERS;i++)
    {
        if (IsPlayerConnected(i))
        {
            GetPlayerName(i,playername1,sizeof(playername1));
            if (strcmp(playername1,playername,true)==0)
            {
                return i;
            }
        }
    }
    new correctsigns_userid=-1;
    new tmpuname[128];
    new hasmultiple=-1;
    if(partofname)
    {
        for (i=0;i<MAX_PLAYERS;i++)
        {
            if (IsPlayerConnected(i))
            {
                GetPlayerName(i,tmpuname,sizeof(tmpuname));

                if(!strfind(tmpuname,playername1[partofname],true, 0))
                {
                    hasmultiple++;
                    correctsigns_userid=i;
                }
                if (hasmultiple>0)
                {
                    return -2;
                }
            }
        }
    }
    return correctsigns_userid;
}
Infamous is offline  
Old 25/12/2010, 11:02 PM   #6
willsuckformoney
High-roller
 
willsuckformoney's Avatar
 
Join Date: Dec 2009
Posts: 1,492
Reputation: 65
Default Re: Getting an NPCs ID.

Gonna try that Infamous, also can't I just do something like this?
pawn Code:
if(IsPlayerNPC(playerid))
{
        SetPlayerSkin(playerid,2);
}
SendClientMessage(playerid,green,"NPC Skin is 2");
?
__________________
Fuck the system.
willsuckformoney is offline  
Old 25/12/2010, 11:05 PM   #7
Infamous
Gangsta
 
Infamous's Avatar
 
Join Date: May 2009
Location: Essex, England
Posts: 663
Reputation: 65
Default Re: Getting an NPCs ID.

Well that would work I guess, but if you have more than one NPC then they will all be set to skinid 2.
Infamous is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
HELP with NPCs GangsTa_ Help Archive 20 11/07/2010 01:00 PM
No NPCs regdude Server Support 5 08/07/2010 05:54 PM
NPCs... SMCentral Help Archive 5 28/01/2010 07:40 PM
[HELP] Npcs armyoftwo Help Archive 3 05/12/2009 08:43 AM
a use of NPCs? Daren_Jacobson Help Archive 6 08/10/2009 05:45 PM


All times are GMT. The time now is 02:34 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.