Team Help
#1

I have this:

pawn Код:
public SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0)
    {
        gTeam[playerid] = TEAM_GROVE;
    }
    else if (classid == 1)
    {
        gTeam[playerid] = TEAM_GROVE;
    }
    else if (classid == 2)
    {
        gTeam[playerid] = TEAM_GROVE;
    }
    else if (classid == 3)
    {
        gTeam[playerid] = TEAM_BALLA;
    }
    else if (classid == 4)
    {
        gTeam[playerid] = TEAM_BALLA;
    }
    else if (classid == 5)
    {
        gTeam[playerid] = TEAM_BALLA;
    }
}
But for some reason every class that I choose is Grove.. I need help.
Reply
#2

pawn Код:
public SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0 || classid == 1 || classid == 2)
    {
        gTeam[playerid] = TEAM_GROVE;
    }
    else if (classid == 3 || classid == 4 || classid == 5)
    {
        gTeam[playerid] = TEAM_BALLA;
    }
    return 1;
}
Try this, it should work.
Reply
#3

pawn Код:
public SetPlayerTeamFromClass(playerid, classid)
{
       switch(classid)
       {
              case 0, 1, 2: gTeam[playerid] = TEAM_GROVE;
              case 3, 4, 5: gTeam[playerid] = TEAM_BALLA;
       }
       return 1;
}
How do you check if a player is in the correct team?
You should build a little command to be sure =D
Reply
#4

Quote:
Originally Posted by Shadow™
Посмотреть сообщение
pawn Код:
public SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0 || classid == 1 || classid == 2)
    {
        gTeam[playerid] = TEAM_GROVE;
    }
    else if (classid == 3 || classid == 4 || classid == 5)
    {
        gTeam[playerid] = TEAM_BALLA;
    }
    return 1;
}
Try this, it should work.
That looks perfect, but the classes that are Ballas are still having green names..
This is what I have for the teams

pawn Код:
#define TEAM_GROVE 0
#define TEAM_BALLA 1
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple

forward SetPlayerTeamFromClass(playerid, classid);
forward SetPlayerToTeamColor(playerid);

new gTeam[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColor(playerid);
    return 1;
}

public SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0 || classid == 1 || classid == 2)
    {
        gTeam[playerid] = TEAM_GROVE;
    }
    else if (classid == 3 || classid == 4 || classid == 5)
    {
        gTeam[playerid] = TEAM_BALLA;
    }
    return 1;
}

public SetPlayerToTeamColor(playerid)
{
    if (gTeam[playerid] == TEAM_GROVE)
    {
        SetPlayerColor(playerid, TEAM_GROVE_COLOR);
    }
    else if (gTeam[playerid] == TEAM_BALLA)
    {
        SetPlayerColor(playerid, TEAM_BALLA_COLOR);
    }
}
Not sure why the Ballas have Green names...
Reply
#5

Looks correct at first view :O
You could check if the colors are correct, or maybe try to use others =D
Reply
#6

Do Like me i thnk is more simple
//team 1
AddPlayerClassEx(1, 284,937.8857, -848.3918, 93.6180, 27.1019, 23, 60, 4, 1, 0, 0);
//team 2
AddPlayerClassEx(2, 284,937.8857, -848.3918, 93.6180, 27.1019, 23, 60, 4, 1, 0, 0);

and with dis set colors and blah blah blah

if(GetPlayerTeam(playerid) == 1)
{
//do something
}
else if(GetPlayerTeam(playerid) == 2)
{
do something
}
Reply
#7

^.^ Here:

pawn Код:
#include <a_samp>

#define TEAM_GROVE 0
#define TEAM_BALLA 1
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple

forward SetPlayerTeamFromClass(playerid, classid);
forward SetPlayerToTeamColor(playerid);

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColor(playerid);
    return 1;
}

public SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0 || classid == 1 || classid == 2)
    {
        SetPVarString(playerid,"Team","GROVE");
    }
    else if (classid == 3 || classid == 4 || classid == 5)
    {
        SetPVarString(playerid,"Team","BALLA");
    }
    return 1;
}

public SetPlayerToTeamColor(playerid)
{
    if (GetPVarString(playerid,"Team","GROVE",128))
    {
        SetPlayerColor(playerid, TEAM_GROVE_COLOR);
    }
    else if (GetPVarString(playerid,"Team","BALLA",128))
    {
        SetPlayerColor(playerid, TEAM_BALLA_COLOR);
    }
    return 1;
}
Also, it should be:

pawn Код:
static gTeam[MAX_PLAYERS];
Not:

pawn Код:
new gTeam[MAX_PLAYERS];
Reply
#8

Quote:
Originally Posted by Shadow™
Посмотреть сообщение
^.^ Here:

pawn Код:
#include <a_samp>

#define TEAM_GROVE 0
#define TEAM_BALLA 1
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple

forward SetPlayerTeamFromClass(playerid, classid);
forward SetPlayerToTeamColor(playerid);

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColor(playerid);
    return 1;
}

public SetPlayerTeamFromClass(playerid, classid)
{
    if (classid == 0 || classid == 1 || classid == 2)
    {
        SetPVarString(playerid,"Team","GROVE");
    }
    else if (classid == 3 || classid == 4 || classid == 5)
    {
        SetPVarString(playerid,"Team","BALLA");
    }
    return 1;
}

public SetPlayerToTeamColor(playerid)
{
    if (GetPVarString(playerid,"Team","GROVE",128))
    {
        SetPlayerColor(playerid, TEAM_GROVE_COLOR);
    }
    else if (GetPVarString(playerid,"Team","BALLA",128))
    {
        SetPlayerColor(playerid, TEAM_BALLA_COLOR);
    }
    return 1;
}
Also, it should be:

pawn Код:
static gTeam[MAX_PLAYERS];
Not:

pawn Код:
new gTeam[MAX_PLAYERS];
That makes every classes color Orange..
Reply
#9

pawn Код:
#define TEAM_GROVE 0
#define TEAM_BALLA 1
#define TEAM_GROVE_COLOR 0x00FF00AA // Bright Green (in RGBA format)
#define TEAM_BALLA_COLOR 0xFF00FFAA // Bright Purple

new gTeam[MAX_PLAYERS];

public OnPlayerSpawn(playerid)
{
    SetPlayerToTeamColor(playerid);
    return 1;
}

stock SetPlayerToTeamColor(playerid)
{
    switch(gTeam[playerid])
    {
        case TEAM_GROVE: SetPlayerColor(playerid, TEAM_GROVE_COLOR);
        case TEAM_BALLA: SetPlayerColor(playerid, TEAM_BALLA_COLOR);
    }
}

public OnPlayerRequestClass(playerid, classid)
{
    switch(classid)
    {
        case 0..2: gTeam[playerid] = TEAM_GROVE;
        case 3..5: gTeam[playerid] = TEAM_BALLA;
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by Shadow™
Посмотреть сообщение
^.^ Here:
pawn Код:
public SetPlayerToTeamColor(playerid)
{
    if (GetPVarString(playerid,"Team","GROVE",128))
    {
        SetPlayerColor(playerid, TEAM_GROVE_COLOR);
    }
    else if (GetPVarString(playerid,"Team","BALLA",128))
    {
        SetPlayerColor(playerid, TEAM_BALLA_COLOR);
    }
    return 1;
}
Will not work. You have to get the team into a string first of all in your example case, but I would definitely not use strings to store the player's team. You define the teams yourself yet you DO NOT USE them! Jesus christ.

And really using the gTeam static variable in this case is better since you'll perhaps have loops for the teams and so on. Do as Jefff is telling you as he's obviously the only one having read the optimization guide!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)