Trains and NPC's and such...
#1

pawn Код:
public Trains(playerid)
{
    new trains=1;
    if(trains==10)
    {
        KillTimer(Traintimer);
        return 0;
    }
    new npcn[20];
    trains++;
    format(npcn,sizeof(npcn),"[NPC]Train[%i]",trains);
    ConnectNPC(npcn,"train_ls");
    for(new i=0;i<MAX_PLAYERS;i++)
    {
        if(dUserINT(PlayerName(i)).("Admin level"))
        {
            SendClientMessage(i,0x0000FFAA,"[!]Beep?");
        }
        else if(IsPlayerNPC(i) && !strcmp(PlayerName(i),npcn))
        {
            new train=AddStaticVehicleEx(538,0,0,0,270,-1,-1,10000000000);
            PutPlayerInVehicle(i,train,0);
        }
    }
    return 1;
}
As you can probably tell, im trying to add a train to the track after time passes after the 1st train leaves (a timer is linked to this for 90 secs). What happens is that the NPC spawns but is not placed in the vehicle. I'm probably doing something obviously stupid but I don't see whats wrong......help?
Reply
#2

Make the train variable an array.

train[trains] = AddStaticVehicle(...)
Reply
#3

Several working Train NPC's are included in the server download from sa-mp.com
Enable 2 or all 3 and you'll have trains running at pretty good intervals.
Reply
#4

Quote:
Originally Posted by John_F
Посмотреть сообщение
Several working Train NPC's are included in the server download from sa-mp.com
Enable 2 or all 3 and you'll have trains running at pretty good intervals.
Clearly, I probably don't like their intervals if im doing this.......
Quote:
Originally Posted by Conroy
Посмотреть сообщение
Make the train variable an array.

train[trains] = AddStaticVehicle(...)
Sorry, didn't work. Just spawned the NPC but didn't put it in the vehicle; I don't even think the vehicle spawns, but I will double check.

EDIT: Fixed the problem, the script was trying to put the NPC in the vehicle before the NPC actually spawned. So I made a separate callback for creating the vehicle and placing the NPC in the vehicle and put this under 'OnPlayerSpawned'
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)