AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved]How to count the connections to the server? (https://forums.alliedmods.net/showthread.php?t=132455)

#8 SickneSS 07-15-2010 09:23

[Solved]How to count the connections to the server?
 
-title-

Bugsy 07-15-2010 09:39

Re: How to count the connections to the server?
 
Use your brain or search. This is probably the most basic plugin one can make and im sure its been done multiple times.

Jelle 07-15-2010 09:39

Re: How to count the connections to the server?
 
PHP Code:

new gConnections

public client_connect(id)
{
    
gConnections gConnections 1



Vechta 07-15-2010 10:04

Re: How to count the connections to the server?
 
Ehm g_Connections += 1 is not the same ?

mottzi 07-15-2010 10:06

Re: How to count the connections to the server?
 
gConnections++


dont forget to save the count in a file/nvault!

Bugsy 07-15-2010 10:08

Re: How to count the connections to the server?
 
Yes it is the same. You can also do g_Connections++ or ++g_Connections. They all will do the same thing in this instance.

Backstabnoob 07-15-2010 10:29

Re: How to count the connections to the server?
 
I thought there was some difference between something++ and ++something, just didn't know what exactly.

#8 SickneSS 07-15-2010 10:43

Re: How to count the connections to the server?
 
Thanks ;D

RedRobster 07-15-2010 11:39

Re: How to count the connections to the server?
 
Quote:

Originally Posted by Backstabnoob (Post 1240090)
I thought there was some difference between something++ and ++something, just didn't know what exactly.

I don't know exactly how to explain it with words, but I can with this:

PHP Code:

for(new i=015i++)
{
    
// i is 0 first
    // ...
    // i is 14 last
}

for(new 
i=015; ++i)
{
    
// i is 1 first
    // ...
    // i is 15 last


Both of them will loop the same number of times. The only difference is that the first one is increasing i after the function, and the second one is increasing it before.

If I am not mistaken...:shock:

hleV 07-15-2010 12:05

Re: How to count the connections to the server?
 
Quote:

Originally Posted by RedRobster (Post 1240157)
I don't know exactly how to explain it with words, but I can with this:

PHP Code:

for(new i=015i++)
{
    
// i is 0 first
    // ...
    // i is 14 last
}
 
for(new 
i=015; ++i)
{
    
// i is 1 first
    // ...
    // i is 15 last


Both of them will loop the same number of times. The only difference is that the first one is increasing i after the function, and the second one is increasing it before.

If I am not mistaken...:shock:

You're thinking correctly, but ++i and i++ result in the same thing in a loop. So in both loops first and last i will be 0 and 14.
Code:
new i = 10;   if (++i == 10) // If 11 is equal to 10 {         // i is now 11 }
Code:
new i = 10;   if (i++ == 10) // If 10 is equal to 10 {         // i is now 11 }


All times are GMT -4. The time now is 07:15.

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