gTeam (+REP)
#1

Hi guys, I am trying to convert a script of gangwars. My old one didn't use gTeam, but I have worked on gTeam today, and it isn't going well.

The compiler isn't giving any errors, but when I go in game and spawn, my color isn't set, and I highly doubt my team is either.

I tried the color at class selection [http://i.imgur.com/Z53UH.png]
Then when I spawn, my color doesn't change. [http://i.imgur.com/uXgE6.png]

Код:
#include <a_samp>

//Gang Colors
#define COLOR_HOBO 0x393939C8
#define COLOR_GROVE 0x1F7B04C8
#define COLOR_BALLAS 0x890398C8
#define COLOR_VAGOS 0xE1F20DC8
#define COLOR_AZTECAS 0x00FFFFC8
#define COLOR_COPS 0x0080FFC8
#define COLOR_MAFIA 0x183298C8
#define COLOR_MEDICS 0xFF0080C8

//Gangs
new gTeam [MAX_PLAYERS];

#define hobos 1
#define grove 2
#define ballas 3
#define vagos 4
#define aztecas 5
#define cops 6
#define mafia 7
#define medics 8

forward SetPlayerToTeamColour(playerid);
forward SetPlayerTeamFromClass(playerid,classid);
//-----------------------------------------------------------

//-----------------------------------------------------------
public SetPlayerTeamFromClass(playerid, classid)
{
	if(classid == 0 || classid == 1)
 	{
  		gTeam[playerid] = hobos; //this
  	}
   	else if(classid == 2 || classid == 3)
   	{
    	gTeam[playerid] = grove; //this
    }
    else if(classid == 4 || classid == 5)
    {
    	gTeam[playerid] = ballas;
    }
    else if(classid == 6 || classid == 7)
    {
    	gTeam[playerid] = vagos;
    }
    else if(classid == 8 || classid == 9)
    {
    	gTeam[playerid] = aztecas;
    }
    else if(classid == 10 || classid == 11)
    {
    	gTeam[playerid] = cops;
    }
    else if(classid == 12 || classid == 13)
    {
    	gTeam[playerid] = mafia;
    }
    else if(classid == 14 || classid == 15)
    {
    	gTeam[playerid] = medics;
    }
}

public SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == hobos)
    {
        SetPlayerColor(playerid, COLOR_HOBO);
    }
    else if(gTeam[playerid] == grove)
    {
        SetPlayerColor(playerid, COLOR_GROVE);
    }
    else if(gTeam[playerid] == ballas)
    {
        SetPlayerColor(playerid, COLOR_BALLAS);
    }
    else if(gTeam[playerid] == vagos)
    {
        SetPlayerColor(playerid, COLOR_VAGOS);
    }
    else if(gTeam[playerid] == aztecas)
    {
        SetPlayerColor(playerid, COLOR_AZTECAS);
    }
    else if(gTeam[playerid] == cops)
    {
        SetPlayerColor(playerid, COLOR_COPS);
    }
    else if(gTeam[playerid] == mafia)
    {
        SetPlayerColor(playerid, COLOR_MAFIA);
    }
    else if(gTeam[playerid] == medics)
    {
        SetPlayerColor(playerid, COLOR_MEDICS);
    }
}
public OnGameModeInit()
{
    //Anims
    UsePlayerPedAnims();
    //GameModeText and Worldtime
	SetGameModeText("Gangwars/DM");
	SetWorldTime(7);
	//Classes
	//Team Hobo
    AddPlayerClass(137,1973.4954,-1560.3402,13.6389,224.7649,24,100,25,100,4,1); // skin 1 pos
    AddPlayerClass(230,1958.7997,-1561.2727,13.5960,222.2816,24,100,31,250,8,1); // skin 2 pos
    //Team Grove
    AddPlayerClass(106,2523.0234,-1658.9280,15.4935,88.0275,4,1,25,75,31,200); // grove skin 1 pos
    AddPlayerClass(107,2512.9238,-1650.7551,14.0938,135.6546,9,1,24,90,32,250); // grove skin 2 spawn pos
    //Team Balla
    AddPlayerClass(102,1909.8513,-1115.7181,25.6641,178.5448,4,1,25,70,31,200); // balla spawn pos skin 1 102
    AddPlayerClass(104,1939.1782,-1117.4927,26.4455,178.7132,2,1,27,100,23,75); // balla spawn pos skin 2 104
    //Team Vagos
    AddPlayerClass(110,2624.0303,-1202.7760,61.0703,268.6752,5,1,24,100,25,80); // vagos 1 positiion skin 110
    AddPlayerClass(109,2626.9021,-1202.0135,62.5425,179.3977,2,1,25,100,29,200); // vagos 2 position skin 109
    //Team Aztecas
    AddPlayerClass(115,1667.4141,-2108.7278,13.7296,182.4924,8,1,24,125,29,200); // azteca spawn position 115
    AddPlayerClass(116,1674.8219,-2121.9463,13.9760,314.7127,4,1,26,85,23,75); // skin 116 azteca
    //Team Cops
    AddPlayerClass(284,1549.3387,-1680.1816,13.5568,91.5889,3,1,24,75,30,200); // cop skin 1 284
    AddPlayerClass(280,1547.3654,-1671.3651,13.5684,88.2312,4,1,24,90,27,100); // cop skin 2 280
    //Team Mafia
    AddPlayerClass(124,812.3387,-1100.6776,25.7861,269.7575,24,90,33,70,25,100); // mafia skin 1 124
    AddPlayerClass(125,810.9052,-1093.8740,25.7844,181.6866,9,1,24,90,31,300); // mafia skin 2 125
    //Team Medics
    AddPlayerClass(193,1180.8661,-1324.2241,13.5864,274.7145,24,90,27,100,34,75); // medic skin 193
    AddPlayerClass(274,1173.4956,-1322.9530,15.1953,268.1345,9,1,28,250,25,90); // skin 274 medic skin 2
Have I done anything wrong? If someone can help me, then I will give rep.#

Thanks ^^
Reply
#2

You're using a really old system. Preferably, we got new systems and we can do it ANOTHER way these days.

Take an example from my GW:
pawn Код:
#define Groves 0
#define Ballas 1
#define Vagos  2
#define Aztecas 3

#define GrovesColor GREEN
#define BallasColor PURPLE
#define VagosColor  YELLOW
#define AztecasColor CYAN

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{ ///////// rest of my code is up //////////// 
    if(classid == 0)
    {
        GameTextForPlayer(playerid,"Grove Street Families",1000, 1);
        SetPlayerTeam(playerid, Groves);
        SetPlayerPos(playerid, 2450.0981,-1661.2932,27.2448);
        SetPlayerCameraPos(playerid, 2442.6885,-1660.7346,27.4131);
        SetPlayerCameraLookAt(playerid,  2450.0981,-1661.2932,27.2448);
    }
//// I don't use gTeam, Instead I simply use SetPlayerTeam! /////

Now when the players team is already decided, all you gotta do is under OnPlayerSpawn


pawn Код:
if(GetPlayerTeam(playerid) == Groves) /// If the player team is groves or if the case is groves:
    {
        SetPlayerRandomGroveSpawn(playerid); // Setting the random spawn (CUSTOM SCRIPT)
        SetPlayerColor(playerid, GrovesColor); /// Setting the color ///
    }

Once the team is decided, You can do whatever you want OnPlayerSpawn. You're making your code a lot more complicated than it is.
Reply
#3

I understand the concept, if I still encounter any more problems, I will bump this in a few days, but yeah, thanks for your help

+REP Sir Gangs_Rocks
Reply
#4

Np. You can pm me anytime and I'll try to help ASAP.
Reply
#5

I recommend y_classes with y_groups. It's great. Though a bit complicated for beginners.
Reply
#6

So the server is going pretty well but when it comes to creating a team kill detector, it creates a problem, anyone mind telling me how to detect teamkilling in this case?

Thanks, I will +REP to someone who gives a valid answer.

Код:
//under OnPlayerDeath
		if GetPlayerTeam(playerid) == GetPlayerTeam(killerid) *then
		{
		ResetPlayerWeapons(killerid);
		SendClientMessage(killerid, COLOR_NEWS, "Your weapons have been taken away due to teamkilling.");
		}
		}
 	    return 1;
}
It returns this error:
Код:
(1018) : error 010: invalid function or declaration
Reply
#7

Quote:
Originally Posted by Barrack
Посмотреть сообщение
So the server is going pretty well but when it comes to creating a team kill detector, it creates a problem, anyone mind telling me how to detect teamkilling in this case?

Thanks, I will +REP to someone who gives a valid answer.

Код:
//under OnPlayerDeath
		if GetPlayerTeam(playerid) == GetPlayerTeam(killerid) *then
		{
		ResetPlayerWeapons(killerid);
		SendClientMessage(killerid, COLOR_NEWS, "Your weapons have been taken away due to teamkilling.");
		}
		}
 	    return 1;
}
It returns this error:
Код:
(1018) : error 010: invalid function or declaration
Which line?
Reply
#8

The one which says return 1, so its asking me to remove it, so I did, and I tested it, it didnt work, so I reverted back to my old version.

Is there any other way to do this?
Reply
#9

If you are using SetPlayerTeam to set teams, team members can't hurt themselves. You don't need to add anything.
Reply
#10

Oh, thanks.
(+REP)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)