NPC Question -
gtapolicemods - 06.06.2010
I have a /login and /register system when you login to my server, but you can still click on the spawn button without doing /login or /register and my NPC are still not showing up....
Does anybody have any input on this?
Re: NPC Question -
Backwardsman97 - 06.06.2010
You need to put something under OnPlayerRequestSpawn that will keep them from spawning without logging in. And you need to show code for the NPC. There's a million different things that could be keeping him from showing up.
Re: NPC Question -
Antonio [G-RP] - 06.06.2010
DIRECTLY under OnPlayerConnect and OnPlayerRequestSpawn add
pawn Код:
if(IsPlayerNPC(playerid)) {
return 1;
}
Re: NPC Question -
gtapolicemods - 06.06.2010
ok I have gotten the npc to connect it shows this in the logs
[02:26:16] [npc:join] Bus_driver has joined the server
but the bot is no where to be found
Re: NPC Question -
gtapolicemods - 06.06.2010
Ok Scratch that post before...
I have found the bot, but he doesn't move..
Re: NPC Question -
DJDhan - 06.06.2010
You need toshow the code for the NPC
Btw if you want the player to login before they can actually spawn, do something like this:
At top of script:
Код:
IsLoggedIn[MAX_PLAYERS];
Then under your login code:
Код:
IsLoggedIn[playerid]=1;
Then Under OnPlayerRequestSpawn
Код:
If(IsLoggedIn[playerd]==0)
{
SendClientMessage(playerid,0xffffffaa,"YOu need to Log In before you can spawn.");
return 0;
}
Re: NPC Question -
gtapolicemods - 06.06.2010
Ok
This is the filterscript
Код:
#include <a_samp>
new TaxiCar;
public OnGameModeInit()
{
ConnectNPC("Driver_Taxi","Taxi");
TaxiCar = AddStaticVehicle(420,2044.8854,1473.2106,10.4494,181.3339,6,1); // Taxi
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) //Checks if the player is an NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Gets the NPC's name
if(!strcmp(npcname, "Driver_Taxi", true)) //Checks if the NPC's name is Driver
{
PutPlayerInVehicle(playerid, TaxiCar, 0); //Puts the NPC into the Taxi.
}
}
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
public OnVehicleSpawn(vehicleid)
{
return 1;
}
public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}
public OnPlayerText(playerid, text[])
{
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/mycommand", cmdtext, true, 10) == 0)
{
// Do something here
return 1;
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}
public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}
public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}
public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}
public OnRconCommand(cmd[])
{
return 1;
}
public OnObjectMoved(objectid)
{
return 1;
}
public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}
public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}
public OnPlayerExitedMenu(playerid)
{
return 1;
}
This is the NPCMODES
Код:
#define RECORDING "Taxi" // Name of the .rec file (Without the Extension)
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.
#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCExitVehicle() StopRecordingPlayback();
Like i said i am able to get them to spawn in game, I have a command that tells me all the players on the server with ip's and locations and my bot comes up. When I tp to the bot he just stands in the same position he doesn't move at all...
@ DJDhan: I already have a code for the prevent spawn without login, but I took it out thinking it was effecting the Bot.
Re: NPC Question -
DJDhan - 06.06.2010
Код:
If(IsLoggedIn[playerd]==0 && !IsPlayerNPC(playerid))
{
SendClientMessage(playerid,0xffffffaa,"You need to Log In before you can spawn.");
return 0;
}
And:
Код:
#include <a_samp>
new TaxiCar;
public OnFilterScriptInit()
{
ConnectNPC("Driver_Taxi","Taxi");
TaxiCar = CreateVehicle(420, 0.0, 0.0, 0.0, 0.0, -1, -1, 5000); // Taxi
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(!strcmp(playername,"Driver_Taxi",true))
{
SetSpawnInfo(playerid,69,61,0.0,0.0,0.0,0.0,-1,-1,-1,-1,-1,-1); // set the skin and stuff
}
return 1;
}
public OnPlayerRequestSpawn(playerid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) //Checks if the player is an NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Gets the NPC's name
if(!strcmp(npcname, "Driver_Taxi", true)) //Checks if the NPC's name is Driver
{
PutPlayerInVehicle(playerid, TaxiCar, 0); //Puts the NPC into the Taxi.
}
}
return 1;
}