קודם כל
קרידט רק ורק לאתר SAMP
לKC שם
מדריך זה נכתב ע"י KC!
-----------------
מקווה לינקה 
**מדריך זה פורסם פה בשביל שמתן ידע איך לעשות את זה**
--------------
תורגם מאנגילת לעברית!
----------------------
ושוב קרידט לKC
---------------------
הנה המדריך:
------------------
~יש פה ושם אנגלית כי זה אמור להיות שם :S~
זה חייב להיות נושא חם לשאלות, אז אני יהיה לעבור את כל זה הסתדר לי איך לעשות עם NPCs כמו הדרכה.
Recording a playback file
השמעת קובץ הקלטה
First of all, we need to record a playback file for our NPC to use.
קודם כל, אנחנו צריכים להקליט קובץ ההפעלה עבור NPC שלנו להשתמש. Start up a server, any gamemode will do, then login to rcon.
הפעל את שרת, כל gamemode יעשה, ואז להיכנס ל rcon. (Type "/rcon login <your_rcon_pass_here>" ) and load the filterscript npc_record (Type "/rcon loadfs npc_record" )
(סוג "/ התחברות rcon <your_rcon_pass_here>") וטען את npc_record filterscript (סוג "/ rcon loadfs npc_record")
Now, there are 3 main recording commands in the npc_record filterscript...
עכשיו, יש 3 פקודות ההקלטה המרכזי filterscript npc_record ...
- <LI style="TEXT-ALIGN: right; DIRECTION: rtl">
/vrecord <filename> - Starts recording a vehicle path to the specified filename.
/ vrecord <filename> - מתחיל הקלטה נתיב הרכב שם הקובץ שצוין. <LI style="TEXT-ALIGN: right; DIRECTION: rtl">/ofrecord <filename> - Starts recording an on foot path to the specified filename.
/ ofrecord <filename> - מתחיל הקלטה על השביל ברגל עד שם הקובץ שצוין. /stoprecord - Stops recording both vehicle and on foot paths.
/ stoprecord - הקלטה נפסקת שני כלי רכב על שבילי רגל.
In this tutorial, we will be making a vehicle path, so get in a vehicle, and type /vrecord mynpc (Note you must be logged into rcon) to start recording.
במדריך זה, אנו עושים שביל הרכב, כך להגיע ברכב, ואת סוג / vrecord mynpc (הערה אתה חייב להיות מחובר אל rcon) כדי להתחיל בהקלטה.
Drive around a bit, and when you are finished type /stoprecord .
כונן קצת מסביב, וכאשר תסיים סוג / stoprecord.
Close the game, and go to your scriptfiles directory, there should be a file called mynpc.rec .
לסגור את המשחק, וללכת המדריך scriptfiles שלך, שם צריך להיות קובץ בשם mynpc.rec. Move that file to <Your SA-MP server directory>/npcmodes/recordings/
להעביר את הקובץ לשרת <Your SA-MP directory> / npcmodes / הקלטות /
Done?
לעשות? Okay, great!
אוקיי, נהדר! You have now recorded a path for your NPC, and moved it into the required directory.
יש לך עכשיו רשמה הנתיב עבור NPC שלך, והעבירה אותו לתוך ספרייה הנדרש.
Controlling the NPC
שליטה על NPC
You may have noticed a lot of pawn scripts in the npcmodes directory, these are standalone "mini" scripts that control the behaviour of your NPC.
שאולי שמת לב הרבה תסריטים הרגלי במדריך npcmodes, אלה העצמאי "מיני" סקריפטים כי שליטת ההתנהגות של NPC שלך.
So, lets create one for your freshly recorded path!
אז, מאפשר ליצור אחד עבור טרי הנתיב המוקלט שלך!
Start a new file in pawno, and replace its contents with...
התחל קובץ חדש ב-pawno, ולהחליף את תוכנו עם ...
PAWN Code:
הרגלי מק"ט:
#define RECORDING "mynpc" //This is the filename of your recording without the extension.
# define ההקלטה "mynpc" / / זה את שם הקובץ של ההקלטה שלך בלי סיומת.
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.
# define RECORDING_TYPE 1 / / 1 עבור ברכב ו 2 עבור ברגל.
#include <a_npc>
# לכלול <a_npc>
main(){}
main () ()
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
OnRecordingPlaybackEnd
ציבורית () StartRecordingPlayback (RECORDING_TYPE, ההקלטה);
# if RECORDING_TYPE == 1
# אם RECORDING_TYPE == 1
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
OnNPCEnterVehicle
הציבור (vehicleid, seatid) StartRecordingPlayback (RECORDING_TYPE, ההקלטה);
public OnNPCExitVehicle() StopRecordingPlayback();
OnNPCExitVehicle
ציבורית () StopRecordingPlayback ();
# else
# אחר
public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
OnNPCSpawn
ציבורית () StartRecordingPlayback (RECORDING_TYPE, ההקלטה);
#endif
endif #
That may look confusing, so I will now go through it line by line.
זה אולי נראה מבלבל, אז אני עכשיו לעבור את זה שורה אחר שורה.
PAWN Code:
הרגלי מק"ט:
#define RECORDING "mynpc" //This is the filename of your recording without the extension.
# define ההקלטה "mynpc" / / זה את שם הקובץ של ההקלטה שלך בלי סיומת. As the comment says, this is the filename of the path you recorded without the extension.
כמו תגובה אומרת, זה שם הקובץ של הנתיב שרשמת בלי סיומת. Our playback recording was named mynpc, and its file was mynpc.rec so we enter in "mynpc"
ההקלטה ההשמעה שלנו נקרא mynpc, ואת הקובץ המקורי היה mynpc.rec כך אנחנו נכנסים ב "mynpc"
PAWN Code:
הרגלי מק"ט:
#define RECORDING_TYPE 1 //1 for in vehicle and 2 for on foot.
# define RECORDING_TYPE 1 / / 1 עבור ברכב ו 2 עבור ברגל. As the comment says again, this is the recording type.
כמו תגובה אומר שוב, זה סוג ההקלטה. If your NPC is on foot, this define would be set to 2, if it was in a vehicle it would be set to 1.
אם NPC שלך ברגל, זה יהיה להגדיר להגדיר 2, אם זה היה ברכב זה יהיה מוגדר 1.
PAWN Code:
הרגלי מק"ט:
#include <a_npc>
# לכלול <a_npc> Including the SA-MP NPC functions.
כולל SA-MP-NPC פונקציות.
PAWN Code:
הרגלי מק"ט:
public OnRecordingPlaybackEnd() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
OnRecordingPlaybackEnd
ציבורית () StartRecordingPlayback (RECORDING_TYPE, ההקלטה);
OnRecordingPlaybackEnd is a callback included in the NPC library included the line above.
OnRecordingPlaybackEnd היא התקשרות כלל בספריה NPC כללה את השורה לעיל. This line of code makes the recording loop, as when the recording playback has ended, it starts the recording again.
את שורת הקוד עושה את הלולאה הקלטה, כמו בעת השמעת הקלטת הסתיימה, זה מתחיל את ההקלטה שוב.
PAWN Code:
הרגלי מק"ט:
public OnNPCEnterVehicle(vehicleid, seatid) StartRecordingPlayback(RECORDING_TYPE, RECORDING);
OnNPCEnterVehicle
הציבור (vehicleid, seatid) StartRecordingPlayback (RECORDING_TYPE, ההקלטה);
This is another callback included in the NPC library.
זה עוד התקשרות כלל בספריה NPC. This will start the recording when the NPC has been put in a vehicle.
זה יתחיל את ההקלטה כאשר NPC כבר לשים ברכב.
PAWN Code:
הרגלי מק"ט:
public OnNPCExitVehicle() StopRecordingPlayback();
OnNPCExitVehicle
ציבורית () StopRecordingPlayback ();
Yet another callback included in the NPC library, this will stop playing back the recording if for any reason the NPC exits the vehicle.
עוד התקשרות כלל בספריה NPC, זה יהיה להפסיק לשחק את ההקלטה אם מסיבה כלשהי NPC היציאות הרכב.
PAWN Code:
הרגלי מק"ט:
public OnNPCSpawn() StartRecordingPlayback(RECORDING_TYPE, RECORDING);
OnNPCSpawn
ציבורית () StartRecordingPlayback (RECORDING_TYPE, ההקלטה);
Yet another callback included in the NPC library, this will start playback when the NPC spawns.
עוד התקשרות כלל בספריה NPC, זה יתחיל ההשמעה כאשר NPC מולידה.
As you can see, it is all very simple.
כפי שאתה יכול לראות, זה פשוט מאוד. Now save your NPC "mini" script as "mynpc.pwn" in the <Your SA-MP server directory>/npcmodes/ directory, and compile.
עכשיו להציל NPC "המיני שלך" סקריפט mynpc.pwn "" של שרת <Your SA-MP directory> / npcmodes / ספרייה, ולעבד.
If it compiled, you can now continue to the last step of this tutorial, if it failed to compile, make sure you have updated your SA-MP includes to the latest 0.3 versions, and make sure you haven't missed any brackets or semi-colons.
אם זה הידור, עכשיו אתה יכול להמשיך לשלב האחרון של מדריך זה, אם זה לא הידור, לוודא עדכנת שלך SA-MP העדכנית כוללת את גירסאות 0.3, וודא שיש לך לא לפספס שום סוגריים או חצי -נקודתיים. Still won't compile?
עדיין לא לקמפל? Post a reply.
לכתוב כאן.
Connecting your NPC
התחברות NPC שלך
So, we have the path file, we have the "mini" pawn script for controlling the NPC directly, now we need to load the NPC into a gamemode or filterscript!
אז, יש לנו את נתיב הקובץ, יש לנו מיני "סקריפט הרגלי לשליטה ישירות NPC, עכשיו אנחנו צריכים לטעון את NPC לתוך gamemode או filterscript!
Close the "mini" pawn script, and load up your gamemode or a filterscript in pawno, It's time to be introduced to the ConnectNPC function, and as its name suggests it is used to connect an NPC to your server.
סגור את מיני "סקריפט חייל, ו להעמיס gamemode שלך או filterscript ב pawno, זה הזמן להיות מוצג לפונקציה ConnectNPC, וכמו שלה משמן זה המשמש לחיבור NPC לשרת שלך.
Lets explore this functions parameters, and what they mean...
זה מאפשר לחקור פונקציות פרמטרים, ומה הם מתכוונים ...
PAWN Code:
הרגלי מק"ט:
ConnectNPC("Dave","mynpc");
ConnectNPC ( "דייב", "mynpc");
- <LI style="TEXT-ALIGN: right; DIRECTION: rtl">
"Dave" - The first parameter is the NPC's name.
"דייב" - הפרמטר הראשון הוא NPC's שם. With this you can detect different NPCs, and perform different actions to them.
עם זה תוכל לאתר את NPCs שונים, ולבצע פעולות שונות אותם. "mynpc" - This is the filename (without extension) of the "mini" script we created above.
"mynpc" - זהו שם הקובץ (בלי סיומת) של מיני "יצרנו סקריפט לעיל.
With your new knowledge of the ConnectNPC function, lets try and make our NPC connect when your gamemode or filterscript loads.
עם הידע החדש של הפונקציה ConnectNPC, מאפשר לנסות NPC שלנו להתחבר כאשר gamemode או שלך המון filterscript.
PAWN Code:
הרגלי מק"ט:
public OnGameModeInit()
OnGameModeInit
ציבורי ()
{
(
print("my gamemode");
הדפס ( "gamemode שלי");
ConnectNPC("MyFirstNPC","mynpc");
ConnectNPC ( "MyFirstNPC", "mynpc");
return 1;
return 1;
}
)
Or , if you are adding the NPC into a filterscript...
או, אם אתה מוסיף את NPC לתוך filterscript ...
PAWN Code:
הרגלי מק"ט:
public OnFilterScriptInit()
OnFilterScriptInit
ציבורי ()
{
(
print("my filterscript");
הדפס ( "filterscript שלי");
ConnectNPC("MyFirstNPC","mynpc");
ConnectNPC ( "MyFirstNPC", "mynpc");
return 1;
return 1;
}
)
Now, as we created a path in a vehicle, we need to create a vehicle for the NPC to drive around in.
עכשיו, כפי שיצרנו נתיב במכונית, אנו זקוקים כדי ליצור הרכב של NPC לנהוג סביב פנימה
OnGameModeInit looks like this, now I have created a vehicle for the NPC to use...
OnGameModeInit נראה כך, עכשיו יש לי יצר הרכב של NPC להשתמש ...
NOTE: If your NPC is not in a vehicle you can skip this step.
הערה: אם NPC שלך היא לא ברכב אתה יכול לדלג על שלב זה.
PAWN Code:
הרגלי מק"ט:
new MyFirstNPCVehicle; //Global variable!
MyFirstNPCVehicle
חדש; / / משתנה גלובלי!
public OnGameModeInit()
OnGameModeInit
ציבורי ()
{
(
print("my gamemode");
הדפס ( "gamemode שלי");
ConnectNPC("MyFirstNPC","mynpc");
ConnectNPC ( "MyFirstNPC", "mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
MyFirstNPCVehicle = CreateVehicle (400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
return 1;
return 1;
}
)
Or , if you are adding the NPC into a filterscript...
או, אם אתה מוסיף את NPC לתוך filterscript ...
PAWN Code:
הרגלי מק"ט:
new MyFirstNPCVehicle; //Global variable!
MyFirstNPCVehicle
חדש; / / משתנה גלובלי!
public OnFilterScriptInit()
OnFilterScriptInit
ציבורי ()
{
(
print("my filterscript");
הדפס ( "filterscript שלי");
ConnectNPC("MyFirstNPC","mynpc");
ConnectNPC ( "MyFirstNPC", "mynpc");
MyFirstNPCVehicle = CreateVehicle(400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
MyFirstNPCVehicle = CreateVehicle (400, 0.0, 0.0, 5.0, 0.0, 3, 3, 5000);
return 1;
return 1;
}
)
Note that the actual location of the vehicle doesn't matter, as it will be teleported to wherever the NPC's path starts, when the path starts playing back.
שים לב המיקום בפועל של הרכב לא משנה, כפי שיהיה teleported למקום שבו NPC של הנתיב מתחיל, כאשר השביל מתחיל לנגן שוב.
Just one more thing before you can go in-game and test out your first NPC, we need to put the NPC into the vehicle we created for it.
רק עוד דבר אחד לפני שאתה יכול להיכנס למשחק ו-NPC את המבחן הראשון שלך, אנחנו צריכים לשים את NPC למכונית שיצרנו אותו.
I did this using OnPlayerSpawn...
עשיתי את זה באמצעות OnPlayerSpawn ...
NOTE: If your NPC is not in a vehicle you can skip this step.
הערה: אם NPC שלך היא לא ברכב אתה יכול לדלג על שלב זה.
PAWN Code:
הרגלי מק"ט:
public OnPlayerSpawn(playerid)
OnPlayerSpawn
הציבור (playerid)
{
(
if (IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
אם (IsPlayerNPC (playerid))
/ / בודק אם השחקן כי הוא הוליד רק NPC.
{
(
new npcname[MAX_PLAYER_NAME];
npcname
חדש [MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
GetPlayerName (playerid, npcname, sizeof (npcname));
/ / קבלת NPC's שם.
if (!strcmp(npcname, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
אם (! strcmp (npcname, "MyFirstNPC", נכון))
/ / בודק אם NPC's שם הוא MyFirstNPC
{
(
PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
PutPlayerInVehicle (playerid, MyFirstNPCVehicle, 0);
/ / לשים את NPC למכונית שיצרנו אותו.
}
)
return 1;
return 1;
}
)
//Other stuff for normal players goes here!
/ / דברים אחרים בשביל שחקנים נורמליים הולך כאן!
return 1;
return 1;
}
)
If you want to add another NPC, this OnPlayerSpawn structure is easy to modify, here is an example for 2 NPCs...
אם ברצונך להוסיף עוד NPC, זה מבנה OnPlayerSpawn קל לשנות, הנה דוגמא עבור 2 NPCs ...
PAWN Code:
הרגלי מק"ט:
public OnPlayerSpawn(playerid)
OnPlayerSpawn
הציבור (playerid)
{
(
if (IsPlayerNPC(playerid)) //Checks if the player that just spawned is an NPC.
אם (IsPlayerNPC (playerid))
/ / בודק אם השחקן כי הוא הוליד רק NPC.
{
(
new npcname[MAX_PLAYER_NAME];
npcname
חדש [MAX_PLAYER_NAME];
GetPlayerName(playerid, npcname, sizeof(npcname)); //Getting the NPC's name.
GetPlayerName (playerid, npcname, sizeof (npcname));
/ / קבלת NPC's שם.
if (!strcmp(npcname, "MyFirstNPC", true)) //Checking if the NPC's name is MyFirstNPC
אם (! strcmp (npcname, "MyFirstNPC", נכון))
/ / בודק אם NPC's שם הוא MyFirstNPC
{
(
PutPlayerInVehicle(playerid, MyFirstNPCVehicle, 0); //Putting the NPC into the vehicle we created for it.
PutPlayerInVehicle (playerid, MyFirstNPCVehicle, 0);
/ / לשים את NPC למכונית שיצרנו אותו.
return 1;
return 1;
}
)
if (!strcmp(npcname, "MySecondNPC", true))
אם (! strcmp (npcname, "MySecondNPC", נכון))
{
(
PutPlayerInVehicle(playerid, AnotherVehicleID, 0);
PutPlayerInVehicle (playerid, AnotherVehicleID, 0);
return 1;
return 1;
}
)
return 1;
return 1;
}
)
//Other stuff for normal players goes here!
/ / דברים אחרים בשביל שחקנים נורמליים הולך כאן!
return 1;
return 1;
}
)
Now, compile your gamemode or filterscript, and go in-game!
עכשיו, הידור gamemode או filterscript שלך, וללכת ב-המשחק!
With any luck, you will see your NPC driving around the path you set for it, congratulations!
עם קצת מזל, תראה NPC הנהיגה שלך סביב הנתיב שאתה מגדיר עבור זה, מזל טוב! You have made your first NPC!
ביצעת NPC הראשון שלך!
Didn't work?
לא עובד? Post here to see if we can troubleshoot your problem.
פוסט כאן כדי לראות אם אנחנו יכולים לפתור את הבעיה שלך.
Any more questions?
עוד שאלות? Again, post in this thread!
שוב, לכתוב בפתיל הזה!
Common problems
בעיות נפוצות
My NPC leaves my server after it joins
שלי NPC עלים השרת שלי אחרי זה מצטרף
Your script is forcing the NPC to login, or you have an anti-cheat / ping kicker that is interfering with your NPC.
התסריט שלך לכפות NPC להתחבר, או יש לך אנטי לרמות / תמרוץ פינג זה מתנגש עם NPC שלך. You can add...
אתה יכול להוסיף ...
PAWN Code:
הרגלי מק"ט:
if (IsPlayerNPC(playerid)) return 1;
אם (IsPlayerNPC (playerid))
return 1;
...
... as the first line of any callbacks that bots will use, eg OnPlayerRequestClass or OnPlayerRequestSpawn.
כמו בשורה הראשונה של כל הרובוטים callbacks כי ישתמש, לדוגמה OnPlayerRequestClass או OnPlayerRequestSpawn. For an efficient, simple way of excluding NPCs from loops, check out
foreach by Y_Less.
עבור בדרך יעילה, פשוטה למעט NPCs מן לולאות, לבדוק את foreach על ידי Y_Less.
My NPC doesn't join my server at all
NPC שלי לא להצטרף לשרת שלי בכלל
This is most likely caused by your server being passworded.
זה קרוב לוודאי שנגרמו על ידי השרת להיות passworded.
I can't get the npc_record filterscript to load
אני לא יכול לקבל את filterscript npc_record לטעון
You either don't have the filterscript, or it is already loaded.
אתה גם אין לך את filterscript, או טעינתו כבר. Try continuing anyway.
נסה בכל זאת ממשיך.
My NPC just stands at the spawnpoint
NPC שלי פשוט עומד על spawnpoint
Go back, and re-do the OnPlayerSpawn part of the tutorial.
לחזור, ולחזור לעשות את החלק OnPlayerSpawn של הדרכה.
My NPCs used to connect, but now I have upgraded to >= RC5 they don't.
NPCs המשמש לחיבור שלי, אבל עכשיו אני צריך לשדרג> = RC5 הם לא.
There is a new maxnpc server.cfg variable that defaults to 0.
יש משתנה חדש maxnpc server.cfg כי ברירת המחדל היא 0. add...
להוסיף ...
Code:
מק"ט:
maxnpc number_goes_here
number_goes_here maxnpc
...to your server.cfg to fix this issue.
... ל server.cfg שלך כדי לפתור בעיה זו.
-------------------------------------------------------------------
מתן תן תגובה XD