Raised This Month: $32 Target: $400
 8% 

Weird issue cant figure out


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
bewpy
Junior Member
Join Date: Jan 2010
Old 08-29-2019 , 04:22   Weird issue cant figure out
Reply With Quote #1

Code:
#pragma semicolon 1

#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <multicolors>
#include <geoip>
#define PLUGIN_VERSION 	"1.0"

public Plugin:myinfo = {
	name = "Random",
	author = "",
	description = "Random weapons and stripping",
	version = PLUGIN_VERSION,
	url = "http://www.sourcemod.net/"
};

//LIST OF WEAPONS

#define MAX_WEAPONS     30
int LastWeaponNumber;

new const String:all_weapons[MAX_WEAPONS][] = {
    "weapon_m4a1", "weapon_m4a1_silencer", "weapon_ak47", "weapon_aug", "weapon_awp", "weapon_bizon", "weapon_deagle", "weapon_elite", "weapon_famas",
    "weapon_fiveseven", "weapon_G3SG1", "weapon_galilar", "weapon_glock", "weapon_hkp2000", "weapon_usp_silencer", "weapon_m249", "weapon_mac10",
    "weapon_mp7", "weapon_mp9", "weapon_negev", "weapon_p90", "weapon_p250", "weapon_cz75a", "weapon_scar20",
    "weapon_sg556", "weapon_ssg08", "weapon_taser", "weapon_tec9", "weapon_ump45", "weapon_revolver"
};

//On plugin start

public OnPluginStart () {
    HookEvent("round_start", RoundStart); 
    RegAdminCmd("sm_forcechange", Command_forcechange, ADMFLAG_KICK, "[OG] Admin - don't like this weapon! :( ");
    CreateConVar("sm_game_player_equip_version", PLUGIN_VERSION, "Game_Player_Equip Fix", FCVAR_NOTIFY|FCVAR_DONTRECORD);
	
}


public OnMapStart() {
   ServerCommand("ammo_grenade_limit_total 0");
   ServerCommand("ammo_grenade_limit_flashbang 0");
   ServerCommand("mp_buytime 0");
   ServerCommand("mp_maxmoney 0");
   ServerCommand("mp_t_default_secondary none");
   ServerCommand("mp_ct_default_secondary none");
   ServerCommand("mp_maxrounds 0");
   ServerCommand("mp_warmup_end");
   ServerCommand("log off");
   ServerCommand("sm_barrearmas_interval 0.01");
   ServerCommand("mp_ct_default_melee weapon_knife");
   ServerCommand("mp_t_default_melee weapon_knife");
   LastWeaponNumber = 0;
}


// !FORCECHANGE

public Action:Command_forcechange(client, args) {
	RandomWeapons();
}


// ROUND START DO RANDOMWEAPONS FUNCTION

public Action:RoundStart(Handle:event , const String: name[] , bool: dontBroadcast) {
    ServerCommand("mp_ct_default_melee weapon_knife");
    ServerCommand("mp_t_default_melee weapon_knife");
    RandomWeapons();
}

//GIVE RANDOM WEAPON FUNCTION

public RandomWeapons() {

    new Random;
    Random = GetRandomInt(0, 29);

    if (LastWeaponNumber != Random) {

    CPrintToChatAll("{blue}[Original-Gamers]{default} Current Weapon:{olive} %s", all_weapons[Random]);

    for (int i = 1; i < GetMaxClients(); ++i) {

        if (IsClientInGame(i) && IsPlayerAlive(i)) {
        
            new ent = GetPlayerWeaponSlot(i, 0);
            new ent1 = GetPlayerWeaponSlot(i, 1);
            new nadeslot = GetPlayerWeaponSlot(i, 3);


            if (ent > 0) {
                RemovePlayerItem(i, ent);
                RemoveEdict(ent);
            }

            if (ent1 > 0) {
                RemovePlayerItem(i, ent1);
                RemoveEdict(ent1);
            }

            if (nadeslot < 0) {
                GivePlayerItem(i, "weapon_hegrenade");
                GivePlayerItem(i, "weapon_flashbang");
            }

            if (Random == 15) {
                LastWeaponNumber = Random;
                return;
            }
            GivePlayerItem(i, all_weapons[Random]);

        }
    }

    LastWeaponNumber = Random;

    } else {
        RandomWeapons();
	
    }

    return;

}
Okay so I found some code that was outdated and started to edit it to fit how I want it to be on my server. Everything works good, but for some reason every round that I get a m249, I actually ONLY get a knife. Every other gun works. The CPrintToChatAll shows i should have spawned with an m249. For some reason this is the only gun that doesnt work and I only spawn with a knife. Anyone know what could be causing that?
bewpy is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-29-2019 , 05:21   Re: Weird issue cant figure out
Reply With Quote #2

PHP Code:

            
if (Random == 15) {
                
LastWeaponNumber Random;
                return;
            } 
Here's your problem.
__________________

Last edited by Ilusion9; 08-29-2019 at 05:21.
Ilusion9 is offline
bewpy
Junior Member
Join Date: Jan 2010
Old 08-29-2019 , 13:22   Re: Weird issue cant figure out
Reply With Quote #3

Thank you! Seems to work now
bewpy is offline
bewpy
Junior Member
Join Date: Jan 2010
Old 08-29-2019 , 23:07   Re: Weird issue cant figure out
Reply With Quote #4

Quote:
Originally Posted by Ilusion9 View Post
PHP Code:

            
if (Random == 15) {
                
LastWeaponNumber Random;
                return;
            } 
Here's your problem.
One more question.. It seems some maps that force weapons on player spawn stay in my inventory when I spawn. For example on aim_deagle7k, if its a round we randomly get a deagle, if I survive the round I keep my deagle the next round even though they're supposed to be stripped at the beginning of the round. Is there a way to remove forcing weapons on spawn on maps?
bewpy is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 08-30-2019 , 05:56   Re: Weird issue cant figure out
Reply With Quote #5

remove game_player_equip entities
__________________
Ilusion9 is offline
qNiGHT
AlliedModders Donor
Join Date: Mar 2019
Location: Romania
Old 08-30-2019 , 10:48   Re: Weird issue cant figure out
Reply With Quote #6

Quote:
Originally Posted by bewpy View Post
One more question.. It seems some maps that force weapons on player spawn stay in my inventory when I spawn. For example on aim_deagle7k, if its a round we randomly get a deagle, if I survive the round I keep my deagle the next round even though they're supposed to be stripped at the beginning of the round. Is there a way to remove forcing weapons on spawn on maps?

+

Code:
	char map[PLATFORM_MAX_PATH];
	GetCurrentMap(map, sizeof(map));
 
	if((strncmp(map, "aim_deagle7k", 5) == 0) || (strncmp(map, "aim_ ( for all aim_ maps )", 4) == 0) || (strncmp(map, "etc...", 4) == 0))
	{
		return;
or use https://sm.alliedmods.net/new-api/sdktools_functions/RemovePlayerItem
	}

Last edited by qNiGHT; 08-30-2019 at 10:49.
qNiGHT is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:40.


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