[Tutorial] How to start creating your own Gamemode?
#1

Introduction:

- Hello... I will explain, how to create your own Gamemode..

- Before starting, you need to download Windows/Linux package from here.
- After downloading, you will have a .ZIP Archive, like this:






- To start scripting, you need to enter in: /pawno/pawno.exe/




- Then, you will get a window. To open a filescript, you put:




- Then, we can start real scripting.


Vehicles:

- Adding vehicles. We can add vehicles under OnFilterScriptInit() if it's a filescript, or OnGameModeInit() if it's a Gamemode.

You can add vehicles, static vehicles, under below publics, and with a model. The model it's:

pawn Код:
AddStaticVehicle(Vehicle Model, X, Y, Z, Angle, Color1, Color2);
VehicleModel - Represent the model of vehicle. You can find model right here!
X - Represent the X Position where car it's.
Y - Represent the Y Position where car it's.
Z - Represent the Z Position where car it's.
ATENTION: These positions, you find them, by going In-Game and writing: /Save, then going in My Documents/Gta Sa User Files/SAMP/savedpositions.txt. If you open them, you will have some positions with AddPlayerClass(), if you wasn't in car when typed command, and AddStaticVehicle(), if you was in car when typed command... Well, you can look below in photo more details:



- You can also, add a vehicle by going In-Game, typing /Save, when you are in a car, going in savedpositions.txt, copying AddStaticVehicle(), and put him under OnFilterScriptInit() or OnPlayerGameModeInit() publics.

Color1 - Self explantory.
Color2 - Self explantory.

- Also, you can see all cars colors, by clicking right here!

Command proccesors:

- Making a command to spawn a vehicle.

- To make this, you need to have an include.A proccesor command. I think fastest Command Proccesor it's ZCMD, made by Zeex.To make a command, using ZCMD you need to download him from right here!After download him, you need to go in your SA-MP Folder in /pawno/include/ folder, and paste zcmd.incin that folder. Also, you enter in pawno.exe, and at the top of script, where it's #include <a_samp> add:

pawn Код:
#include <a_samp>
#include <zcmd>
- Now, we are ready to make a command to spawn a vehicle. So, scroll down, page, down, down, and then we will make command to spawn vehicle! Here's a model, with zcmd.inc command proccesor.

pawn Код:
CMD:CommandName(playerid, params[]) // This it's ZCMD model to make a command. Replace "CommandName" with your Command name.
{ // Open bracket!
    return 1; // Returns the value. You need to put this at final of all commands!
} // Closing bracket!

ATTENTION: If you open bracket, you need to move next line 4 SPACES IN FACE. If you close bracket, you need to move next line 4 SPACES BACK, else you will get an error: "loose identitation" when compile.


- Now, let's start with spawns car command!

pawn Код:
CMD:spawncar(playerid, params[]) // Well command
{ // Open bracket!
    new Float:X, Float:Y, Float:Z, Float:A; // Defines the position X, Y, Z, Angle
    GetPlayerPos(playerid, X, Y, Z); // Will get the player's position.
    GetPlayerFacingAngle(playerid, A); // Will get the player's facing angle.
    AddStaticVehicle(411, X, Y, Z, A, 1, 1); // Will spawn a car at his position.
    return 1; // Returns the value
} // Closing bracket
new Float:X, Y, Z, A --> We define the position of that player, because playerid it's the player wich use that command "spawncar". So define the position of that player!
GetPlayerPos(playerid, X, Y, Z); --> With new Float; variables, we get the position X, Y, Z of that player wich use command /spawncar.
GetPlayerFacingAngle(playerid, A);--> With A Float; defined, we get the player's Angle position.

AddStaticVehicle(411, X, Y, Z, A, 1, 1); --> Well, 411 it's the model of that car [INFERNUS], X, Y, Z, A it's the position of that player, and 1, 1 it's first and second color of that car. If a car it's like an Infernus, then he got only first color, White, in our case, but if that car it's a car like Bashee or Bullet, then will get both of colors.

Teleports:

