[Tutorial] [TUT] Teams - Setting up teams - Team restricted vehicles - Team Restricted base
#21

Quote:
Originally Posted by Ritchie999
Quote:
Originally Posted by retart441
What do you want to learn with Roleplay style teams?
i need it so you dont pick the team, either you spawn off and your instantly in the gang team like grove street or else you go to the police station if your a cop and go on duty
Code:
 	if(strcmp(cmd, "/acceptjob fireman", true) == 0)
	{
		if(gTeam[playerid] == TEAM_CIVILIAN)
		}
			SetPlayerHealth(playerid, 0);
			gTeam[playerid] = TEAM_FIREMAN;
			SetPlayerPos(playerid, Fireman spawnS);
			SetPlayerColor(playerid, Fireman color);
		else
		{
			SendClientMessage(playerid, COLOR_RED, "You already have a job.");
			return 0;
		}
<--- Idk that is just a example.
Reply
#22

Quote:
Originally Posted by retart441
Quote:
Originally Posted by [LCG
TANKER ]
very nice, just having a tiny issue with it, just been futzing around with it and i seam to have broke something xD


its a warning but ya...

pawn Code:
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerTeamFromClass(playerid, classid)
    {
    if(classid == 0)
    {
    gTeam[playerid] = TEAM_ARMY;
    return 1;
    }
    else if(classid == 1)
    {
    gTeam[playerid] = TEAM_REBAL;
    return 1;
    }

    public OnPlayerRequestClass(playerid, classid)
    {
    if(classid == 0)
    {
    SendClientMessage(playerid, COLOR_GREEN, "ARMY!");
    }
    else if(classid == 1)
    {
    SendClientMessage(playerid, COLOR_BLUE, "REBAL!");
    }
    return 1;
}
Try that. Sorry for the indentation errors.

And to make people spawn as a cop or a gang member, you want them to choose a skin or it to be random??

I assign the skins, for police i use skins 280 to 286
and for the gangs i use all the gang skins.

so basically, the leader of the gang invites people, and when they quit and re-join they are still in the gang but they have to be invited into the faction to join it
Reply
#23

Quote:
Originally Posted by Ritchie999

I assign the skins, for police i use skins 280 to 286
and for the gangs i use all the gang skins.

so basically, the leader of the gang invites people, and when they quit and re-join they are still in the gang but they have to be invited into the faction to join it
Alright so you want it to save what faction there in after the leader invites them.

So first your gonna need a Saving system, if you already have on and understand it well then skip this step.

http://forum.sa-mp.com/index.php?topic=126584.0
Very simple tutorial to make a dini saving system.

After you set up your players save files, it's time we add the variables for players stats.

under the enum pInfo.

pawn Code:
enum pInfo
{
/* The stuff in the tutorial */,
pTeam,
pLeader,
}
Under the /register command look for were it is creating the file.
For dini look for dini_IntSet(file, "name", somthing);
add the two saves for Team, and Leader.

After you do that, under the /login command, create the function that will load the Team save, and Leader Save, and set it to pTeam, and pLeader.
pawn Code:
gTeam = dini_Set(file, "Team")
And example.

pawn Code:
if(strcmp(cmd, "/invite", true) == 0)
    {
      if(PlayerInfo[playerid][Leader] == 1)
      {
        if(gTeam[playerid] == 1)
            {
              if(!strlen(cmd[7])) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /invite [playerid]");
              new otherplayerid = strval(cmdtext[9]);
              if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "That player isnt connected");
              if(otherplayerid == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You cannot invite yourself!!");
              new gstring[128], string2[128];
              new adminname[MAX_PLAYER_NAME], otherguysname[MAX_PLAYER_NAME];
              GetPlayerName(playerid,adminname,sizeof(adminname));
              GetPlayerName(otherplayerid,otherguysname,sizeof(otherguysname));
              format(gstring,sizeof(gstring),"** You have invited %s", otherguysname);
              format(string2,sizeof(string2),"** You were invited to join a faction by %s", adminname);
              SendClientMessage(playerid, 0x00E100FF, gstring);
              SendClientMessage(otherplayerid, 0x00E100FF, string2);
              gTeam[otherplayerid] = 1;
              SetPlayerHealth(otherplayerid, 0.00 );
              return 1;
            }
        return 1;
        }
        if(PlayerInfo[playerid][Leader] == 1)
      {
        if(gTeam[playerid] == 2)
            {
              if(!strlen(cmd[7])) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /invite [playerid]");
              new otherplayerid = strval(cmdtext[9]);
              if(!IsPlayerConnected(otherplayerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "That player isnt connected");
              if(otherplayerid == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You cannot invite yourself!!");
              new gstring[128], string2[128];
              new adminname[MAX_PLAYER_NAME], otherguysname[MAX_PLAYER_NAME];
              GetPlayerName(playerid,adminname,sizeof(adminname));
              GetPlayerName(otherplayerid,otherguysname,sizeof(otherguysname));
              format(gstring,sizeof(gstring),"** You have invited %s", otherguysname);
              format(string2,sizeof(string2),"** You were invited to join a faction by %s", adminname);
              SendClientMessage(playerid, 0x00E100FF, gstring);
              SendClientMessage(otherplayerid, 0x00E100FF, string2);
              gTeam[otherplayerid] = 2;
              SetPlayerHealth(otherplayerid, 0.00 );
              return 1;
            }
        return 1;
        }
      else
      {
        SendClientMessage(playerid, COLOR_RED, "Only Leaders can Invite.");
        return 1;
        }
    }
An example of my /invite command.
The pLeader is there to make sure the leader is the only one who can invite.

You can do even more, such as pick skins, and respawn the player.
Reply
#24

Where did you put this ?
Code:
 enum TeamCars
{
t11
t12
t13
t14
t21
t22
t23
t24
}
new Cars[TeamCars];
Reply
#25

Quote:
Originally Posted by Alex_Cop
Where did you put this ?
Code:
 enum TeamCars
{
t11
t12
t13
t14
t21
t22
t23
t24
}
new Cars[TeamCars];
Put it near the top of the script.
Reply
#26

im getting a problem...

i create gTeam variable [check]
i define tems and colors above main [check]

above my OnPlayerRequestClass i have created the new SetPlayerTeamFromClass and SetPlayerToTeamColor functions [check]

put SetPlayerTeamFromClass in my OnPlayerRequestClass Callback [check]

put SetPlayerToTeamColor in my OnPlayerSpawn Callback [check]

but no matter how much i try the team colors dont work everybody is the same color usually the 1st color to be set (green)

can anyone help me please i would appreciate your help alot thx
Reply
#27

Nice Tutorial!
Reply
#28

8/10 Great tutorial. One problem i have is making the spawns show their actual location. not just showing the one set of digits you put in setcamerapos and all of that. So if someone could help me please do.

P.S: The classes dont show when i use the x,y,z floats, when i am trying to show the player's class in their actual location where i spawned them.
Reply
#29

For some reason, I'm getting the following errors:

Code:
C:\Users\Gorka\Desktop\SAMPscripting\gamemodes\MyFirstGM.pwn(43) : error 001: expected token: "}", but found "-identifier-"
C:\Users\Gorka\Desktop\SAMPscripting\gamemodes\MyFirstGM.pwn(88) : error 017: undefined symbol "SetPlayerTeamFromClass"
C:\Users\Gorka\Desktop\SAMPscripting\gamemodes\MyFirstGM.pwn(101) : error 017: undefined symbol "SetPlayerToTeamColor"
C:\Users\Gorka\Desktop\SAMPscripting\gamemodes\MyFirstGM.pwn(140) : warning 217: loose indentation
C:\Users\Gorka\Desktop\SAMPscripting\gamemodes\MyFirstGM.pwn(142) : warning 217: loose indentation
I've checked everything like 5 times and I still can't get what's causing those errors.

Here's my code:

pawn Code:
/*===========================================================
=============================================================
=======          Oh My DeathMatch!  OMDM            =========
=======          Developer: whosHate aka TehHate    =========
=======          Game Mode: Team DeathMatch         =========
=======          Version:   v0.1                    =========
=============================================================
===========================================================*/


/*===========================================================
===== Enjoy this crap and leave credits if you edit ^^ ======
===========================================================*/


/*===========================================================
                          Changelog
                - v0.1: First version of OMDM
===========================================================*/


#include <a_samp>
//======= Color Defines ===========
#define COLOR_WHITE     0xFFFFFFAA
#define COLOR_RED       0xFF0000AA
#define COLOR_GREEN     0x00FF00AA
#define COLOR_BLUE      0x0000FFAA
#define COLOR_GRAY      0xAFAFAFAA
#define COLOR_YELLOW    0xFFFF00AA
#define COLOR_LIGHTBLUE 0x0AFFFFAA
#define COLOR_PURPLE    0xFF00FFAA
#define COLOR_ORANGE    0xFFBB00AA
//=================================

//====== Team Defines =============
#define TEAM_GROVE      0
#define TEAM_LSPD       1
#define TEAM_BALLAS     2
#define TEAM_FBI        3
//=================================

//============ ENUMS ==============
enum TeamCars
{
t11
t12
t13
t14
t21
t22
t23
t24
}
//==================================

//========== Variables =============
new gTeam[MAX_PLAYERS];
new Cars[TeamCars];
//==================================


main()
{
    print("||========Oh My Deathmatch!=======||");
    print("||OMDM Team Deathmatch by whosHate||");
    print("||=============v0.1===============||");
}


public OnGameModeInit()
{
    SetGameModeText("OMDM v0.1");
    //============================= PLAYER CLASSES =========================================
    AddPlayerClass(106,-183.5194,1090.8673,19.7422,52.6484,22,120,28,120,30,120); // Grove
    AddPlayerClass(102,1607.0870,1815.6981,10.8203,193.8336,22,120,28,120,30,120); // Ballas
    //======================================================================================
    //=============================== VEHICLES ==================================
    Cars[t11] = CreateVehicle(463,-168.0218,1079.2097,19.2757,359.2158,0,0,120);
    //===========================================================================
    return 1;
}


public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    {
        if(classid == 0)
        {
        gTeam[playerid] = TEAM_GROVE;
        return 1;
    }
        else if(classid == 1)
        {
        gTeam[playerid] = TEAM_BALLAS;
        return 1;
        }
    }
    SetPlayerToTeamColor(playerid)
    {
        if (gTeam[playerid] == TEAM_GROVE)
        {
            SetPlayerColor(playerid, COLOR_GREEN);
        }
        else if (gTeam[playerid] == TEAM_BALLAS)
        {
            SetPlayerColor(playerid, COLOR_PURPLE);
        }
    }
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerConnect(playerid)
{
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_GROVE)
    {
        SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid, 1090.8673, 19.7422, 52.6484);
        return 1;
    }
    else if(gTeam[playerid] == TEAM_BALLAS)
    {
        SetPlayerInterior(playerid, 0);
        SetPlayerPos(playerid, 1815.6981, 10.8203, 193.8336);
    return 1;
    }
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/help", cmdtext, true, 4) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}

public OnVehicleSpawn(vehicleid)
{
    return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
    return 1;
}

public OnPlayerText(playerid, text[])
{
    return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
    return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
    return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
    return 1;
}

public OnRconCommand(cmd[])
{
    return 1;
}

public OnPlayerRequestSpawn(playerid)
{
    return 1;
}

public OnObjectMoved(objectid)
{
    return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
    return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
    return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
    return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
    return 1;
}

public OnPlayerExitedMenu(playerid)
{
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
    return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
    return 1;
}

public OnPlayerUpdate(playerid)
{
    return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
    return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
    return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
    return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
    return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    return 1;
}
I'm stuck in the 5th step... Can anyone help me?

Thanks

PS: I know this is my first post, but I haven't make this account only for this, the problem is that I lost my other account D:
Reply
#30

How can I set a default team(civillains team_civillian). First time someone logs in he is team civillian.
Reply
#31

Very good tutorial, i learned much.
Reply
#32

I recommend using SetPlayerTeam and GetPlayerTeam functions. Simple and easy.
Reply
#33

write to me in skype ioan_5 please
Reply
#34

Mine got stuck in a pwn(459) : error 017: undefined symbol "gTeam" so can someone help out? I wanna make 6 teams so there's something missing:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#define DropMoney 30000
#include <YSI\y_ini> //If you have installed YSI, then you shouldn't have any problem
native WP_Hash(buffer[],len,const str[]); // Whirlpool native, add it at the top of your script under includes
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PATH "/Players/%s.ini" //Will define user's account path. In this case, we will save it in Scriptfiles/Users. So create a file inside of your Scriptfiles folder called Users
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
#if defined FILTERSCRIPT
#define TEAM_SOKABOYZ 0
#define TEAM_LOKOS 1
#define TEAM_PIMPS 2
#define TEAM_MICES 3
#define TEAM_POTATOHEADZ 4
#define TEAM_AVENGERS 5
#define COLOR_GREEN 0x008000FF
#define COLOR_BLUE 0x0000FFFF

SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
gTeam[playerid] = TEAM_SOKABOYZ;
return 1;
}
else if(classid == 1)
{
gTeam[playerid] = TEAM_LOKOS;
}
else if(classid == 2)
{
gTeam[playerid] = TEAM_PIMPS;
}
else if(classid == 3)
{
gTeam[playerid] = TEAM_MICES;
}
else if(classid == 4)
{
gTeam[playerid] = TEAM_POTATOHEADZ;
}
else if(classid == 5)
{
gTeam[playerid] = TEAM_AVENGERS;
return 1;
}

public OnPlayerSpawn(playerid)
{
GivePlayerMoney(playerid, DropMoney);
{
if(gTeam[playerid] == TEAM_SOKABOYZ)
{
SetPlayerInterior(playerid, 0-13);
SetPlayerPos(playerid, -1818.3712,-1612.8964,23.0156);
return 1;
}
else if(gTeam[playerid] == TEAM_LOKOS)
{
SetPlayerInterior(playerid, 43-52);
SetPlayerPos(playerid, -1527.3290,-289.5187,6.0000);
}
else if(gTeam[playerid] == TEAM_PIMPS)
{
SetPlayerInterior(playerid, 87-101);
SetPlayerPos(playerid, -2654.8364,1373.4486,7.1003);
}
else if(gTeam[playerid] == TEAM_MICES)
{
SetPlayerInterior(playerid, 137-150);
SetPlayerPos(playerid, 297.6018,1839.6121,7.8281);
}
else if(gTeam[playerid] == TEAM_POTATOHEADZ)
{
SetPlayerInterior(playerid, 188-20;
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
}
else if(gTeam[playerid] == TEAM_AVENGERS)
{
SetPlayerInterior(playerid, 265-277);
SetPlayerPos(playerid, 1962.3696,-2188.4583,13.5469);
return 1;
}
return 1;
}
Reply
#35

Quote:
Originally Posted by ciberblue
View Post
Mine got stuck in a pwn(459) : error 017: undefined symbol "gTeam" so can someone help out? I wanna make 6 teams so there's something missing:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#define DropMoney 30000
#include <YSI\y_ini> //If you have installed YSI, then you shouldn't have any problem
native WP_Hash(buffer[],len,const str[]); // Whirlpool native, add it at the top of your script under includes
#define DIALOG_REGISTER 1
#define DIALOG_LOGIN 2
#define DIALOG_SUCCESS_1 3
#define DIALOG_SUCCESS_2 4
#define PATH "/Players/%s.ini" //Will define user's account path. In this case, we will save it in Scriptfiles/Users. So create a file inside of your Scriptfiles folder called Users
#define COL_WHITE "{FFFFFF}"
#define COL_RED "{F81414}"
#define COL_GREEN "{00FF22}"
#define COL_LIGHTBLUE "{00CED1}"
#if defined FILTERSCRIPT
#define TEAM_SOKABOYZ 0
#define TEAM_LOKOS 1
#define TEAM_PIMPS 2
#define TEAM_MICES 3
#define TEAM_POTATOHEADZ 4
#define TEAM_AVENGERS 5
#define COLOR_GREEN 0x008000FF
#define COLOR_BLUE 0x0000FFFF

SetPlayerTeamFromClass(playerid, classid)
{
if(classid == 0)
{
gTeam[playerid] = TEAM_SOKABOYZ;
return 1;
}
else if(classid == 1)
{
gTeam[playerid] = TEAM_LOKOS;
}
else if(classid == 2)
{
gTeam[playerid] = TEAM_PIMPS;
}
else if(classid == 3)
{
gTeam[playerid] = TEAM_MICES;
}
else if(classid == 4)
{
gTeam[playerid] = TEAM_POTATOHEADZ;
}
else if(classid == 5)
{
gTeam[playerid] = TEAM_AVENGERS;
return 1;
}

public OnPlayerSpawn(playerid)
{
GivePlayerMoney(playerid, DropMoney);
{
if(gTeam[playerid] == TEAM_SOKABOYZ)
{
SetPlayerInterior(playerid, 0-13);
SetPlayerPos(playerid, -1818.3712,-1612.8964,23.0156);
return 1;
}
else if(gTeam[playerid] == TEAM_LOKOS)
{
SetPlayerInterior(playerid, 43-52);
SetPlayerPos(playerid, -1527.3290,-289.5187,6.0000);
}
else if(gTeam[playerid] == TEAM_PIMPS)
{
SetPlayerInterior(playerid, 87-101);
SetPlayerPos(playerid, -2654.8364,1373.4486,7.1003);
}
else if(gTeam[playerid] == TEAM_MICES)
{
SetPlayerInterior(playerid, 137-150);
SetPlayerPos(playerid, 297.6018,1839.6121,7.8281);
}
else if(gTeam[playerid] == TEAM_POTATOHEADZ)
{
SetPlayerInterior(playerid, 188-20;
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
}
else if(gTeam[playerid] == TEAM_AVENGERS)
{
SetPlayerInterior(playerid, 265-277);
SetPlayerPos(playerid, 1962.3696,-2188.4583,13.5469);
return 1;
}
return 1;
}
Check out my singtrue
Reply
#36

Hi, I am having a problem.
Where to put that SetPlayerTeamfromClass
Reply
#37

Very well explained tut.Really liked it,will help newbies scripters alot.
Reply
#38

Can you help me with RP Factions?
Reply
#39

Quote:

gTeam[playerid] = /* Your Save file for team */

What do I need to type if I have the folder called Users in filterscripts to save.
Reply
#40

Very Nice tut
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)