קוד:
http://forum.sa-mp.com/index.php?topic=119947.0
בגרסה SAMP0.3 הוסיפו אפשרות מדהימה: אפשרות להקליט שחקן נוסע במכונית,הולך,אפשר לשנות לו ניק,לשלוט עליו מתי הוא יעשה את ההקלטה ועוד.
אז איך אתה תוכל ליצור בוט?:
פקודות:
Recording a playback file
/vrecord <filename> - Starts recording a vehicle path to the specified filename.
/ofrecord <filename> - Starts recording an on foot path to the specified filename.
/stoprecord - Stops recording both vehicle and on foot paths.
/vrecord להקליט בוט בתוך רכב,תכנס לרכב ותעשה את הפקודה [לא לשכוח לרשום שם לקובץ הקלטה]
/ofrecord להקליט בוט הולך לא במכונית אותו דבר לקבוע שם להקלטה
/STOPRECORD כמו שנשמע:לעצור את ההקלטה
אז זה הכל בפקודות,עכשיו הFILTERSCRIPT והNCPMODE
קודם כל חובה לNPC[בוט] קבצי שרת SAMP03
כנסו לתיקייה npcmodes
צרו שם קובץ פאון חדש אם איזה שם שאתם רוצים ובתוך תרשמו ככה:
PHP Code:
#define RECORDING "mynpc" //This is the filename of your recording without the extension.
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.
#include <a_npc>
main(){}
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#if RECORDING_TYPE == 1
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
public OnNPCExitVehicle() StopRecordingPlayback();
#else
public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
#endif
בהכל לא נוגעים
רק בdefile בראשון בRECORDING
משנים את הMYNPC לשם של הבוט שלכם
RECORDING_TYPE להגדיר 1=בוט במכונית 2=איש הולך לא ברכב..
בסדר?
תשמרו את הפאון ונמשיך,איך שבאלכם או להשים את הבוט כfilterscript או במוד שלכם
"Dave" - The first parameter is the NPC's name. With this you can detect different NPCs, and perform different actions to them.
"mynpc" - This is the filename (without extension) of the "mini" script we created above.
PHP Code:
ConnectNPC("Dave","mynpc");
FILTERSCRIPT:
PHP Code:
new MyFirstNPCVehicle; //Global variable!
public OnFilterScriptInit()
{
print("my filterscript");
ConnectNPC("MyFirstNPC","mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
return 1;
}
בזה ^^ תשנו את האיידי של האוטו לאוטו שהקלטתם לא צריך XYZ
CONNECTNPC הסברתי למעלה..
PHP Code:
public OnPlayerSpawn(playerid)
{
if(IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
{
new npcname[MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
if(!strcmp(npcname, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
{
PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
}
return 1;
}
//Other stuff for normal players goes here!
return 1;
}
להגדיר שם את השם של הבוט במקום MYFIRSTNPC
למוד אותו דבר רק במקום
PHP Code:
new MyFirstNPCVehicle; //Global variable!
public OnGameModeInit()
{
print("my gamemode");
ConnectNPC("MyFirstNPC","mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
return 1;
}
PHP Code:
public OnFilterScriptInit()
{
print("my filterscript");
ConnectNPC("MyFirstNPC","mynpc");
return 1;
}
ניסיתם ולא עובד?
Common problems
My NPC leaves my server after it joins
Your script is forcing the NPC to login, or you have an anti-cheat / ping kicker that is interfering with your NPC. You can add...
PAWN Code:
if(IsPlayerNPC(playerid))
return 1;
... as the first line of any callbacks that bots will use, e.g. OnPlayerRequestClass or OnPlayerRequestSpawn. For an efficient, simple way of excluding NPCs from loops, check out
foreach by Y_Less.
My NPC doesn't join my server at all
This is most likely caused by your server being passworded.
I can't get the npc_record filterscript to load
You either don't have the filterscript, or it is already loaded. Try continuing anyway.
My NPC just stands at the spawnpoint
Go back, and re-do the OnPlayerSpawn part of the tutorial.
My NPCs used to connect, but now I have upgraded to >= RC5 they don't.
There is a new maxnpc server.cfg variable that defaults to 0. add...
Code:
maxnpc number_goes_here
...to your server.cfg to fix this issue.
זהו תהנו!