AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Setting user team with client_cmd (https://forums.alliedmods.net/showthread.php?t=295288)

CouldYouPlease051 03-21-2017 11:00

Setting user team with client_cmd
 
PHP Code:

public handleJoin(id) {
  if(
bool:g_PlayerData[id][inTeam] == true) {
    return 
PLUGIN_HANDLED_MAIN;
  }

  return 
PLUGIN_CONTINUE;


Handles jointeam and joinclass commands.
This part in the function is causing me problems:
PHP Code:

g_PlayerData[id][inTeam] = false;
client_cmd(id"jointeam 1");
client_cmd(id"joinclass 5");
//g_PlayerData[id][inTeam] = true; 

If the boolean is commented out, it works perfectly, when it's not .. it won't work. I have an idea that I must have a longer delay when setting inTeam to true again but that would require me to create a task..

Am I doing anything wrong? Is there a better way so I wouldn't have to set a task?

klippy 03-21-2017 11:08

Re: Setting user team with client_cmd
 
Try engclient_cmd() instead.

CouldYouPlease051 03-21-2017 11:19

Re: Setting user team with client_cmd
 
Quote:

Originally Posted by KliPPy (Post 2505385)
Try engclient_cmd() instead.

Silly, but that oughta do it, thank you.

PRoSToTeM@ 03-21-2017 12:16

Re: Setting user team with client_cmd
 
Is this in client_putinserver?

CouldYouPlease051 03-21-2017 14:49

Re: Setting user team with client_cmd
 
Quote:

Originally Posted by PRoSToTeM@ (Post 2505398)
Is this in client_putinserver?

No, this is in a delayed function which is hooked with the ShowMenu and VGUIMenu message.

EFFx 03-21-2017 15:11

Re: Setting user team with client_cmd
 
as KliPPy said

PHP Code:

engclient_cmd(id"jointeam""5")
engclient_cmd(id"joinclass""5"

Edit:

If it works with client_cmd(). Then show the whole code.

CouldYouPlease051 03-21-2017 16:49

Re: Setting user team with client_cmd
 
Quote:

Originally Posted by EFFx (Post 2505441)
as KliPPy said

PHP Code:

engclient_cmd(id"jointeam""5")
engclient_cmd(id"joinclass""5"

Edit:

If it works with client_cmd(). Then show the whole code.

Right.. I'd like to believe I was quite clear about KliPPy's solution working just fine, it seems you either misunderstood or you're simply postcounting.

EFFx 03-21-2017 16:55

Re: Setting user team with client_cmd
 
Oh sry, I didn't know what was 'oughta', sry.


All times are GMT -4. The time now is 17:59.

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