AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved [CS:GO]Bool for clients (https://forums.alliedmods.net/showthread.php?t=291718)

Papero 12-19-2016 07:43

[CS:GO]Bool for clients
 
Hi,
How can I toggle a bool (or any variable that can do this) not globaly but only for the client that did the command like:

Code:

Player A do : sm_command
Server answer: X
Player B do: sm_command
Server answer: X
Player B do: sm_command
Server answer: Y ; not X

EDIT: Solved by searching in the tutorial sections: https://forums.alliedmods.net/showth...highlight=bool
Sorry for the (I think)not useful post.

Kolapsicle 12-19-2016 08:19

Re: [CS:GO]Bool for clients
 
I don't know why you can't use a global two dimensional boolean, but you could probably use a static boolean.

Papero 12-19-2016 08:32

Re: [CS:GO]Bool for clients
 
Quote:

Originally Posted by Kolapsicle (Post 2479000)
I don't know why you can't use a global two dimensional boolean, but you could probably use a static boolean.

Sawing that tutorial I saw that I can use
PHP Code:

bool Comm;

Comm[client] = true/false


headline 12-19-2016 23:26

Re: [CS:GO]Bool for clients
 
Quote:

Originally Posted by Papero (Post 2479002)
Sawing that tutorial I saw that I can use
PHP Code:

bool Comm;

Comm[client] = true/false


That can't happen

ddhoward 12-20-2016 03:18

Re: [CS:GO]Bool for clients
 
bool Comm[MaxClients + 1];

Comm[client] = !Comm[client];

WildCard65 12-20-2016 21:32

Re: [CS:GO]Bool for clients
 
Quote:

Originally Posted by ddhoward (Post 2479196)
bool Comm[MaxClients + 1];

Comm[client] = !Comm[client];

The declaration for the array is incorrect as it'll eval to 1 at compile time, or error

ddhoward 12-20-2016 23:50

Re: [CS:GO]Bool for clients
 
derp

bool Comm[MAXPLAYERS + 1];

bool Comm[] = new bool[MaxClients + 1];

One of those, depending on where it's declared and/or initialized, right? Source Engine games are making my machine BSOD, so I've been getting rusty. :P

WildCard65 12-21-2016 20:22

Re: [CS:GO]Bool for clients
 
Quote:

Originally Posted by ddhoward (Post 2479417)
derp

bool Comm[MAXPLAYERS + 1];

bool Comm[] = new bool[MaxClients + 1];

One of those, depending on where it's declared and/or initialized, right? Source Engine games are making my machine BSOD, so I've been getting rusty. :P

2nd varient requires static keyword.

Impact123 12-22-2016 00:34

Re: [CS:GO]Bool for clients
 
The code has to look like this though
PHP Code:

bool[] Comm = new bool[MaxClients 1]; 


shavit 12-22-2016 00:37

Re: [CS:GO]Bool for clients
 
Quote:

Originally Posted by WildCard65 (Post 2479605)
2nd varient requires static keyword.

how so?

Code:

// global
bool[] boolean1 = new bool[MaxClients + 1];

public void OnPluginStart()
{
        // local
        bool[] boolean2 = new bool[MaxClients + 1];
}

compiles just fine!


All times are GMT -4. The time now is 16:28.

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