23.10.2012, 09:57
How to begin with Scripting my Server!
Download Links!
MTA Mapping Software: CLICK ME!
MTA Converter: CLICK ME!
Includes/Plugins: CLICK ME!
Please give me Rep++, I worked really hard!
__________________________________________________ _______________________________________________
Introduction
Hello all, I've made this tutorial becoz' i want to show begginer scripterz how to Script a Simple Server.I will show you how to begin with the primary scripting!
Lets Go!
First what is very important you have to know which Includes and Plugins you will use.The Inc&Plugs are very important mostly they are system operators and they use for ex. in Reg/Log systems and they are saving all your stuff.
Here are some Inc/Plugs!
You must Define some primary things like Colors or some Functions
Here are some Color defines made by me! (You have to put this on the top of script)
What kind?
Then you have to ask yourself ''What kind of Server I want?"....The simplest kind of a Server is Freeroam!
A Freeroam is a server where players can do anything they want except hacking etc..
To a Freeroam GM you can add everything you want cuz' there are not very much rules like "How to Play?" like in RP servers...
Scripting
Ok, now come the best part of my tutorial... The scripting *_*
First you have to Compile the script that you have get in your pawno folder.Then if its compiled successfully then you can start scripting....Now watch what you have to do!
1. Give your Gamemode a name
2. You have to create a simple function
3. You must Add a player class
4. You can add Vehicles & Objects
5. Creating simple commands!
__________________________________
1. Give your gamemode a name!
You can give your gamemode a name which you want....You can give you GM a name on this way!
Find this code in your script!
This "Blank Script" is the Name of the GameMode!
You can edit it and change the test
Warning: Never remove this "" in any of your editions cuz' the script wont work!
Ok now we have set the name of the Gamemode to "Tutorial"
2. Creating a Simple function
We will now create simple Function like a text which show to you does your server work!
Now thats the text.....now i show you how to create a simple Message to the player when he connects to server!
Ok this text will be showen when you connect to server!
3. AddPlayerClass
This is very very important...If you dont Add a player class the server will not work correctly!
Ok now ill show you how to add a player class!
You have to find this code!
Then you add this!... AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
Ok now you have a PlayerClass! And you can add more player classes!
I show you now the meaning of the parameters
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 (ID)
weapon1-3_ammu = Ammu in weapon 1-3
4. Add Vehicles & Objects!
Adding Vehs and Objects is not very simple but you can do it!
The best way is That you have MTA ( a Mapping Software )...With MTA you can place Vehicles & Objects anywhere you want...Then you can choose the MTA codes convert them and Add to script....Follow my steps!
Add a Vehicle
Here are 3 codes to add a vehice but you can use any u want!
Add a Object
Its the Same like in Add vehicle but here are the code begginings
5.Creating Simple Commands!
For creating command we will use STRCMP not any other operator!
Here are some primary commands like: /heal , /getcash ,/repair & one teleport /ls
THE END
Thank you guyz for watching! I've been working Two hours on this TuT! so sorry if i missed something to write!
Download Links!
MTA Mapping Software: CLICK ME!
MTA Converter: CLICK ME!
Includes/Plugins: CLICK ME!
Please give me Rep++, I worked really hard!
__________________________________________________ _______________________________________________
Introduction
Hello all, I've made this tutorial becoz' i want to show begginer scripterz how to Script a Simple Server.I will show you how to begin with the primary scripting!
Lets Go!
First what is very important you have to know which Includes and Plugins you will use.The Inc&Plugs are very important mostly they are system operators and they use for ex. in Reg/Log systems and they are saving all your stuff.
Here are some Inc/Plugs!
Код:
Dini , sscanf , MySQL , foreach , dudb ....
Here are some Color defines made by me! (You have to put this on the top of script)
Код:
#define COLOR_WHITE 0xFFFFFFC8 #define COLOR_YELLOW 0xFFFF00C8 #define COLOR_GREEN 0x00FF00C8 #define COLOR_BLUE 0x0080C0C8 #define COLOR_PURPLE 0x8000FFC8 #define COLOR_PINK 0xFF0080C8 #define COLOR_ORANGE 0xFF8000C8 #define COLOR_GRAY 0x808080C8 #define COLOR_BLACK 0x000000C8
Then you have to ask yourself ''What kind of Server I want?"....The simplest kind of a Server is Freeroam!
A Freeroam is a server where players can do anything they want except hacking etc..
To a Freeroam GM you can add everything you want cuz' there are not very much rules like "How to Play?" like in RP servers...
Scripting
Ok, now come the best part of my tutorial... The scripting *_*
First you have to Compile the script that you have get in your pawno folder.Then if its compiled successfully then you can start scripting....Now watch what you have to do!
1. Give your Gamemode a name
2. You have to create a simple function
3. You must Add a player class
4. You can add Vehicles & Objects
5. Creating simple commands!
__________________________________
1. Give your gamemode a name!
You can give your gamemode a name which you want....You can give you GM a name on this way!
Find this code in your script!
Код:
public OnGameModeInit() { SetGameModeText("Blank Script"); return 1; }
You can edit it and change the test
Warning: Never remove this "" in any of your editions cuz' the script wont work!
Код:
public OnGameModeInit() { SetGameModeText("Tutorial"); return 1; }
2. Creating a Simple function
We will now create simple Function like a text which show to you does your server work!
Код:
main () { print ("Tutorial GM successfully Loaded!"); return 1; }
Код:
public OnPlayerConnect(playerid) { SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Server!"); return 1; }
3. AddPlayerClass
This is very very important...If you dont Add a player class the server will not work correctly!
Ok now ill show you how to add a player class!
You have to find this code!
Код:
public OnGameModeInit() { SetGameModeText("Tutorial"); return 1; }
Код:
public OnGameModeInit() { SetGameModeText("Tutorial"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); return 1; }
I show you now the meaning of the parameters
Код:
AddPlayerClass(skin, Float:x, Float:y, Float:z, Float:Angle, weapon1, weapon1_ammo, weapon2, weapon2_ammo, weapon3, weapon3_ammo);
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 (ID)
weapon1-3_ammu = Ammu in weapon 1-3
4. Add Vehicles & Objects!
Adding Vehs and Objects is not very simple but you can do it!
The best way is That you have MTA ( a Mapping Software )...With MTA you can place Vehicles & Objects anywhere you want...Then you can choose the MTA codes convert them and Add to script....Follow my steps!
Add a Vehicle
Код:
CreateVehicle (modelid, Float: x, Float: y, Float: z, Float: kut, color1, color2, respawn_delay); AddStaticVehicle (modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: kut, color1, color2); AddStaticVehicleEx (modelid, Float: spawn_x, Float: spawn_y, Float: spawn_z, Float: kut, color1, color2, respawn_delay);
Add a Object
Its the Same like in Add vehicle but here are the code begginings
Код:
CreateObject & CreateDynamicObject
For creating command we will use STRCMP not any other operator!
Here are some primary commands like: /heal , /getcash ,/repair & one teleport /ls
Код:
//------------ Heal public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(heal, 4, cmdtext); return 0; } dcmd_heal(playerid, params[]) { new id; if (sscanf(params, "u", id)) SendClientMessage(playerid, 0xFF0000AA, "Usage: \"/heal <playerid>\""); else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found"); else { SetPlayerHealth(id, 100.0); SendClientMessage(id, 0x00FF00AA, "You have been healed"); SendClientMessage(playerid, 0x00FF00AA, "Player healed"); } return 1; }
Код:
//------------------Givecash public OnPlayerCommandText(playerid, cmdtext[]) { dcmd(givecash, 8, cmdtext); return 0; } dcmd_givecash(playerid, params[]) { new giveplayerid, amount; if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname] [amount]"); else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found"); else if (amount > GetPlayerMoney(playerid)) SendClientMessage(playerid, 0xFF0000AA, "Insufficient Funds"); else { GivePlayerMoney(giveplayerid, amount); GivePlayerMoney(playerid, 0 - amount); SendClientMessage(playerid, 0x00FF00AA, "Money sent"); SendClientMessage(giveplayerid, 0x00FF00AA, "Money received"); } return 1; }
Код:
//---------------Repair public OnPlayerCommandText(playerid, cmdtext[]) { if (!strcmp("/repair", cmdtext)) { if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!"); RepairVehicle(GetPlayerVehicleID(playerid)); SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!"); return 1; } }
Код:
public OnPlayerCommandText(playerid,cmdtext[]) { if(!strcmp(cmdtext,"/ls",true)) { SetPlayerPos(playerid,1024.2322,-1125.7014,23.8736); return 1; } return 0; }
Thank you guyz for watching! I've been working Two hours on this TuT! so sorry if i missed something to write!