[HELP] bus npc
#1

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(playeridbus0);
    }
    return 
1;

Please help
Reply
#2

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;
}
Reply
#3

Thanks a lot

Problem solved!
Reply
#4

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.
*/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)