27.01.2014, 16:07
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.
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; }