oh, i should have named them "TeamFileName" maybe? its simply a string, stored in an array. the team you are using is a variable, turned to a pointer, pointing to the filename array. so if you use that function for team 9, then the 10th element of the array wil get used as filename, f.ex:
Код:
new TeamFileName[][]=
{
"team_0_none",
"team_1",
"team_2",
// and so on...
"team_9_Ballas" //lets assume the player is in team 9
};
you can use that string as filename by formatting it with
Код:
format(FileName,sizeof(Filename),"Server/%s",TeamFileName[GetPlayerTeam(playerid)]);
..so it will turn into:
Код:
format(FileName,sizeof(Filename),"Server/%s",TeamFileName[9]);
and further:
Код:
format(FileName,sizeof(Filename),"Server/%s","team_9_Ballas");
final result:
Код:
format(FileName,sizeof(Filename),"Server/team_9_Ballas");
..quite faster than using loops, which would look like that ugly piece of spaghetticode:
Код:
new Team=GetPlayerTeam(playerid);
if(Team==1)
{
SetPlayerTeam(playerid,dini_Int("Server/team_1_Grove"));
}
else if(Team==2)
{
SetPlayerTeam(playerid,dini_Int("Server/team_2_Ballas"));
}
else if(Team==3)
{
SetPlayerTeam(playerid,dini_Int("Server/team_1_always"));
}
else if(Team==4)
{
SetPlayerTeam(playerid,dini_Int("Server/team_1_try"));
}
else if(Team==5)
{
SetPlayerTeam(playerid,dini_Int("Server/team_1_to"));
}
else if(Team==6)
{
SetPlayerTeam(playerid,dini_Int("Server/team_1_trade"));
}
else if(Team==7)
{
SetPlayerTeam(playerid,dini_Int("Server/team_1_RAM"));
}
else if(Team==8)
{
SetPlayerTeam(playerid,dini_Int("Server/team_1_for"));
}
else if(Team==9)
{
SetPlayerTeam(playerid,dini_Int("Server/team_1_speed"));
}
i know, an array is wasting RAM, but we arent in the 80's anymore, so a few KBytes wont make the server run out of memory
btw: the arrayed method runs in linear time, so it wont matter if you are using just 2 or 500 teams.
despite that the "loop-method" for handling 500 teams would use some memory, too, plus: it would need to run thru 499 teams to get the resulting filename for team 499.
in short:
the array TeamFileName[499] will give you the proper filename ("Team_499_Cops") with just 1 call