View Single Post
`666
AlliedModders Donor
Join Date: Jan 2006
Old 08-18-2021 , 15:19   Re: a little help please
Reply With Quote #2

Code:
#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>
#include <sdktools>

int g_iCountawp;
char g_sWeaponName[64] = "weapon_awp";
bool g_bTimerOn;

public void OnPluginStart() {
	HookEvent("player_spawn", Event_PlayerSpawn);
}
public void OnMapStart() {
	g_iCountawp = 0;
	g_bTimerOn = false;
}

public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) {
	int client = GetClientOfUserId(event.GetInt("userid"));
	if (client > 0 && !IsFakeClient(client) && !g_bTimerOn) {
		g_bTimerOn = true;
		CreateTimer(0.5, Timer1, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
	}
}

Action Timer1(Handle timer) {
	if (GameRules_GetProp("m_bWarmupPeriod") == 0) {
		for (int i = 1; i <= MaxClients; i++) {
			if (IsClientInGame(i) && !IsFakeClient(i)) {
				int iWeapon = GetPlayerWeaponSlot(i, 0);
				char WeaponName2[32];
				GetEdictClassname(iWeapon, WeaponName2, sizeof(WeaponName2));
				if (StrContains(g_sWeaponName, WeaponName2, false)) {
						g_iCountawp++;
				}
			}
		}
		PrintToChatAll(" \x02AWP = %i", g_iCountawp);
	}
	return Plugin_Continue;
}
`666 is offline