Teams and teams vehicles, need help.
#4

First I removed all unused callbacks like that
pawn Код:
#include <a_samp>

#define POLICE 1
#define EMS 2
#define POLICE_COLOR 0x1B4CE0AA
#define EMS_COLOR 0xFF8AF5AA
#define COLOR_RED 0xFF0000AA

new Cars[TeamCars];
enum TeamCars
{
Police,
Ems
}

new gTeam[MAX_PLAYERS];

main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    AddPlayerClass(282,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0); //POLICE
    AddPlayerClass(275,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0); //EMS
    Cars[Police] = AddStaticVehicle(598,-210.8453,999.8466,19.3565,88.9803,0,1); // FCpolice1
    Cars[Ems] = AddStaticVehicle(416,-330.7315,1063.7899,19.8899,270.1239,1,3); // FCems1
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    return 1;
}

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

SetPlayerTeamFromClass(playerid, classid)
{
    if(classid == 0)
    {
        gTeam[playerid] = POLICE;
    }
    if(classid == 1)
        gTeam[playerid] = EMS;
    }
}

SetPlayerToTeamColour(playerid)
{
    if(gTeam[playerid] == POLICE)
    {
        SetPlayerColor(playerid,POLICE_COLOR); //BLUE
    }
    if(gTeam[playerid] == EMS)
        SetPlayerColor(playerid,EMS_COLOR); // PINK
    }
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        if(CarCheck == Cars[Police] )
        {
            if(gTeam[playerid] != 1)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
                return 1;
            }
        }
        if(CarCheck == Cars[Ems] )
        {
            if(gTeam[playerid] != 2)
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, COLOR_RED, "You don't belong to the correct faction.");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Through that you get rid of the the error 021: symbol already defined: "OnPlayerStateChange" because you got that public twice in your code

Than I just moved the enum TeamCars over the Cars array, that will solve all other errors and will only leave the two error 054
pawn Код:
enum TeamCars
{
Police,
Ems
}
new Cars[TeamCars];
These are caused in SetPlayerToTeamColour and SetPlayerTeamFromClass trough the missing opening bracket at the second if statement
pawn Код:
//SetPlayerTeamFromClass
if(classid == 1) // missing {
    gTeam[playerid] = EMS;
}
//SetPlayerTeamFromClass
if(gTeam[playerid] == EMS) // missing {
    SetPlayerColor(playerid,EMS_COLOR); // PINK
}
That wont result in the code I posted above but will fix your errors and warnings
I just rewrote some things to make it more effective and easier to use but its not beginner friendly
Reply


Messages In This Thread
Teams and teams vehicles, need help. - by needhack - 23.02.2013, 14:11
AW: Teams and teams vehicles, need help. - by Nero_3D - 23.02.2013, 14:43
Re: Teams and teams vehicles, need help. - by needhack - 23.02.2013, 14:47
AW: Teams and teams vehicles, need help. - by Nero_3D - 23.02.2013, 15:08
Re: Teams and teams vehicles, need help. - by needhack - 23.02.2013, 15:16
Re: Teams and teams vehicles, need help. - by needhack - 23.02.2013, 16:01

Forum Jump:


Users browsing this thread: 1 Guest(s)