SA-MP Forums Archive
Trains and NPC's and such... - 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: Trains and NPC's and such... (/showthread.php?tid=163538)



Trains and NPC's and such... - mastasquizy - 27.07.2010

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?


Re: Trains and NPC's and such... - Conroy - 27.07.2010

Make the train variable an array.

train[trains] = AddStaticVehicle(...)


Re: Trains and NPC's and such... - John_F - 27.07.2010

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.


Re: Trains and NPC's and such... - mastasquizy - 28.07.2010

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'