Quote:
Originally Posted by Ghost Killer
Hi guys, I'm making a changing in a plugin to add a feature, I don't know too much of sorcepawn, but I know a little bit of C++. I'm having some doubts about what can use inside TF2_GetPlayerClass()?
|
you use a client index, which is basically an integer set to a certain number relative to your server's player count.
Example:
PHP Code:
//This is an extract from some of my code, it won't work on its own, the following code is in a "player_death" event:
new client = GetEventInt(GetClientOfUserId(event, "attacker")); //This will get us the client index of the killer
if (TF2_GetPlayerClass(client) == TF2_GetClass("pyro")) // If the player is a pyro, continue
{
//do stuff
}
basically, whatever you assign the client index to (in most cases you'll most likely assign it to a variable called 'client') is what you use in TF2_GetPlayerClass().
If I adjust the above code to what you're possibly trying to do:
PHP Code:
new TFClassType:classe = TF2_GetPlayerClass(client);
if (classe == TFClass_Pyro) // You can also use the TFClass_Classname form rather than TF2_GetClass("classname")
{
// do stuff
}
(I'm not 100% sure which of the 2 methods are more efficient/less expensive programming-wise)
Quote:
Also, How do I can restrict this check to only player who have choosed a class (so it will no include specs)? Cause if I don't it will generate a error inside the case (to choose what to do if player is on specified class),right?
|
I recommend looking at
GetClientTeam
I'm not certain as I haven't used the function myself yet, but I believe you check like so:
PHP Code:
if (GetClientTeam(client) == 1) //1 = spectator (I THINK) (If it isn't confirmed I will find out when I am in a position to)
{
Quote:
I've finished the edition of the file, but this things I said before probably will generate an error, so I'm asking here, can I past the full code so you guys can help me "debug" it? This is for a modified version of N1G TF2 stats that will generate a ranking per class too in the webpage (which default don't).
|
Besides the help above, trial and error testing on some kind of private server can teach you alot about how Sourcemod works
. If you want to paste the entire thing I'm sure someone who knows a bit more about this stuff will gladly help!
Hope this helps!
__________________