PDA

View Full Version : [tf2]team based events help


Vic Viper X
10-25-2015, 03:52
Hello! I was wondering if someone could possibly provide a short snippet of code that would perform a basic event (like displaying some text) based on their team.

Ex: if player is on red...
They typed: !sm_-command name here-.
PrintToChatAll("Someone on red typed something!")

if player is on blue...
They typed: !sm_-command name here-.
PrintToChatAll("Someone on blue typed something!")

Essentially i'm looking for a basic example on how to get a team, and then do different events based on it for tf2. Yes i'm semi-aware of "GetClientTeam" but i'm not sure how to apply it to this (if it can at all) My learning style is through example but for this particular instance i think a cleaner example (not me searching through other plugins code) would help more.

If anyone wouldn't mind quickly writing up one, it would be much appreciated! Thanks :)

Chaosxk
10-25-2015, 04:36
Example ->
int iTeamNum = GetClientTeam(client);
if(iTeamNum == (view_as<int>(TFTeam_Red))) {
PrintToChatAll("Someone on red typed something!");
}
else {
PrintToChatAll("Someone on blue typed something!");
}

Or you can use this, uses ternary op. to make it a 1 liner.
PrintToChatAll("Someone on %s typed something!", GetClientTeam(client) == (view_as<int>(TFTeam_Red)) ? "red" : "blue");

Wliu
10-25-2015, 14:46
Use TF2_GetClientTeam instead. Then you can get rid of the view_as stuff.

Vic Viper X
10-27-2015, 01:19
Yup that's what i needed! Thank you :)