[Include] AFNPC - Control System for NPC.
#10

Alright, so I was creating a filterscript for my server testing out this include and I came across an issue with spawning the NPC, and setting the NPC's position, world and interior ids. I might be right and I might be wrong but by using this code I assume I'm correct with my code.

When /spawnnpc is executed with an available NPCID, the NPC thats supposed to have been spawned, and set at the command executor's position doesn't appear and cannot be seen anywhere.

Ignore any loose indentations, merely due to the forum mode.

Код:
COMMAND:createnpc(playerid, params[])
{
	new npcid,npcname[20], string[50];
	if(sscanf(params, "is[20]", npcid,npcname)) SendClientMessage(playerid, COLOR_GREY, "USAGE: /createnpc [npc_id] [npc_name]");
	else
	{
	    CreateNPC(npcid, npcname);
	    npc_id++;
	    format(string,sizeof(string),"SERVER: NPC ID: %d has been created.",npc_id);
	    SendClientMessage(playerid,COLOR_WHITE,string);
	    print(string);
	}
	return 1;
}

COMMAND:deletenpc(playerid, params[])
{
    new npcid, string[50];
    if(sscanf(params, "i", npcid)) SendClientMessage(playerid, COLOR_GREY, "USAGE: /destroynpc [npc_id]");
    else
    {
          DestroyNPC(npcid);
	  npc_id--;
	  format(string,sizeof(string),"SERVER: NPC ID: %d has been deleted.",npc_id);
	  SendClientMessage(playerid,COLOR_WHITE,string);
	  print(string);
     }
     return 1;
}

COMMAND:spawnnpc(playerid, params[])
{
        new npcid, string[50],Float:x,Float:y,Float:z,Float:angle, interior, world;
	if(sscanf(params, "i", npcid)) SendClientMessage(playerid, COLOR_GREY, "USAGE: /spawnnpc [npc_id]");
	else
	{
	   if(IsNPCSpawned[npcid] == true) return SendClientMessage(playerid,COLOR_GREY,"SERVER: NPC ID already has been spawned.");
	   GetPlayerPos(playerid, x, y, z);
	   GetPlayerFacingAngle(playerid,angle);
	   GetPlayerVirtualWorld(playerid,world);
	   GetPlayerInterior(playerid,interior);
	   SpawnNPC(npcid);
	   SetNPCPos(npcid, x, y, z+1);
	   SetNPCFacingAngle(npcid, angle);
	   SetNPC
	   format(string,sizeof(string),"SERVER: NPC ID: %d has been spawned.",npc_id);
	   SendClientMessage(playerid,COLOR_WHITE,string);
	   print(string);
	}
        return 1;
}
Reply


Messages In This Thread
AFNPC - Sistema de Control para NPC. - by Swedky - 23.01.2014, 17:16
Re: AFNPC - Control System for NPC. - by [D]ry[D]esert - 23.01.2014, 17:18
Re: AFNPC - Control System for NPC. - by TheArcher - 23.01.2014, 18:12
Respuesta: Re: AFNPC - Control System for NPC. - by Swedky - 23.01.2014, 18:20
Re: AFNPC - Control System for NPC. - by TheArcher - 23.01.2014, 18:40
Re: AFNPC - Control System for NPC. - by Blunt - 25.01.2014, 16:43
Respuesta: Re: AFNPC - Control System for NPC. - by Swedky - 25.01.2014, 17:02
Re: AFNPC - Control System for NPC. - by Riddick94 - 27.01.2014, 14:30
Re: AFNPC - Control System for NPC. - by TonyII - 27.01.2014, 14:35
Re: AFNPC - Control System for NPC. - by Blunt - 27.01.2014, 16:07

Forum Jump:


Users browsing this thread: 1 Guest(s)