[HELP] bus npc - 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] bus npc (
/showthread.php?tid=266949)
[HELP] bus npc [Solved] -
SilverBox aka XHell4YouX - 06.07.2011
I just did a npc that enter bus in red county and he drive there
I did an record buy the problem I think he can't login
I see him inside the server with orange color above his name but he fly above San Fierro, I think he cant login or register
Here is the code
PHP код:
public OnGameModeInit()
{
ConnectNPC("james","bus"); // The name of your NPC and the record. The record need to match an record with the same name. The NPC name can be anything
bus = AddStaticVehicle(437,251.2450,-69.4936,1.5635,89.8581,0,1); // Creating your vehicle, this can be done ingame by typing /save. Then go to your SA-MP folder and find the folder "savedpositions"
return 1;
}
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) return 1;
new playername[64]; //Player String
GetPlayerName(playerid,playername,64); //This is to get the NPC's name
if(!strcmp(playername, "james", true)) { // Detecting if the NPC is spawned. If it is not spawned or the name is wrong, nothing will happend
SetPlayerColor(playerid,0xFFFFFFFF); // Chose any color you want, this is currently white
PutPlayerInVehicle(playerid, bus, 0);
}
return 1;
}
Please help
Re: [HELP] bus npc -
TheGarfield - 06.07.2011
pawn Код:
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid))
{
new playername[64]; //Player String
GetPlayerName(playerid,playername,64); //This is to get the NPC's name
if(!strcmp(playername, "james", true))
{
SetPlayerColor(playerid,0xFFFFFFFF);
PutPlayerInVehicle(playerid, bus, 0);
}
}
return 1;
}
Re: [HELP] bus npc -
SilverBox aka XHell4YouX - 06.07.2011
Thanks a lot
Problem solved!
Re: [HELP] bus npc -
[LCK]Chris - 06.07.2011
try this
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) {
new playername[32];
GetPlayerName(playerid,playername,32);
if(!strcmp(playername, "james", true)) {
SetPlayerColor(playerid,0xFFFFFFFF);
PutPlayerInVehicle(playerid, bus, 0);
}
return true;
}
return true;
}
/*
your code failed because:
if(IsPlayerNPC(playerid)) return 1; // if the player is an NPC then stop reading from this function.
*/