- Well... In this game, you can also make teleports. For that, we need to go In-Game. Go at place, where do you want to get teleported and type: /Save. I explain one time again. After you typed, go to /My Documents/GTA San Andreas User Files/SAMP/savedpositions.txt, and open savedpositions.txt, and you will have there some position. You need only X, Y, Z position. Let's suppose this it's a position from savedpositions.txt.

pawn Код:
AddPlayerClass(217,2244.5071,-1665.0314,15.4766,166.2733,0,0,0,0,0,0); //

// You don't need AddPlayerClass and first number [217], to create a teleport
// So, we remove them, and remain with: 2244.5071,-1665.0314,15.4766,166.2733,0,0,0,0,0,0);
// Also, we don't need "0" from final to create a teleport, so remove them too.
// We remain with: 2244.5071, -1665.0314, 15.4766, 166.2733
// Last number, "166.2733", from final, you don't need it. [OF COURSE, YOU WILL HAVE ANOTHER NUMBER].
// We remain with only 3 numbers: 2244.5071,-1665.0314,15.4766.
// That number it's X, Y, Z position.
- Now, after found X, Y, Z position, we scroll down, down, and we will make command.

pawn Код:
CMD:teleport(playerid, params[])
{
    SetPlayerPos(playerid, 2244.5071,-1665.0314,15.4766);
    SendClientMessage(playerid, -1, "{FFCC33}You teleported to this location!");
    return 1;
}
EXPLAIN:So, SetPlayerPos(); will sets player pos to specified location, but of course, you will have another positions. SendClientMessage(playerid, -1, " ");, will send a message to a player. Also, that "{FFCC33}" from message, represent a color.

USEFUL TOPICS:

You can also find colors ColorPicker.com
You can also find more details about SendClientMessage right here.
You can also find more details about SetPlayerPos right here!

Compiling:

- To finish what you did in pawno, you need to compile. You can compile only by pressing a button.



- Well, that button it's compiler. If you press him, you will get something like this, if you made all correct.



- Else, if you made mistakes, you will get errors and warnings. You can try solve them, using Jochemd tutorial about SA-MP Compiler Warnings and Errors or using SA-MP Wiki Errors and Warnings List!


Pawno.exe bar:



Callbacks:

- Callbacks...every time, when you open a new file, you will have callbacks. This Callbacks describe an action of a player from game. For example:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    return 1;
}
- So this it's a callback. You can do what do you want with that callbacks. You edit them like this:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid)
{
    SendClientMessage(playerid, -1, "You entered in a vehicle");
    return 1;
}
- So now, when he enter in vehicle, he will get message "You entered in a vehicle" without " ". Pawno have 42 callbacks. More callbacks, are made by usual SA-MP Players in a .INC File [INCLUDE File]. In Includes file, you have natives and callbacks. So, you can search more callbacks at Includes Topics SA-MP Forum.

- Simple callbacks are:

OnPlayerKnifePlayer.inc by Abagail.

OnPlayerAirbreak.inc by Emmet_.

- If you want to see all calbacks, without enter in a new file, you can search right here.


Checkpoints:

- On SA-MP you can create too Checkpoints. A simple command to add checkpoints it's:

pawn Код:
CMD:checkpoint(playerid, params[])
{
    SetPlayerCheckpoint(playerid, X, Y, Z, 5.0);
    return 1;
}
X, Y, Z = Positions of checkpoint's position!
5.0 = Checkpoint size.

- Like this, you can make only 1 checkpoint. If you want to create more checkpoints, you need to use Streamer Plugin created, thank you, by Incognito.

More details about SetPlayerCheckpoint you find right here!

Pick-ups:

- You can create too Pick-ups. To create pick-ups, you need to create a variable, with Pick-up name:

pawn Код:
new pickup;
- So, you created the variable. If you compile, you will get a error. But if you continue, error will disapper. Error it's : "Symbol is never used". So, if you don't use him, you will get this error.
- Under OnFilterScriptInit() or OnGameModeInit() we add:

pawn Код:
pickup = CreatePickup(1239, 2, X, Y, Z);
Great. We created pickup. 1239 it's pick-up ID. You can find more pick-up ID's, right here!. Also, 2, it's a pick-up type, wich can be found right here!. X, Y, Z are pick-up positions X, Y, Z. We spoke about callbacks, below. Pick-up have a callback, called, when a player enter in a pick-up.

pawn Код:
public OnPlayerPickUpPickUp(playerid, pickupid)
{
    return 1;
}
So, when a player enter in pick-up, you can give to him something, or to send him something.

pawn Код:
public OnPlayerPickUpPickUp(playerid, pickupid)
{
    if(pickupid == pickup) // if enters in our pick-up variable created
    {
        SendClientMessage(playerid, -1, "You entered in pick-up!"); // Will send this message!
    }
    return 1;
}
- More details about Pick-ups you find right here!

Advanced Scripting:

- If you want to create alone something more advanced, you can start making alone a Vip/Admin System.Let's try to make a Vip System.Starting with enumerators:

pawn Код:
enum vInfo // Enumerator for Vip Info.
{ // Open bracket
    Vip // Vip defined
} // Close bracket
new VipInfo[MAX_PLAYERS][vInfo]; // Vip Variable for Vips Players
- And you need to start with "/MakeVip" command. Self explinatory, but, this will make a player VIP. To make this, you need to have a another include, with his name SSCANF.inc, made by, thanks, ******. After that, put SSCANF.inc in your /pawno/include/ folder. After this, you can start making command.

pawn Код:
CMD:makevip(playerid, params[]) // "/MakeVip" command
{ // Open bracket.
    new ID; // ID, for that player wich will make vip!
    if(IsPlayerAdmin(playerid)) // If that player, wich use command it's RCON !
    { // Open bracket!
        if(sscanf(params,"u", ID)) return SendClientMessage(playerid,-1 ,"USAGE: /MakeVip [ID]"); // If he don't write ID, will Send message to him with "Correct Usage"
        VipInfo[ID][Vip] = 1; // Will set to "ID" Vip 1.
    } // Close bracket !
    else // Else, if he isn't RCON
    { // Open bracket !
        SendClientMessage(playerid, -1, "You aren't RCON"); // Sends message, if he isn't rcon!
    } // Closing bracket!
    return 1; // Returns the value!
} // Closing Bracket;
- So, you make /makevip command.... Now, let's create some VIP Commands. The model for that commands, of course, if you made all enums like me, are:

pawn Код:
CMD:CommandName(playerid, params[])
{
    if(VipInfo[playerid][Vip] == 1)
    {
        // YOUR CODE RIGHT HERE.
    }
    else
    {
        SendClientMessage(playerid, -1, "You aren't VIP!");
    }
    return 1;
}
- SSCANF: It's very useful, SSCANF + ZCMD, I think it's the best combination, because all commands work more faster. SSCANF have this:

pawn Код:
Specifier(s)            Name                Example values
    i, d            Integer             1, 42, -10
    c           Character           a, o, *
    l           Logical             true, false
    b           Binary              01001, 0b1100
    h, x            Hex             1A, 0x23
    o           Octal               045 12
    n           Number              42, 0b010, 0xAC, 045
    f           Float               0.7, -99.5
    g           IEEE Float          0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
    u           User name/id (bots and players) ******, 0
    q           Bot name/id         ShopBot, 27
    r           Player name/id          ******, 42
Last Words:

- Well... I hope this tutorial will help some players.
Reply
#2

It looks pretty good.
Reply
#3

Quote:
Originally Posted by Aerotactics
Посмотреть сообщение
It looks pretty good, although, I would clean it up if I were you. Keep everything 1 font, I saw 3 or 4 different fonts. Also keep all descriptive text the same size, and all topics the same size. Looks a little messy.
Thanks. I writed with a black, and "" important things. I think newbies doesn't look at font.
Reply
#4

very good tutorial
Reply
#5

Good tutorial
Reply
#6

Such a terrible tutorial.
- Hardly explains why you did what you did
- Didn't show linux steps.
Reply
#7

Quote:
Originally Posted by Khanz
Посмотреть сообщение
Such a terrible tutorial.
- Hardly explains why you did what you did
- Didn't show linux steps.
Second That.
Reply
#8

easy tuto for me ..
thank you
Reply
#9

Thank you
Reply
#10

Thanks for this tutorial
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)