[Tutorial] How to make groups/teams and how to set team cars and team cmds.(y_groups / y_classes / y_commands)
#1

Hello forum members!

This is my first tutorial and I will try to explain how to use y_groups to set player team with them.

So first of all you need to download YSI you can find it here : https://sampforum.blast.hk/showthread.php?pid=1696956#pid1696956
After downloading extract it and you will see the folder YSI-master cut out the contents of a folder and paste it in your server localation.

Now when it's done open new pawn and add include.
pawn Code:
#include <YSI\y_groups>
#include <YSI\y_classes>
After that we will start to add new variables (groups).

Ofcorse this will be only example for that you can set group names as you wish.
pawn Code:
new
    Group:gHoodRats, //So this is team one my choosen name is HoodRats as you can see.
    Group:gGSF, //group 2
    Group:gSBF, //group3
    Group:gTDF //group 4
;
So basicly we have 4 groups (only variables so now wee will define them as groups)

Under public OnGameModeInit()

we need to set groups definitions.

pawn Code:
gHoodRats = Group_Create("HoodRats"); //Basically we set group one.
    gGSF = Group_Create("GSF"); //Group 2
    gSBF = Group_Create("SBF"); //Group 3
    gTDF = Group_Create("TDF"); //Group 4
Now we will set group by AddPlayerClass to see which is in which team. (Basically TDM Or DM server sets)
pawn Code:
Class_AddWithGroupSet(gHoodRats,15, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gHoodRats,170, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gHoodRats,183, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gHoodRats,263, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    //GroveStreet
    Class_AddWithGroupSet(gGSF,270, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gGSF,105, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gGSF,106, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gGSF,107, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    //SBF
    Class_AddWithGroupSet(gSBF,0, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gSBF,105, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gSBF,106, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gSBF,107, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    //TDF
    Class_AddWithGroupSet(gTDF,269, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gTDF,105, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gTDF,106, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
    Class_AddWithGroupSet(gTDF,107, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
Here will be some explanation why I'm using Class_AddWithGroupSet( and not another function.

To let player choose more groups you can only setting group current skins. If you will use Class_AddForGroup(group,

Player who connected will see only current skins which will be added to the group with this function.
So for example:

If you are using multiple groups like in this case (example):

pawn Code:
Class_AddForGroup(gCrips, 29, 0, 0, 0, 0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
Class_AddForGroup(gAdmin, 29, 0, 0, 0, 0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);  
Class_AddForGroup(gLeader, 29, 0, 0, 0, 0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);  
Class_AddForGroup(gVIP, 29, 0, 0, 0, 0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
So, when a player connects you will see only a group of crips because he will automatically set the player group crips.
Using Class_AddForGroup (group, function group which sees the player chooses, and gives him his selected group.

I hope that you have noticed that the next step is to add to the player's individual class with skin to current groups.

So as at start we setted this variables:
pawn Code:
new
    Group:gHoodRats, //So this is team one my choosen name is HoodRats as you can see.
    Group:gGSF, //group 2
    Group:gSBF, //group3
    Group:gTDF //group 4
;
Now we will use them.
For example:
pawn Code:
Class_AddWithGroupSet(group, skin, x, y, z, a, (weapon, amm));
You need to change group to your variable like : gHoodRats which was set on variable.

So as next step is add weapons and armor.
So here will be some list of weapons you can add:
pawn Code:
WEAPON_BRASSKNUCKLE                
WEAPON_GOLFCLUB                  
WEAPON_NITESTICK                
WEAPON_KNIFE                  
WEAPON_BAT                        
WEAPON_SHOVEL                    
WEAPON_POOLSTICK                
WEAPON_KATANA                  
WEAPON_CHAINSAW                    
WEAPON_DILDO                    
WEAPON_DILDO2                
WEAPON_VIBRATOR                  
WEAPON_VIBRATOR2                
WEAPON_FLOWER                    
WEAPON_CANE                        
WEAPON_GRENADE                    
WEAPON_TEARGAS                    
WEAPON_MOLTOV                    
WEAPON_COLT45                
WEAPON_SILENCED
WEAPON_DEAGLE                  
WEAPON_SHOTGUN                    
WEAPON_SAWEDOFF                    
WEAPON_SHOTGSPA                    
WEAPON_UZI                        
WEAPON_MP5                        
WEAPON_AK47                        
WEAPON_M4                        
WEAPON_TEC9                        
WEAPON_RIFLE                    
WEAPON_SNIPER                    
WEAPON_ROCKETLAUNCHER            
WEAPON_HEATSEEKER                
WEAPON_FLAMETHROWER                
WEAPON_MINIGUN                    
WEAPON_SATCHEL                  
WEAPON_BOMB                        
WEAPON_SPRAYCAN                    
WEAPON_FIREEXTINGUISHER            
WEAPON_CAMERA                    
WEAPON_PARACHUTE
So and now how to set amount of bullets and weapons for example:
pawn Code:
WEAPON_MP5 //Weapon name
500 //Bullets
WEAPON_ARMOUR
50 //How much armor player will have

And this is how it needs to look:
Class_AddWithGroupSet(gTDF,107, 1958.3783, 1343.1572, 15.3746, 0.0, WEAPON_MP5, 500, WEAPON_ARMOUR, 50, WEAPON_DEAGLE, 200);
Remember that it sets armor, weapon and bullets when player spawns.

So to use them we need to remove too.

So next step is removing them OnPlayerRequestSpawn because it will set then it to another group not to the correct group thats why we need to remove them.

pawn Code:
public OnPlayerRequestSpawn(playerid)
{
    Group_SetPlayer(gHoodRats, playerid, false); // Remove from the group HoodRats
    Group_SetPlayer(gGSF, playerid, false); //Remove from the group GSF
    Group_SetPlayer(gSBF, playerid, false); //Remove from the group SBF
    Group_SetPlayer(gTDF, playerid, false); //Remove from the group TDF
    return 1;
}
Group_SetPlayer sets in which team is player.
gHoodRats = player is in hoodrats team
playerid = by connected players id
false = is not true.

So this is all about how to set groups with y_group.

Now next step how to set group cars it's very simple.

For example:

pawn Code:
enum TeamCars //Making enum for team cars..
{
    GroveStreet,
        GroveStreet1,
}
new Cars[TeamCars]; //variable

public OnGameModeInit()
{
Cars[GroveStreet] = AddStaticVehicleEx(492,2499.5000000,-1655.4000200,13.3000000,60.0000000,18,20,15); //Greenwood //sets Grovestreet car..
Cars[GroveStreet1] = AddStaticVehicleEx(412,2503.8000500,-1684.6999500,13.5000000,24.0000000,12,20,15);
return 1;
}

So here you will see example how it besaclly looksAnd which is long way... (But ain't bad to)
public OnPlayerStateChange(playerid, newstate, oldstate)
{

    if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER) //checks if player is in driver state
    {
        new CarCheck = GetPlayerVehicleID(playerid); //variable
        if(CarCheck == Cars[GroveStreet]) //check if player is in grovestreet car
        {
            if (Group_GetPlayer(gGSF, playerid)) //Check if player is in grove street
            {
                SendClientMessage(playerid, COLOR_RED, "* %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren'
t in team Grove Street Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }
                if(CarCheck == Cars[GroveStreet1]) //check if player is in grovestreet car
        {
            if (Group_GetPlayer(gGSF, playerid)) //Check if player is in grove street
            {
                SendClientMessage(playerid, COLOR_RED, "
* %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "
You aren't in team Grove Street Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }
    }
    return 1;
}
So here will be faster way.
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER) //checks if player is in driver state
    {
        new CarCheck = GetPlayerVehicleID(playerid); //variable
        if(CarCheck == Cars[GroveStreet] || Cars[GroveStreet1] || Cars[GroveStreet2]) //check if player is in grovestreet car
        {
            if (Group_GetPlayer(gGSF, playerid)) //Check if player is in grove street
            {
                SendClientMessage(playerid, COLOR_RED, "* %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't in team Grove Street Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }            
                //If you have gangs or multiple group cars....
                if(CarCheck == Cars[Bloodz] || Cars[Bloodz1] || Cars[Bloodz2]) //check if player is in grovestreet car
        {
            if (Group_GetPlayer(gBloodz, playerid)) //Check if player is in grove street
            {
                SendClientMessage(playerid, COLOR_RED, "* %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't in team Bloodz");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }          
    }
    return 1;
}
So basically that's all I will update it.

So Now I will show you how to add a command for group..
pawn Code:
public OnGameModeInit()
{
    Group_SetGlobalCommand(YCMD:kill, false);//Sets command for all players to false!
    Group_SetCommand(gGSF, YCMD:kill, true);//Sets command for gGSF members to true!
    return 1;
}
pawn Code:
YCMD:kill(playerid, params[], help)//params[] = What this does is create one variable at a suitable size [256 is NOT a suitable size!], but here we are not using it..
{
        SetPlayerHealth(playerid, 0.0); // Sets players Health to 0 Also if you want you can add SendCliendMessage
        return 1;
}
So as you can see we set cmd can be used only for team GSF So basiclly thats all.... Soon I think I will update it with saving in which groupt player is. When player connects all data will be seenable + maybe with registartion and admin system...

Big thanks to ****** and everyone who helped me to learn how to use it.

If you need some examples ask I will show you and send you by pm or post them on thread!
With Respect Scrillex!
Reply
#2

One note: I think that WEAPON_DROWN and WEAPON_COLLISION are only usable in OnPlayerDeatch as a reason, not a valid weapons
Reply
#3

Quote:
Originally Posted by Misiur
View Post
One note: I think that WEAPON_DROWN and WEAPON_COLLISION are only usable in OnPlayerDeatch as a reason, not a valid weapons
Okay, I'll take it out right now. thanks for the tip
Reply
#4

Quote:

Cars[GroveStreet] = AddStaticVehicleEx(492,2499.5000000,-1655.4000200,13.3000000,60.0000000,18,20,15);

with this if i would to add multiple vehicles how would it be? like this below

Cars[GroveStreet] = AddStaticVehicleEx(492,2499.5000000,-1655.4000200,13.3000000,60.0000000,18,20,15);
Cars[GroveStreet]2 = AddStaticVehicleEx(492,2499.5000000,-1655.4000200,13.3000000,60.0000000,18,20,15);

because i added multiple vehicles like this
but with my own groups and vehicles and only the first vehicle is locked for the group
great tut

Cars[GroveStreet] = AddStaticVehicleEx(492,2499.5000000,-1655.4000200,13.3000000,60.0000000,18,20,15);
Cars[GroveStreet] = AddStaticVehicleEx(492,2499.5000000,-1655.4000200,13.3000000,60.0000000,18,20,15);
Cars[GroveStreet] = AddStaticVehicleEx(492,2499.5000000,-1655.4000200,13.3000000,60.0000000,18,20,15);
Reply
#5

Updated!
Reply
#6

Good job 10/10
Reply
#7

Thank you mate Today I will try to update it all things what I want to include.
Reply
#8

Still only 1 car is locked
enum TeamCars //Making enum for team cars..
{
GroveStreet,
GroveStreet1,//this one is locked
GroveStreet2,
GroveStreet3,
}
new Cars[TeamCars]; //variable

Cars[GroveStreet] = AddStaticVehicleEx(492,2499.5000000,-1655.4000200,13.3000000,60.0000000,18,20,15); //not locked anyone can get in
Cars[GroveStreet1] = AddStaticVehicleEx(412,2503.8000500,-1684.6999500,13.5000000,24.0000000,12,20,15);//locked only the group can get in
Cars[GroveStreet2] = AddStaticVehicleEx(412,2503.8000500,-1684.6999500,13.5000000,24.0000000,12,20,15);//not locked anyone can get in
Cars[GroveStreet3] = AddStaticVehicleEx(412,2503.8000500,-1684.6999500,13.5000000,24.0000000,12,20,15);//not locked anyone can get in
Reply
#9

^

pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    switch(newstate) {
        case PLAYER_STATE_ONFOOT: {
            switch(oldstate) {
                case PLAYER_STATE_DRIVER: OnPlayerExitVehicle(playerid,255);
                case PLAYER_STATE_PASSENGER: OnPlayerExitVehicle(playerid,255);
            }
        }
    }
    new vehicle = GetVehicleModel(GetPlayerVehicleID(playerid));
    new Float:PX, Float:PY, Float:PZ;  
    if(vehicle == 492 || vehicle == 412 )
    {
       if(gTeam[playerid] != TEAM_GROVE) //Or whatever
       {
          GetPlayerPos(playerid,PX,PY,PZ);
          SetPlayerPos(playerid,PX,PY,PZ+3);
          SendClientMessage(playerid,COLOR_RED,"[ERROR]: This car is locked only grove street members can use it.");
       }

    }
}
Reply
#10

You saw what I updated ..
First of all this isn't
gteam I showed how to use y_groups and y_classes.. So dont show how to use gTeam in here!
pawn Code:
if(GetPlayerState(playerid)==PLAYER_STATE_DRIVER) //checks if player is in driver state
    {
        new CarCheck = GetPlayerVehicleID(playerid); //variable
        if(CarCheck == Cars[GroveStreet]) //check if player is in grovestreet car
        {
            if (Group_GetPlayer(gGSF, playerid)) //Check if player is in grove street
            {
                SendClientMessage(playerid, COLOR_RED, "* %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't in team Grove Street Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }
                if(CarCheck == Cars[GroveStreet1]) //check if player is in grovestreet1 car
        {
            if (Group_GetPlayer(gGSF, playerid)) //Check if player is in grove street
            {
                SendClientMessage(playerid, COLOR_RED, "* %s spins a key and tries to start vehicle engine.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_RED, "You aren't in team Grove Street Crips");
                RemovePlayerFromVehicle(playerid);
            }
            return 1;
        }
    }
And it will work
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)