Team cars problem
#5

Thats a pretty bad tutorial (not only the team car part) and it would never work like that

From the start, we create three arrays
pawn Код:
new
    Team: gTeam[MAX_PLAYERS char], // stores the team of the player
    Team: gTeamClass[300 char] = {Team: -1, ...}, // stores the team of the class
    Team: gTeamVehicle[MAX_VEHICLES + 1 char] = {Team: -1, ...} // stores the team of the vehicle
;
Than two easy function to set the team of the class and the vehicle
pawn Код:
SetClassToTeam(Team: teamid, classid) {
    if((0 <= classid < (sizeof gTeamClass * 4)) && (0 <= _: teamid <= 255)) {
        gTeamClass{classid} = teamid;
        return classid;
    }
    return printf("* SetClassToTeam(%d, %d) failed", _: teamid, classid);
}

SetVehicleToTeam(Team: teamid, vehicleid) {
    if((1 <= vehicleid < (sizeof gTeamVehicle * 4)) && (0 <= _: teamid <= 255)) {
        gTeamVehicle{vehicleid} = teamid;
        return vehicleid;
    }
    return printf("* SetVehicleToTeam(%d, %d) failed", _: teamid, vehicleid);
}
Now we create our teams and an array for the colors
pawn Код:
enum Team { // edit to your wish
    GROVE_STREET,
    POLICE
}

new const
   gTeamColors[Team] = { // edit to your wish
        0x00820FAA, // GROVE
        0x003DF5AA // POLICE
    }
;
The publics which set the class and the color
pawn Код:
//OnPlayerRequestClass
    gTeam{playerid} = gTeamClass{classid};

//OnPlayerRequestSpawn
    SetPlayerColor(playerid, gTeamColors[gTeam{playerid}]);
And now OnGameModeInit
pawn Код:
//OnGameModeInit -  edit to your wish
    SetClassToTeam(GROVE_STREET, AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0));
    SetClassToTeam(GROVE_STREET, AddPlayerClass(105,2497.2693,-1676.9578,13.3398,23.6501,0,0,0,0,0,0));

    SetVehicleToTeam(GROVE_STREET, CreateVehicle(492,2484.3054,-1655.0886,13.1036,90.8565,44,16,900)); //Greenwood

    SetClassToTeam(POLICE, AddPlayerClass(280,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0));
    SetClassToTeam(POLICE, AddPlayerClass(280,1544.0514,-1675.7766,13.5577,98.0974,0,0,0,0,0,0));

    SetVehicleToTeam(POLICE, CreateVehicle(596,1536.0603,-1676.5302,13.1054,0.6847,-1,-1,900)); //LSPD Cruiser
Reply


Messages In This Thread
Team cars problem - by bustern - 14.09.2013, 10:46
AW: Team cars problem - by Nero_3D - 14.09.2013, 11:24
Re: Team cars problem - by bustern - 14.09.2013, 13:12
Re: Team cars problem - by bustern - 14.09.2013, 15:04
AW: Team cars problem - by Nero_3D - 14.09.2013, 15:06
Re: Team cars problem - by bustern - 14.09.2013, 15:16
Re: Team cars problem - by bustern - 14.09.2013, 15:56
Re: Team cars problem - by bustern - 15.09.2013, 07:10
Re: Team cars problem - by bustern - 15.09.2013, 11:45
Re: Team cars problem - by bustern - 15.09.2013, 12:51

Forum Jump:


Users browsing this thread: 4 Guest(s)