Jump to content
schadler17

Detecting player classnames

Recommended Posts

Gonna be making a gear script based on the players class. My question is, what's the fastest way of detecting the players classnames and assigning gear/items? I was thinking the switch command, but I'm not 100% sure how to use it. My other idea was the if then, but I'm not sure if that's the fastest way to do such a thing since there'd be so many possibilities.

If possible could someone write a basic switch command for something like this so I can see the usage of it? Like said, I'm not sure of how to use it if I were to do it that way.

Share this post


Link to post
Share on other sites
switch (typeOf player) do
{
	case "B_Rifleman_F": {/*Loadout*/};
	case "ClassName2": {/*Loadout*/};
	case "ClassName3": {/*Loadout*/};
	default {/*Default Loadout or Error Message*/};
};

Depending on the number of possibilities a switch will always be the better route, if you only have two, I would recommend using an if-else statement.

 

A switch, in basic terms, says, take this particular variable and compare it to a number of different possible values for that variable, if one of the "cases" is true, run that code, if it isn't true for that case check the next, and so forth. And if you have a default case (as exampled above, and is highly recommended to always include one) the code within it will run if none of the aforementioned cases are true.

Share this post


Link to post
Share on other sites

Exactly what I was looking for. I wasn't sure of where to put the classnames in question. Thank you very much.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×