[help] Removing NPCs? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [help] Removing NPCs? (
/showthread.php?tid=113498)
[help] Removing NPCs? -
devteamsnDOTcom - 14.12.2009
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();?
Re: [help] Removing NPCs? -
Malice - 14.12.2009
DisconnectNPC isn't a real function is it? If not, Kick is fine.
Re: [help] Removing NPCs? -
devteamsnDOTcom - 14.12.2009
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....
Re: [help] Removing NPCs? -
Malice - 14.12.2009
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.
Re: [help] Removing NPCs? -
devteamsnDOTcom - 14.12.2009
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?
Re: [help] Removing NPCs? -
Malice - 14.12.2009
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.
Re: [help] Removing NPCs? -
devteamsnDOTcom - 14.12.2009
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
Re: [help] Removing NPCs? -
Malice - 14.12.2009
Woops, just remove the semicolon at the end of the define.