NPC Script
#1

Is it possible to make a script that will active a recorded vehicle path(From npc_record filterscript)
When the player enters in the car and stop it when he exit the car

If yes can someone make a quick script here
P.S the name of the recorded file is : Taxi

Thanks
Reply
#2

"the car" ? What car?
Reply
#3

Car = a Vehicle, specific a taxi I made to spawn but is it possible to start the playback of the recording when you enter in the taxi?
Reply
#4

In gamemode:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_PASSENGER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == thecar)
        {
            SendClientMessage(thenpc, 123456, "/start");
        }
    }
    return 1;
}
pawn Код:
public OnPlayerExitVehicle(playerid, vehicleid)
{
    if(vehicleid == thecar)
    {
        SendClientMessage(thenpc, 123456, "/stop");
    }
    return 1;
}
Replace 'thecar' and 'thenpc' with taxi and NPC IDs.


In NPC script:

pawn Код:
public OnClientMessage(color, text[])
{
    if(text[0] != '/' || color != 123456) return; // ignore all other client messages that NPC receives
   
    if(strcmp(text, "/start", true) == 0)
    {
        StartRecordingPlayback(PLAYER_RECORDING_TYPE_DRIVER, "Taxi");
        return;
    }
   
    if(strcmp(text, "/stop", true) == 0)
    {
        StopRecordingPlayback();
        return;
    }
}
Reply
#5

Thanks it worked but I've got 1 problem

I put this on Game ModeInit
ConnectNPC("Taxidriver","Taxi");

But when I change the npc and enter the name of my npc

SendClientMessage(Taxidriver, 123456, "/start");
SendClientMessage(Taxidriver, 123456, "/stop");

It says in compiler
C:\Users\User\Desktop\crptestserver\gamemodes\Gene rationRoleplay.pwn(94) : error 017: undefined symbol "Taxidriver"
C:\Users\User\Desktop\crptestserver\gamemodes\Gene rationRoleplay.pwn(107) : error 017: undefined symbol "Taxidriver"
Reply
#6

Quote:
Originally Posted by Alexis1999
Посмотреть сообщение
Thanks it worked but I've got 1 problem

I put this on Game ModeInit
ConnectNPC("Taxidriver","Taxi");

But when I change the npc and enter the name of my npc

SendClientMessage(Taxidriver, 123456, "/start");
SendClientMessage(Taxidriver, 123456, "/stop");

It says in compiler
C:\Users\User\Desktop\crptestserver\gamemodes\Gene rationRoleplay.pwn(94) : error 017: undefined symbol "Taxidriver"
C:\Users\User\Desktop\crptestserver\gamemodes\Gene rationRoleplay.pwn(107) : error 017: undefined symbol "Taxidriver"
You cannot send message to a NPC
Reply
#7

Quote:
Originally Posted by Alexis1999
Посмотреть сообщение
Thanks it worked but I've got 1 problem

I put this on Game ModeInit
ConnectNPC("Taxidriver","Taxi");

But when I change the npc and enter the name of my npc

SendClientMessage(Taxidriver, 123456, "/start");
SendClientMessage(Taxidriver, 123456, "/stop");

It says in compiler
C:\Users\User\Desktop\crptestserver\gamemodes\Gene rationRoleplay.pwn(94) : error 017: undefined symbol "Taxidriver"
C:\Users\User\Desktop\crptestserver\gamemodes\Gene rationRoleplay.pwn(107) : error 017: undefined symbol "Taxidriver"
You need to enter the NPC ID, not the name.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)