[help] Removing NPCs?
#1

Ok, So I have a command to enter my npc's into the game, as ConnectNPC(); Works flawlessly, my one problem is, how do I make them leave when I type /endnpc. Do I use kick(); or DisconnectNPC();?
Reply
#2

DisconnectNPC isn't a real function is it? If not, Kick is fine.
Reply
#3

YA, I didn't think disconnectNPC(); was a real function, but How do I make kick(); kick them, they dont really have a specific id, depends on when they are entered....
Reply
#4

They have an ID that isn't show in the scoreboard. You can get it by name or maybe even the return value of ConnectNPC. The Wiki says it doesn't return a value but it has been wrong before. Don't quote me on that, but it is worth a try. If not, like I said, you can get the ID from the name (i.e. GetPlayerName until there is a match).

Edit:

Or just use your default "/kick" command. You can just kick by the NPC's name.
Reply
#5

Well, I am kind of a noob when It comes to coding samp gamemodes, Can you give me an example of how I might be able to go about scanning through the users for like

Код:
if (PlayerIsNPC(playerid))
{
   Kick(playerid;
}
or something like that?
Reply
#6

To be honest I would just use the default kick command. To identify an NPC you are going to need a name as the ID can always change if the NPC connects mid-game or you happen to join before the NPC. So you might as well use /kick. However, let's say you wanted to kick all NPCs you could do something like:

pawn Код:
#define KickAllNPCs() for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerNPC(i)) Kick(i);
This should work.
Reply
#7

I added that ontop, then said

Код:
if (strcmp("/endnpc", cmdtext, true, 10) ==0)
   {
   if (IsPlayerAdmin(playerid))
   {
 	  //exit npc's
	  KickAllNPCs();
 	 //exit npc's
   }
}
Then I got

Код:
C:\Program Files\Rockstar Games\Newest Includes\gamemodes\NathansStuntage.pwn(264) : error 036: empty statement
Reply
#8

Woops, just remove the semicolon at the end of the define.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)