NPC Script - 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)
+--- Thread: NPC Script (
/showthread.php?tid=302597)
NPC Script -
Alexis1999 - 09.12.2011
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
Re: NPC Script -
MadeMan - 09.12.2011
"the car" ? What car?
Re: NPC Script -
Alexis1999 - 09.12.2011
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?
Re: NPC Script -
MadeMan - 09.12.2011
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;
}
}
Re: NPC Script -
Alexis1999 - 10.12.2011
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"
Re: NPC Script -
Kostas' - 10.12.2011
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
Re: NPC Script -
sabretur - 10.12.2011
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.