Some noob questions. :)
#1

Код:
SetPlayerTeamFromClass(playerid, classid)
{
	if (classid == 105)
	{
		gTeam[playerid] = TeamGrovest;
This sets class 105 as a member of TeamGrovest. But there are 3 availible classes that all need to be in TeamGrovest. Instead of making three "if's" can i just make one "if" like this?

Код:
SetPlayerTeamFromClass(playerid, classid)
{
	if (classid == 105,106,107)
	{
		gTeam[playerid] = TeamGrovest;
Can i just seperate the three classes by commas? (105,106,107)? Or do they need to all have seperate IF statements?

Reply
#2

If you're gonna use "if" you'll need to do it like this:
pawn Код:
if(classid == 105 || classid == 106 || classid == 107)
But wait, there's an easier way!
pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
  switch(classid)
  {
    case 105, 106, 107:
    {
     // code
    }
    case 108:
    {
      // code for if(classid == 108)
    }
    case 109 .. 120: // this mean from 109 to 120 (if (classid == 109 || classif == 110...)
    {
      // code
    }
    default: // this is "else"
    {
      // code
    }
  }
  return 1;
}
I'd do it like:

pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
  switch(classid)
  {
    case 105 .. 107: gTeam[playerid] = TeamGrovest;
  }
  return 1;
}
Reply
#3

Ok, thanks SAWC.

Another noob question. I want each gang (Grove, Balla, Triad, Vagos) to have their own gang color. (Both blips AND name in chat screen).

I have it like this..

Код:
#define TeamGrovest 1
#define TeamBallas 2
#define TeamVagos 3
#define TeamTriads 4
#define TeamGrovestColor 0x339900AA
#define TeamBallasColor 0xAF00FFAA
#define TeamVagosColor 0xBF00FFAA
#define TeamTriadsColor 0xCF00FFAA   //these are just random colors for testing. I'll change them later.
Then, down some..
Код:
SetPlayerTeamFromClass(playerid, classid)
{
	{
  	if(classid == 105 || classid == 106 || classid == 107)

			gTeam[playerid] = TeamGrovest;
	}
	{
  	if(classid == 102 || classid == 103 || classid == 104)

			gTeam[playerid] = TeamBallas;
	}
	{
  	if(classid == 108 || classid == 109 || classid == 110)

			gTeam[playerid] = TeamVagos;
	}
	{
  	if(classid == 117 || classid == 118 || classid == 120)

			gTeam[playerid] = TeamTriads;
	}
}

SetPlayerToTeamColor(playerid)
{
	if (gTeam[playerid] == TeamGrovest)
	{
		SetPlayerColor(playerid, TeamGrovestColor);
	}
	else if (gTeam[playerid] == TeamBallas)
	{
		SetPlayerColor(playerid, TeamBallasColor);
	}
	else if (gTeam[playerid] == TeamVagos)
	{
		SetPlayerColor(playerid, TeamVagosColor);
	}
	else if (gTeam[playerid] == TeamTriads)
	{
		SetPlayerColor(playerid, TeamTriadsColor);
	}
}



And, under OnPlayerSpawn, i run my function. I cant see why it wouldnt work..
Reply
#4

just a bump.. gotta fix this issue.
Reply
#5

Change this:
Код:
#define TeamGrovestColor 0x339900AA
#define TeamBallasColor 0xAF00FFAA
#define TeamVagosColor 0xBF00FFAA
#define TeamTriadsColor 0xCF00FFAA
To this:

Код:
#define TeamGrovestColor 0x33990099
#define TeamBallasColor 0xAF00FF99
#define TeamVagosColor 0xBF00FF99
#define TeamTriadsColor 0xCF00FF99
I am not sure if it works, but I use the same function, this is the only thing which is different.
Reply
#6

Thanks but it didnt work =( All the colors are orange. No matter what team i choose.
Reply
#7

I am not sure if this works, but I have read this somewhere, add 'return 1;', so it'll be like this:

Код:
SetPlayerToTeamColor(playerid)
{
	if (gTeam[playerid] == TeamGrovest)
	{
		SetPlayerColor(playerid, TeamGrovestColor);
	}
	else if (gTeam[playerid] == TeamBallas)
	{
		SetPlayerColor(playerid, TeamBallasColor);
	}
	else if (gTeam[playerid] == TeamVagos)
	{
		SetPlayerColor(playerid, TeamVagosColor);
	}
	else if (gTeam[playerid] == TeamTriads)
	{
		SetPlayerColor(playerid, TeamTriadsColor);
	}
return 1;
}
Reply
#8

Sigh.. That didnt work either. :/
Ive seen this in virtually EVERY server, so dont act like there isnt a way. Can someone experienced please help me? Im sure its something simple.

No matter what gang i choose, my color is orange.
Reply
#9

bump, again. Can i get some expert feedback here? Seems like a simple problem.
Reply
#10

Bump again. I've tried re-arranging my code, thinking maybe if one function was above another it may work. But it doesnt. My name is still orange. Supposed to be green. Seems like an easy fix. Can someone please take the time to help me?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)