View Single Post
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-06-2022 , 18:17   Re: Enum struct, how do we access the struct property as parameter?
Reply With Quote #8

PHP Code:
#define MAXPLAYERS      65  /**< Maximum number of players SourceMod supports */ 
Different games has different max player count.
There can be 65 players in some games.


So if you create array
Code:
array[65]
...you have array, valid array indexs from 0 to 64 (total 65 index)


Usually we use client indexs as array index. You have to remember, client index start from 1 (0 is console)
Now you use above array, starting index 1 to 64 (total 64 index)

In code we loop using dynamic variable MaxClients, this can return result 65

In code loop, to catch finale client index 65
PHP Code:
for(int i 1<= MaxClientsi++) 
...plugin would throw error, Array index out-of-bounds.

This is reason why should add +1 while create array, because array index has offset +1 when using client indexs.






Also
SourceTV adds +1 extra slot in some games (ex. CS:S).

Code:
Unable to load plugin "addons/metamod/bin/win64/server"
maxplayers set to 65
Unknown command "r_decal_cullsize"
Network: IP 192.168.1.2, mode MP, dedicated Yes, ports 27015 SV / 27005 CL
Initializing Steam libraries for secure Internet server
No account token specified; logging into anonymous game server account.  (Use sv_setsteamaccount to login to a persistent account.)
L 12/07/2022 - 00:32:08: [GEOIP] GeoIP2 database loaded: GeoLite2-City (2022-11-21 15:35:08 UTC) (G:\server\counter-strike source\cstrike\addons\sourcemod\configs\geoip\GeoLite2-City.mmdb)
L 12/07/2022 - 00:32:08: [GEOIP] GeoIP2 supported languages: de en es fr ja pt-BR ru zh-CN
Executing dedicated server config file server.cfg
Using map cycle file 'cfg/mapcycle_default.txt'.  ('cfg\mapcycle.txt' was not found.)
Set motd from file 'cfg/motd_default.txt'.  ('cfg/motd.txt' was not found.)
Set motd_text from file 'cfg/motd_text_default.txt'.  ('cfg/motd_text.txt' was not found.)
SV_ActivateServer: setting tickrate to 66.7
Unknown command "sm_bombsite_swap"
Unknown command "sm_bombsiteA_pos"
Unknown command "sm_bombsiteB_pos"
Connection to Steam servers successful.
   Public IP is x.
Assigned anonymous gameserver Steam ID [A:1:270043136:22053].
VAC secure mode is activated.
status
hostname: Do not come here.
version : 6630498/24 6630498 secure
udp/ip  : 192.168.1.2:27015  (public ip: x)
steamid : [A:1:270043136:22053] (90166709731231744)
map     : de_dust2 at: 0 x, 0 y, 0 z
tags    : increased_maxplayers
players : 0 humans, 0 bots (65 max)
edicts  : 261 used of 2048 max
# userid name                uniqueid            connected ping loss state  adr
tv_enable
"tv_enable" = "0"
 notify
 - Activates SourceTV on server.
tv_enable 1
maxplayers set to 66 (extra slot was added for SourceTV)
status
hostname: Do not come here.
version : 6630498/24 6630498 secure
udp/ip  : 192.168.1.2:27015  (public ip: x)
steamid : [A:1:270043136:22053] (90166709731231744)
map     : de_dust2 at: 0 x, 0 y, 0 z
tags    : increased_maxplayers
players : 0 humans, 0 bots (66 max)
edicts  : 261 used of 2048 max
# userid name                uniqueid            connected ping loss state  adr
But this would give glitches, errors and crashes to server.
__________________
Do not Private Message @me
Bacardi is offline