YSI:Tutorial 0

From SA-MP Wiki

Jump to: navigation, search

Contents

Introduction

This tutorial will cover setting up a very basic gamemode first and then go on to set up a nice little class selection screen for it. This will introduce you to using YSI, and the class selection and group libraries.

A basic mode

Ok, this is quite complicated so pay attention:

1) After installing YSI open up pawno and click "new". This is the left most icon at the top left of the screen, it can also be found under File->New.

1b) You can optionally change the author name, look for:

print("\n--------------------------------");
print(" YSI Gamemode by your name here");
print("--------------------------------\n");

And edit the text in the quotes.

2) Save the file in your gamemode folder.

3) Compile.

4) Run your mode.

You now have your first YSI mode done, if you go in game you'll find it's not really that interesting, the standard class selection screen and spawn point, with three vehicles at the bottom of the escalators. Not really that much different to a non-YSI script.

However, from here you can now type /commands and you will discover a whole host of features, including fully integrated user and help system already implemented. You will also see some commands which can't be used currently, we'll cover both how to use and how to disable these later.

Group crash course

Put simply a group is a collection of people, this can be a team, a faction, an admin level, a gang, a job or any other way of grouping people you can think of, basically YSI has abstracted all these various representations to simplify coding. Unlike almost every implementation of all these things however you can be in multiple groups at once, this makes for very simple coding for example for things like admin scripts to allow admins access to faction only commands without being in the faction, or to allow people to be an admin and a team member at the same time without having to write two almost identical systems.

There are three types of groups - default groups, custom groups and temporary groups. The default group is the one everyone and everything is in by default, this allows everyone to use everything unless told otherwise. You can remove things from the default group (e.g. to restrict access to a command) but not people. Custom groups are for things like admin groups and teams, they do not have any people or settings by default, but they can be added to to allow for example only people in that group to use a command (or at least allow people in that group to use a command, depending on other group settings other people may be able to use that command too). These groups are automatically saved when you leave the server (assuming you are logged in). Temporary groups are functionally identical to custom groups but they are not saved when you log out. They are generally used to control unimportant things like class selected, as we will see later. The only difference between a custom group and a temporary group is that a custom group has a name. You can make a custom group into a temporary group simply by removing it's name, and vice-versa by adding a name.

The group system controls almost every aspect of YSI, so is a very powerful tool once you understand it. The reason it is brought up now is because as well as controlling big things like teams and admins, it can at the same time be used to control small things like who can see a class (YSI's class selection system is entirely dynamic, allowing you to set, either manually or with the group system, exactly who can and can't use and see every class).

Adding an user only class

The simplest way of demonstrating this feature is to have two classes - one which anyone can use and one which only people logged in to the server can use. First we need to adjust the selection screen view so we can actually see the different classes, this will just set the selection screen to be in front of CJ's house, you can put it anywhere you like:

Script_OnPlayerRequestClass(playerid, classid)
{
	// Set the camera to outside CJ's house
	SetPlayerPos(playerid, 2495.3022, -1663.2081, 17.3359);
	SetPlayerCameraPos(playerid, 2495.3022, -1664.2081, 17.3359);
	SetPlayerCameraLookAt(playerid, 2495.3022, -1670.2081, 17.3359);
	return 1;
}

Now we need to add our two classes:

Personal tools
Navigation
Toolbox