Today we gona learn how to make a PlayerID function. It's a pretty good tutorial,
cause you can use this function do do more than just check a players name (for example
making a medic or something else cool). But Today we will do a PlayerID.
The first thing we need to do is to make a new file called "playerid.qc". Now, place this into that file: void() PlayerID = { local vector src; string trackp; src = self.origin + v_forward*10; src_z = self.absmin_z + self.size_z * 0.7; traceline (src, src + v_forward*1024, FALSE, self); // We are tracing a line from your view and to the first object that we hit (note the limit of 1024 units) if (trace_ent != world && trace_ent.origin != world.origin ) // Check so this object is not the world { if (trace_ent.classname == "player" && trace_ent.health > 0) // If it's not the world, is it a player? { trackp = ftos(trace_ent.health); // ftos (Float To String), or else we can't display the health with centerprint centerprint(self, "Name: ",trace_ent.netname, "\nHealth: ", trackp); // Print the player's netname (name) and health } } }; .float idupdate; self.idupdate = 0; if (self.idupdate < time) { self.idupdate = time + 1; PlayerID(); } void() PlayerID; |