AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Catching Class Selection (https://forums.alliedmods.net/showthread.php?t=19298)

Brad 10-13-2005 15:35

Catching Class Selection
 
Does anyone know how to determine when the player has selected a class? To clarify, when choosing a team, you first select your team, and then a class. I want to determine when the class has been selected. I don't care what class. Just that any class has been chosen, thus the player is formally in the game.

XxAvalanchexX 10-13-2005 15:37

For which mod?

v3x 10-13-2005 16:01

I believe he's talking about CS with VGUI menus, we were discussing this earlier in IRC and I told him to take a look at the WeaponMod Lite plugin that I ported.

I assume you couldn't find a way to hook the menu? ;\

Brad 10-13-2005 16:35

Yes, CS.

The best I've been able to do thus far is to determine when the "select class" menu appears. Haven't been able to get to the other side yet.

Hawk552 10-13-2005 21:25

Sorry that it's got all the surf stuff in it, but that's what I used it for. This is the best I've been able to do to check when someone has selected their model:

EDIT: Also ignore "client_putinserver", it calls some stuff that's really irrelevant to this particular thing.

Code:
new g_lastmodel[33] = {0,...}; /*     CS_DONTCHANGE = 0,     CS_CT_URBAN = 1,     CS_T_TERROR = 2,     CS_T_LEET = 3,     CS_T_ARCTIC = 4,     CS_CT_GSG9 = 5,     CS_CT_GIGN = 6,     CS_CT_SAS = 7,     CS_T_GUERILLA = 8,     CS_CT_VIP = 9 */

Code:
register_event("TextMsg","join_respawn","a","1=1","2&Game_join_te","2&Game_join_ct");

Code:
public join_respawn() {     if(surfmap == false || !get_cvar_num("surf_on") || !get_cvar_num("surf_respawn"))     {         return 0;     }         new arg[32];     read_data(3,arg,31);         new id = cmd_target(1,arg,0);         if(g_lastmodel[id] == 0)     {         set_task(0.1,"check_model",id,_,_,"b");     }     else     {           // Spawn the player twice to avoid the HL engine bug         set_task(0.5,"player_spawn",id);         set_task(0.7,"player_spawn",id);             // Then give them a suit and a knife         set_task(0.9,"player_giveitems",id);     }         return 0; }

Code:
public check_model(id) {     new model[32];     cs_get_user_model(id,model,31);         if(containi(model,"urban")!=-1)     {         if(g_lastmodel[id]!=1)         {             remove_task(id);                         g_lastmodel[id] = 1;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);                         client_putinserver(id);         }       }     else if(containi(model,"terror")!=-1)     {         if(g_lastmodel[id]!=2)         {             remove_task(id);                         g_lastmodel[id] = 2;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);                         client_putinserver(id);         }       }     else if(containi(model,"leet")!=-1)     {         if(g_lastmodel[id]!=3)         {             remove_task(id);                         g_lastmodel[id] = 3;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);                         client_putinserver(id);         }       }     else if(containi(model,"arctic")!=-1)     {         if(g_lastmodel[id]!=4)         {             remove_task(id);                         g_lastmodel[id] = 4;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);                         client_putinserver(id);         }       }     else if(containi(model,"gsg")!=-1)     {         if(g_lastmodel[id]!=5)         {             remove_task(id);                         g_lastmodel[id] = 5;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);                         client_putinserver(id);         }       }     else if(containi(model,"gign")!=-1)     {         if(g_lastmodel[id]!=6)         {             remove_task(id);                         g_lastmodel[id] = 6;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);             client_putinserver(id);         }       }     else if(containi(model,"sas")!=-1)     {         if(g_lastmodel[id]!=7)         {             remove_task(id);                         g_lastmodel[id] = 7;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);                         client_putinserver(id);         }       }     else if(containi(model,"guerilla")!=-1)     {         if(g_lastmodel[id]!=8)         {             remove_task(id);                         g_lastmodel[id] = 8;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);                         client_putinserver(id);         }       }     else if(containi(model,"vip")!=-1)     {         if(g_lastmodel[id]!=9)         {             remove_task(id);                         g_lastmodel[id] = 9;                         /* Spawn the player twice to avoid the HL engine bug */             set_task(0.5,"player_spawn",id);             set_task(0.7,"player_spawn",id);                 /* Then give them a suit and a knife */             set_task(0.9,"player_giveitems",id);                         client_putinserver(id);         }       } }

Code:
public client_disconnect(id) {     g_lastmodel[id] = 0;         return 0; }

Code:
public client_client_putinserver(id) {     g_lastmodel[id] = 0;     // This is not what it actually is in my script, but it's just to help with this particular instance     return 0; }

Brad 10-13-2005 21:28

I just breezed through your code, so I may have missed something, but essentially you're just checking to see if the player's model changed from what it was when they spawn, correct?

While that would tell me that they've selected a class, it wouldn't tell me until they spawn, which could be seconds or minutes after they've selected the class. I need to know immediately.

Hawk552 10-13-2005 21:28

No actually it does tell you right away. Try it before you dismiss it.

Brad 10-13-2005 21:32

I will try it.

In the meantime, I'd appreciate it if you could read what I wrote again and tell me where I was dismissive.
Quote:

Originally Posted by Brad
I just breezed through your code, so I may have missed something, but essentially you're just checking to see if the player's model changed from what it was when they spawn, correct?

The bolded portions are of note. They indicate that I acknowledge that I could be wrong and that I'm asking for verification. The portion of my post that I didn't quote is based on the assumption that I was correct.

Hawk552 10-13-2005 21:33

Sigh, yes that's basically what it does. I haven't bumped into anything else that has been able to do it and therefore had to make a stupid and hackish method myself.

XxAvalanchexX 10-13-2005 21:33

I was testing in preThink comparing cs_get_user_model, the problem is that by default (upon joining) it is "urban", so if you picked the urban model itself there would be no change and it wouldn't signal that you have selected your "class."


All times are GMT -4. The time now is 00:05.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.