16.10.2010, 23:21
I find that piece of code very confusing, well a few tips anyway.
Now for one thing, you should be using else if, because you can't be in more than one team, right? So why check the rest if he is in team soldier, police etc.
Then the part where you send the message is just a shorter if statement, no need for brackets unless you need to write multiple functions within the if statement.
Although none of this is actually changing how much code execution per-say, except for the else if changes.
Now about the code itself, if I guess correctly, you want it to see if the person is a medic or not? Well why all of these checks, you could just do
!= means not equal to.
Hope that helps
pawn Код:
if(cTeam[playerid] == TEAM_SOLIDER) // Doing nothing here?
else if(cTeam[playerid] == TEAM_POLICE) // or here?
else if(cTeam[playerid] == TEAM_ZOMBIE) // or here?
else if(cTeam[playerid] == TEAM_ZOMBIE2) SendClientMessage(playerid,COLOR_WHITE,"You are not a medic!");
Then the part where you send the message is just a shorter if statement, no need for brackets unless you need to write multiple functions within the if statement.
Although none of this is actually changing how much code execution per-say, except for the else if changes.
Now about the code itself, if I guess correctly, you want it to see if the person is a medic or not? Well why all of these checks, you could just do
pawn Код:
if(cTeam[playerid] != TEAM_MEDIC) SendClientMessage(playerid,COLOR_WHITE,"You are not a medic!");
Hope that helps