14.09.2013, 15:06
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
Than two easy function to set the team of the class and the vehicle
Now we create our teams and an array for the colors
The publics which set the class and the color
And now OnGameModeInit
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
;
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);
}
pawn Код:
enum Team { // edit to your wish
GROVE_STREET,
POLICE
}
new const
gTeamColors[Team] = { // edit to your wish
0x00820FAA, // GROVE
0x003DF5AA // POLICE
}
;
pawn Код:
//OnPlayerRequestClass
gTeam{playerid} = gTeamClass{classid};
//OnPlayerRequestSpawn
SetPlayerColor(playerid, gTeamColors[gTeam{playerid}]);
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