NPC help
#1

My script is huge, I've tried adding NPC's... They weren't working before but now they are working.
They were passing through login system but they weren't passing through the tutorial therefore they were getting stuck. I passed them through the tutorial but now I'm sure there's lots of other things (that I can't find) that are stopping them from spawning properly... The zombie NPC's are spawning properly now, except they won't die or take any damage and I don't know why. Is there any script I can place first under OnPlayerConnect that will just pass it through everything and spawn it? I've been working on this for literally the past 7-8 no joke and I still can't get them to work. Could someone please give me a hand, I'd really appreciate it. Would even be offering to pay like $5 or some shit for someone to set them up properly for me over Teamviewer.. I'm starting to get over it hahah.

Thanks in advanced
Reply
#2

Just easy tricks:

PHP код:
//Under OnPlayerConnect always@TOP!
if(IsPlayerNPC(playerid)) return 1;
//Under OnPlayerRequestClass
if(IsPlayerNPC(playerid))
{
    
SetSpawnInfo(playerid,0,299,0,0,3,0,0,0,0,0,0,0);
    
SpawnPlayer(playerid);
    return 
1;
}
//Under OnPlayerSpawn
if(IsPlayerNPC(playerid))
{
    new 
n[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
    if(!
strcmp(n,"Peter"))
    {
        
//For example if Peter spawns:
        
SetPlayerSkin(playerid69); //Like this number :3
    
}
    return 
1;

If you do this statements always at the top of these callbacks..nothing can happen with them and they will spawn directly
If you wanna have Zombie NPCs you have to use a Plugin..like FCNPC
Just look at some tutorials how you create them
Reply
#3

You can simply block full OnPlayerConnect stuff for npcs by adding that under OnPlayerConnect callback:
PHP код:
if(IsNPC(playerid))
{
    return 
1;

Reply
#4

Quote:
Originally Posted by Kaliber
Посмотреть сообщение
Just easy tricks:

PHP код:
//Under OnPlayerConnect always@TOP!
if(IsPlayerNPC(playerid)) return 1;
//Under OnPlayerRequestClass
if(IsPlayerNPC(playerid))
{
    
SetSpawnInfo(playerid,0,299,0,0,3,0,0,0,0,0,0,0);
    
SpawnPlayer(playerid);
    return 
1;
}
//Under OnPlayerSpawn
if(IsPlayerNPC(playerid))
{
    new 
n[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,n,MAX_PLAYER_NAME);
    if(!
strcmp(n,"Peter"))
    {
        
//For example if Peter spawns:
        
SetPlayerSkin(playerid69); //Like this number :3
    
}
    return 
1;

If you do this statements always at the top of these callbacks..nothing can happen with them and they will spawn directly
If you wanna have Zombie NPCs you have to use a Plugin..like FCNPC
Just look at some tutorials how you create them
Thanks so much!! I'm using a zombie NPC filterscript

The only problem is, I use the command /zombie to add a zombie and the number goes up each time. Example, /zombie would create a zombie called "Zombie_1" then using the command again would create "Zombie_2" etc... so how would I get the zombies name?
This is the code in the filterscript for getting the zombie name, would I add that into the OnPlayerSpawn in my gamemode?
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(
strcmp(cmdtext"/zombie"true) == 0) {
        if(!
IsPlayerAdmin(playerid)) return false;
        
Caller playerid;
        new 
newname[64];
        
format(newname,sizeof(newname),"%s_%d",ZOMBIE_NAME,LastAdded);
        
ConnectNPC(newname,"zombie");
        
LastAdded++;
        return 
1;
    }
    return 
0;

Thanks again!
Reply
#5

Well you can do here a trick...

PHP код:
//Under OnPlayerSpawn 
if(IsPlayerNPC(playerid)) 

    new 
n[MAX_PLAYER_NAME]; 
    
GetPlayerName(playerid,n,MAX_PLAYER_NAME); 
    if(
strfind(n,ZOMBIE_NAME) != -1)
    { 
        
//So you know..here spawned a zombie
        
SetPlayerSkin(playerid162); //This is a nice zombie skin xD
    

    return 
1

Reply
#6

Thanks man!

Only problem is now, the NPC isn't showing.

And when I /gotop (npc) it says "that player isn't spawned yet" which means the npc is still in the tutorial.
Do you know why the if(IsPlayerNPC(playerid)) return 1; under OnPlayerConnect didn't work? :/
Reply
#7

It worked.

But you have to set it..ehh what Variable you use..to check if a player spawns?
Reply
#8

You mean like this?
PHP код:
if(IsPlayerNPC(playerid))
    {
        
gPlayerLogged[playerid] = 1;
        return 
1;
    } 
Reply
#9

Yes, right
Reply
#10

Ahhhh now they're spawning up in the sky

So sorry man, almost got it though!

When I /zombie, it spawns next to me then disappears. I use /gotop and the zombie is in the sky hahah

EDIT: I figured that this is the dialog it's getting stuck at
PHP код:
if(dialogid == SEXMENU//spawn
    
{
        if(
response)
                {
                     
SetPlayerPos(playerid1.7187530.40621200.34);
                     
SetPlayerInterior(playerid,0);
                    
PlayerInfo[playerid][pSex] = 1;
                       
RegistrationStep[playerid] = 2;
                       
SetPlayerSkin(playerid261);
                    
ShowPlayerDialog(playeridAGEMENUDIALOG_STYLE_INPUT"Please specify your age""How old are you?""Select""Cancel");
                     return 
0;
                 }
                   else
                 {
                    
SetPlayerPos(playerid1.7187530.40621200.34);
                      
SetPlayerInterior(playerid,0);
                    
PlayerInfo[playerid][pSex] = 2;
                       
RegistrationStep[playerid] = 2;
                       
SetPlayerSkin(playerid193);
                      
ShowPlayerDialog(playeridAGEMENUDIALOG_STYLE_INPUT"Please specify your age""How old are you?""Select""Cancel");
                     return 
0;
                }
      } 

EDIT: EVERYTHINGS FIXED EXCEPT, I can't kill the NPC's.. They won't take any damage. What could this be caused by?

.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)