here you go guys this is a real simple way to limit weapons per server… its crude and doesnt implement the gui out of stock like heavy weapons does but it works just the same… it would be a very good idea to implement limiting weapons to your mod… this would add appeal to your mod
here is an example to limiting sniper rifles 0 - 100
g_main.c
{ &d_sniperRifleRestriction, "d_sniperRifleRestriction", "100", CVAR_ARCHIVE|CVAR_SERVERINFO },
vmCvar_t d_sniperRifleRestriction;
local.h
extern vmCvar_t d_sniperRifleRestriction;
g_client .c Function: SetWolfSpawnWeapons
int numberRifles;
numberRifles = NumberOfRifles(client);
.
.
.
else if( pc == PC_COVERTOPS )
{
switch( client->sess.playerWeapon )
{
case WP_K43:
if( client->sess.sessionTeam == TEAM_AXIS )
{
if (numberSnipers >= d_sniperRifleRestriction.integer)
{
AddWeaponToPlayer( client, WP_STEN, 2*(GetAmmoTableData(WP_STEN)->defaultStartingAmmo), GetAmmoTableData(WP_STEN)->defaultStartingClip, qtrue );
break;
}
if (numberSnipers < d_sniperRifleRestriction.integer)
{
if( AddWeaponToPlayer( client, WP_K43, GetAmmoTableData(WP_K43)->defaultStartingAmmo, GetAmmoTableData(WP_K43)->defaultStartingClip, qtrue ) )
{
AddWeaponToPlayer( client, WP_K43_SCOPE, GetAmmoTableData(WP_K43_SCOPE)->defaultStartingAmmo, GetAmmoTableData(WP_K43_SCOPE)->defaultStartingClip, qfalse );
}
break;
}
}
case WP_GARAND:
if (numberSnipers >= d_sniperRifleRestriction.integer)
{
AddWeaponToPlayer( client, WP_STEN, 2*(GetAmmoTableData(WP_STEN)->defaultStartingAmmo), GetAmmoTableData(WP_STEN)->defaultStartingClip, qtrue );
break;
}
if (numberSnipers < d_sniperRifleRestriction.integer)
{
if( AddWeaponToPlayer( client, WP_GARAND, GetAmmoTableData(WP_GARAND)->defaultStartingAmmo, GetAmmoTableData(WP_GARAND)->defaultStartingClip, qtrue ) )
{
AddWeaponToPlayer( client, WP_GARAND_SCOPE, GetAmmoTableData(WP_GARAND_SCOPE)->defaultStartingAmmo, GetAmmoTableData(WP_GARAND_SCOPE)->defaultStartingClip, qfalse );
}
break;
}
also in g_client.c add the following function
// NumberOfRifles
//
//
int NumberOfRifles( gclient_t *client) {
int numRifles = 0;
int i;
int j;
for( i = 0; i < level.numConnectedClients; i++ ) {
j = level.sortedClients[i];
if( level.clients[j].sess.playerType == PC_COVERTOPS) {
if(COM_BitCheck( level.clients[j].ps.weapons, WP_K43)
||COM_BitCheck( level.clients[j].ps.weapons, WP_K43_SCOPE)
||COM_BitCheck( level.clients[j].ps.weapons, WP_GARAND)
||COM_BitCheck( level.clients[j].ps.weapons, WP_GARAND_SCOPE))
{
numRifles++;
}
}
}
return numRifles;
}
thats it … now you just allowed the server admins the abiliity to limit the total amount of sniper rifles allowed on the server :drink:
