27.01.2011, 17:10
(
Последний раз редактировалось Kwarde; 30.01.2011 в 05:19.
)
Hi. Again, an usefull tutorial by me
I'll explain you how to make a gamemode from scratch - Probably only for the beginners :')
Before starting I have a little tip. If you never made a gamemode yourself, or if you're a beginner, I recommend you to make a freeroam gamemode - That's the easiest gamemode type (I think).
Let's start!
The most people would ask: "Where should/must I begin" or "What do I have to make when?".
I won't answer them . Actually, if you make a gamemode, you need to ask yourself questions!
1) What for a gamemode do I want?
2) What do I want included in the gamemode?
That are the most basic questions. You need to know that before you're gonna make anything! If you're making a gamemode, but if you don't know what you want, you won't come far :/
I'll give an example of the questions (+answers).
Question 1:
Let's say I want a freeroam gamemode. For this you only need to place vehicles and some important stuff (basic stuff, scroll down)
Now I know that I need to place vehicles (random). It's also usefull to add random spawns, handy teleports and a house system
Question 2:
For a basic gamemode, a player system is handy
Know I the following things:
* Add vehicles
* Add random spawns
* Add 'usefull' teleports
* Add an (easy) house system
* Add an player system
That's a begin! The most basic things are: VEHICLES, USER SYSTEM, (random) SPAWNS, USER CLASSES
When you're gonna start making a gamemode, open pawno and press CTRL + N. You'll get a page with alot of callbacks.
You can remove all this callbacks! (unless if you don't know all of them. Leave them if you wanna use it later, but I always remove them 'cuz I don't use the most of them!)
Start including includes This's how it's being used:
The "FILENAME" is included in your {pawno}/includes folder. It needs to have the extension .inc. When including, you won't need to add '.inc'.
So, #include <file> instead of #include <file.inc>. This'll work, but it costs A BIT diskspace (without .inc is looks better). You can also use #include "file" instead of the <> for the parent directory.
So you can also add an includes map in your SAMP map... Example:
[map "SAMP"]
--[map "PAWNO"]
----[map "includes"]
----[/map]
--[/map]
--[map "includes"]
--[/map]
[/map]
With #include "../includes/{file}" you'll use an include from the "SAMP/includes" folder instead of "SAMP/pawno/includes"!
NOTE: Always include a_samp! That includes all the standard functions!
After this, you can add colours. These are more clearer when you use SendClientMessage (e.d)... Example!!!
SendClientMessageToAll(0xFFFFFFFF, "Hello world!"); looks less clearer then SendClientMessageToAll(COLOR_WHITE, "Hello world!");. Also, if you used some color codes in client messages instead of the defines, you need to change it all (or use CTRL+H ^^). But with defined, you only have to change one thing, fast! I recommend you using #define.
It works like this:
You can define coulors, texts and more. For texts you need to use parentheses! (").
BAD EXAMPLE:
GOOD EXAMPLE:
About the colours; It's almost the same as HEX format. You need to put 0x in front of it, and ALPHA behind it!.
The color white in HTML (HEX) is this: FFFFFF. So, in SA:MP it would be 0xFFFFFFFF. How lower the ALPHA is, how less visible it'll be!
The most nice alpha is "AA". It's also the very best for the color gray (my opinion). I'll give you some standard colors!
And I also have a tip: Use TABS after defines (#define {DEFINE}_TAB_{INFO}). Putt them all on one line. That makes it also clearer. Another example :')
You see? This is more clearer and easier to find something (again my opinion).
You can find more about it on ****** his tutorial: https://sampforum.blast.hk/showthread.php?tid=166680
Now we only have includes, defines. That's no gamemode! We can't do ANYTHING with this. And actually, it's possible that you'll crash when you connect and when you won't spawn.
But we'll handle that later. First, we need an important function. If you don't use it, you'll get this error in your console (and server_log.txt)
You need the function main() for this. The most people only use it for a message, so you can see that the gamemode is loaded. So this is what we gonna have, for example:
So, when it's done with the callback OnGameModeInit(), it'll show My gamemode from scratch is loaded! .
We also have OnGameModeInit. That'll be called when the gamemode starts. You can (re)set strings here, create textdraws e.d. Just add in your script (not in main or another callback): OnGameModeInit()
Then, open it with brackets( { & } ). In the brackets you have to fill in the information you want. For example, the AddPlayerClass. That one is important too!
If you won't add that, and when you spawn after connecting, you'll 'crash'. I mean with that, that you get a screen with the text Stay within the world boundries! and some weird colors.
When you say something in the chat, it'll be showed really strange. AddPlayerClass has the following params:
If you're gonna make the spawn positions in the script and if you're gonna use commands to get weapons (RP) I recommend you to only use this:
Replace the SKINID with the skin id you want.
There's by the way also an OnGameModeExit. This one'll be called when the gamemode exists, so when you use rcon command 'exit' or 'gmx'. Just clicking [X] on your console won't work!
Adding vehicle's is also VERY usefull. This can you do with three different functions:
I recommend you using CreateVehicle, because AddStaticVehicle(Ex) will only work in OnFilterScriptInit or OnGameModeInit! Trains can only be added with AddStaticVehicle.
How to find positions?
Well, I ever made a filterscript named Ultimate Ingame Editor.
With this you can:
* Add vehicles and save them into a file
* Add positions and save them into a file (with or without function names)
* Make teleport commands and them them into a file
* Add a pickup with info and save it into a file (health, armour, info pickup, custom: Edit it yourself)
Here's the topic: https://sampforum.blast.hk/showthread.php?tid=184733
After all the important includes, defines and functions, you are more on your own! Now, the two questions'll come (back).
What do you want? What do you need? If you're gonna include your own usersystem, I recommend you to make that one first
I'll make a good tutorial soon for making user systems! The most are using MySql, and alot of people don't know that or don't want that. I found two other tutorials, but they're using the slow dini! I'll make one that's using DJSON and ZCMD!
You're now on you're own. 'cuz there probably over million different script ways, ideas etc, I won't give more information
Well, I'll put some usefull standard functions below this, but you need to make systems your own! Off course you can ask questions in this topic .
Usefull STANDARD functions e.d.
SetTimer - Will start a timer. You're gonna need (custom) callbacks for this! Just adding 'public callback()' won't work! Use forward:
SetTimerEx - Will start a timer. With this one, you can use params in a custom callback! With the normal SetTimer you can't!!!
It works like this:
SetTimerEx(callbackname, interval, repeat, param_type_code, param_string);
If you don't understand this, I'll give an example of this callback:
This timer'll kick the player after 5 seconds after using the function.
SetTimerEx("KickPlayer", 5000, false, "i", playerid);
The '5000' is the time in milli seconds when the function'll be called. (1 second = 1000 milli seconds. 1 minute = 60000 milli seconds).
The 'false' means, that the function won't be repeated. When you use 'true', the function'll be called every 5 seconds
The "i" stands for "integer". The playeris is just a single integer, that's why you're gonna need "i", "d". I'll give the most used 'tags'.
"i" = integer
"d" = omg forgotten... same effect as "i"
"s" = string (text string)
"f" = float (0.00000000).
This is the most usefull stuff
If you're really don't know alot yet, I recommend you reading the next tutorials:
* How to find bugs (learn more about debugging)
* Script cleanup (how to make a script looking more 'professional')
* Tutorial for script beginners (more important stuff)
And as last, but not least at all!
Don't forget to add credits if you're using someone's include, function, script etc!!!
Put this above in the gamemode or make a new file! Here's an example of my 'CREDITS.txt'
Please add credits! People won't like it if you don't add credits, and you can be banned for it if you release a script!
I think I gave enough now. Say it again if I miss something
I'll add it then, probably.
Good luck
- Kevin
I'll explain you how to make a gamemode from scratch - Probably only for the beginners :')
Before starting I have a little tip. If you never made a gamemode yourself, or if you're a beginner, I recommend you to make a freeroam gamemode - That's the easiest gamemode type (I think).
Let's start!
The most people would ask: "Where should/must I begin" or "What do I have to make when?".
I won't answer them . Actually, if you make a gamemode, you need to ask yourself questions!
1) What for a gamemode do I want?
2) What do I want included in the gamemode?
That are the most basic questions. You need to know that before you're gonna make anything! If you're making a gamemode, but if you don't know what you want, you won't come far :/
I'll give an example of the questions (+answers).
Question 1:
Let's say I want a freeroam gamemode. For this you only need to place vehicles and some important stuff (basic stuff, scroll down)
Now I know that I need to place vehicles (random). It's also usefull to add random spawns, handy teleports and a house system
Question 2:
For a basic gamemode, a player system is handy
Know I the following things:
* Add vehicles
* Add random spawns
* Add 'usefull' teleports
* Add an (easy) house system
* Add an player system
That's a begin! The most basic things are: VEHICLES, USER SYSTEM, (random) SPAWNS, USER CLASSES
When you're gonna start making a gamemode, open pawno and press CTRL + N. You'll get a page with alot of callbacks.
You can remove all this callbacks! (unless if you don't know all of them. Leave them if you wanna use it later, but I always remove them 'cuz I don't use the most of them!)
Start including includes This's how it's being used:
pawn Код:
#include <FILENAME>
So, #include <file> instead of #include <file.inc>. This'll work, but it costs A BIT diskspace (without .inc is looks better). You can also use #include "file" instead of the <> for the parent directory.
So you can also add an includes map in your SAMP map... Example:
[map "SAMP"]
--[map "PAWNO"]
----[map "includes"]
----[/map]
--[/map]
--[map "includes"]
--[/map]
[/map]
With #include "../includes/{file}" you'll use an include from the "SAMP/includes" folder instead of "SAMP/pawno/includes"!
NOTE: Always include a_samp! That includes all the standard functions!
pawn Код:
#include <a_samp>
SendClientMessageToAll(0xFFFFFFFF, "Hello world!"); looks less clearer then SendClientMessageToAll(COLOR_WHITE, "Hello world!");. Also, if you used some color codes in client messages instead of the defines, you need to change it all (or use CTRL+H ^^). But with defined, you only have to change one thing, fast! I recommend you using #define.
It works like this:
pawn Код:
#define {DEFINE} {INFO}
BAD EXAMPLE:
pawn Код:
#define HELLO_WORLD Hello World!
pawn Код:
#define HELLO_WORLD "Hello World!"
The color white in HTML (HEX) is this: FFFFFF. So, in SA:MP it would be 0xFFFFFFFF. How lower the ALPHA is, how less visible it'll be!
The most nice alpha is "AA". It's also the very best for the color gray (my opinion). I'll give you some standard colors!
pawn Код:
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_RED 0xFF0000AA
#define COLOR_GREEN 0x00FF00AA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_GRAY 0xAFAFAFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_LIGHTBLUE 0x0AFFFFAA
#define COLOR_PURPLE 0xFF00FFAA
#define COLOR_ORANGE 0xFFBB00AA
pawn Код:
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_RED 0xFF0000AA
#define COLOR_GREEN 0x00FF00AA
#define COLOR_BLUE 0x0000FFAA
#define COLOR_GRAY 0xAFAFAFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_LIGHTBLUE 0x0AFFFFAA
#define COLOR_PURPLE 0xFF00FFAA
#define COLOR_ORANGE 0xFFBB00AA
You can find more about it on ****** his tutorial: https://sampforum.blast.hk/showthread.php?tid=166680
Now we only have includes, defines. That's no gamemode! We can't do ANYTHING with this. And actually, it's possible that you'll crash when you connect and when you won't spawn.
But we'll handle that later. First, we need an important function. If you don't use it, you'll get this error in your console (and server_log.txt)
Код:
[hh:mm:ss] Script[gamemodes/script.amx]: Run time error 20: "Invalid index parameter (bad entry point)"
pawn Код:
main()
{
print("My gamemode from scratch is loaded! :D");
return 1;
}
We also have OnGameModeInit. That'll be called when the gamemode starts. You can (re)set strings here, create textdraws e.d. Just add in your script (not in main or another callback): OnGameModeInit()
Then, open it with brackets( { & } ). In the brackets you have to fill in the information you want. For example, the AddPlayerClass. That one is important too!
If you won't add that, and when you spawn after connecting, you'll 'crash'. I mean with that, that you get a screen with the text Stay within the world boundries! and some weird colors.
When you say something in the chat, it'll be showed really strange. AddPlayerClass has the following params:
Код:
AddPlayerClass(skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo); skin = the skin id x = The X spawn position y = The Y spawn position z = The Z spawn position (height) Angle = The angle, where the player looks at when spawning weapon1-3 = Weapon 1-3 ([url=http://weedarr.wikidot.com/gunlist]ID) weapon1-3_ammu = Ammu in weapon 1-3
pawn Код:
AddPlayerClass(SKINID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
There's by the way also an OnGameModeExit. This one'll be called when the gamemode exists, so when you use rcon command 'exit' or 'gmx'. Just clicking [X] on your console won't work!
Adding vehicle's is also VERY usefull. This can you do with three different functions:
pawn Код:
CreateVehicle(modelid, Float:x, Float:y, Float:z, Float:angle, color1, color2, respawn_delay);
AddStaticVehicle(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2);
AddStaticVehicleEx(modelid, Float:spawn_x, Float:spawn_y, Float:spawn_z, Float:angle, color1, color2, respawn_delay);
How to find positions?
Well, I ever made a filterscript named Ultimate Ingame Editor.
With this you can:
* Add vehicles and save them into a file
* Add positions and save them into a file (with or without function names)
* Make teleport commands and them them into a file
* Add a pickup with info and save it into a file (health, armour, info pickup, custom: Edit it yourself)
Here's the topic: https://sampforum.blast.hk/showthread.php?tid=184733
After all the important includes, defines and functions, you are more on your own! Now, the two questions'll come (back).
What do you want? What do you need? If you're gonna include your own usersystem, I recommend you to make that one first
I'll make a good tutorial soon for making user systems! The most are using MySql, and alot of people don't know that or don't want that. I found two other tutorials, but they're using the slow dini! I'll make one that's using DJSON and ZCMD!
You're now on you're own. 'cuz there probably over million different script ways, ideas etc, I won't give more information
Well, I'll put some usefull standard functions below this, but you need to make systems your own! Off course you can ask questions in this topic .
Usefull STANDARD functions e.d.
SetTimer - Will start a timer. You're gonna need (custom) callbacks for this! Just adding 'public callback()' won't work! Use forward:
pawn Код:
forward MyFunction();
public MyFunction()
{
return 1;
}
It works like this:
SetTimerEx(callbackname, interval, repeat, param_type_code, param_string);
If you don't understand this, I'll give an example of this callback:
pawn Код:
forward KickPlayer(playerid);
public KickPlayer(playerid)
return Kick(playerid);
SetTimerEx("KickPlayer", 5000, false, "i", playerid);
The '5000' is the time in milli seconds when the function'll be called. (1 second = 1000 milli seconds. 1 minute = 60000 milli seconds).
The 'false' means, that the function won't be repeated. When you use 'true', the function'll be called every 5 seconds
The "i" stands for "integer". The playeris is just a single integer, that's why you're gonna need "i", "d". I'll give the most used 'tags'.
"i" = integer
"d" = omg forgotten... same effect as "i"
"s" = string (text string)
"f" = float (0.00000000).
This is the most usefull stuff
If you're really don't know alot yet, I recommend you reading the next tutorials:
* How to find bugs (learn more about debugging)
* Script cleanup (how to make a script looking more 'professional')
* Tutorial for script beginners (more important stuff)
And as last, but not least at all!
Don't forget to add credits if you're using someone's include, function, script etc!!!
Put this above in the gamemode or make a new file! Here's an example of my 'CREDITS.txt'
Код:
The SA:MP Team: [www.sa-mp.com] * Server scripting functions Kwarde: [www.rl-rp.com] * The gamemode/script * The idea * Outside prison * Bank interior Dracoblue: [www.dracoblue.net] * Djson include * Dini include Incognito: * Incognito's streamer [https://sampforum.blast.hk/showthread.ph...6.19059212 Zeex: * ZCMD [https://sampforum.blast.hk/showthread.ph...6.19059212 Alex_Valde: * The Prison INTERIOR. (OZ Prison). [https://sampforum.blast.hk/showthread.ph...6.19059212 ******: [www.y-less.com] * sscanf * Some tutorials Slice: * Hold studio - For the weapon holdster script * Some tutorials * Mailer include Wups: * OnPlayerShootPlayer include [https://sampforum.blast.hk/showthread.ph...6.19059212 Admantis: * After dead, laying on ground IDEA (made by myself) [Afterlife/accept dead : https://sampforum.blast.hk/showthread.php?tid=205223]
I think I gave enough now. Say it again if I miss something
I'll add it then, probably.
Good luck
- Kevin