[Tutorial] [TuT] How to Script Server!
#1

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!

Код:
Dini , sscanf , MySQL , foreach , dudb ....
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)

Код:
#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
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!


Код:
public OnGameModeInit()
{
	
	SetGameModeText("Blank Script");
	
	return 1;
}
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!

Код:
public OnGameModeInit()
{
	
	SetGameModeText("Tutorial");
	
	return 1;
}
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!

Код:
 main () 
  { 
  print ("Tutorial GM successfully Loaded!"); 
  return 1; 
  }
Now thats the text.....now i show you how to create a simple Message to the player when he connects to server!

Код:
public OnPlayerConnect(playerid)
{

  SendClientMessage(playerid, COLOR_YELLOW, "Welcome to Server!");
	return 1;
}
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!


Код:
public OnGameModeInit()
{
	
	SetGameModeText("Tutorial");
	
	return 1;
}
Then you add this!... AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);

Код:
public OnGameModeInit()
{
	
	SetGameModeText("Tutorial");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}
Ok now you have a PlayerClass! And you can add more player classes!
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);
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

Код:
  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);
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

Код:
CreateObject & CreateDynamicObject
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

Код:
//------------ 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;
}
THE END

Thank you guyz for watching! I've been working Two hours on this TuT! so sorry if i missed something to write!
Reply
#2

Good one but you must EXPLAIN MORE for beginners and don't mention anything about MTA this is SA-MP forums and samp already has its own map editor
Reply
#3

What's going with this?

Everyone make's a tutorial put this and put this with bad grammar?

Although,you have many spelling problems,and some of this is copied of the SA-MP wiki!

On: Try to do something better next time.
Reply
#4

Quote:
Originally Posted by WizBoy
Посмотреть сообщение
For creating command we will use STRCMP not any other operator!
Operator??
It must be command processor.
Reply
#5

Sorry guyz but i know that the name is Command Processor but i heard somewhere this operator.....but if it is False i wont use it
Reply
#6

Quote:
Originally Posted by WizBoy
Посмотреть сообщение
Sorry guyz but i know that the name is Command Processor but i heard somewhere this operator.....but if it is False i wont use it
Guyz? And making a noob tutorial to get reputation?


Simply noob and fail tutorial,you should learn scripting and at least go take some English lessons,that will correct your faults you made now,and please do not post another noob tutorial,make something useful for people that they can understand,I mean oh my god I only got 1 tutorial and it's basic and I'm happy I don't get reputation for that,because if I will,then it will be a total noob tutorial,just take my advice.
Reply
#7

Quote:
Originally Posted by James_Nick
Посмотреть сообщение
Guyz? And making a noob tutorial to get reputation?


Simply noob and fail tutorial,you should learn scripting and at least go take some English lessons,that will correct your faults you made now,and please do not post another noob tutorial,make something useful for people that they can understand,I mean oh my god I only got 1 tutorial and it's basic and I'm happy I don't get reputation for that,because if I will,then it will be a total noob tutorial,just take my advice.
Quote:

If you like this tutorial subscribe to this thread and REP me!

Why did you ask for rep in your tutorial then

OT:

And yea you need to be better in English.

EDIT:

Here

Quote:
Originally Posted by James_Nick
Посмотреть сообщение
Introduction

Launching the server
Now we done everything we need,let's start the server and play after you saved the settings on the server.cfg you will need to open a file called samp-server.exe open it and add this I.P to your favourites "127.0.0.1" If you want your friends to play with you you need an open port,Check out how to portforward Here!


If you have suggestions you want me to add or having questions ask here simply!
If you like this tutorial subscribe to this thread and REP me!
Reply
#8

Quote:
Originally Posted by gtakillerIV
Посмотреть сообщение
Why did you ask for rep in your tutorial then

OT:

And yea you need to be better in English.
Proof that I asked for reputation? or simply being a n00b and saying that I asked for?
Reply
#9

Quote:
Originally Posted by James_Nick
Посмотреть сообщение
Guyz? And making a noob tutorial to get reputation?


Simply noob and fail tutorial,you should learn scripting and at least go take some English lessons,that will correct your faults you made now,and please do not post another noob tutorial,make something useful for people that they can understand,I mean oh my god I only got 1 tutorial and it's basic and I'm happy I don't get reputation for that,because if I will,then it will be a total noob tutorial,just take my advice.
Way to go, destroy a possibly brilliant mind's hopes. You want another Hitler(For those that don't know, a possible theory why Hitler hated Jews is that they crushed his hopes and dreams as a artist)?
Reply
#10

Quote:
Originally Posted by JhnzRep
Посмотреть сообщение
Way to go, destroy a possibly brilliant mind's hopes. You want another Hitler(For those that don't know, a possible theory why Hitler hated Jews is that they crushed his hopes and dreams as a artist)?
Dude, why are you bringing Hitler into this?

On topic:
By the way, there are like 50 tutorials about this.. The SA:MP wiki already has it all.

https://sampwiki.blast.hk/wiki/PAWN_for_Begginers
https://sampwiki.blast.hk/wiki/Windows_Server
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)