Raised This Month: $39 Target: $400
 9% 

a little help please


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mrmiki
Junior Member
Join Date: Mar 2021
Old 08-18-2021 , 15:56   a little help please
Reply With Quote #1

hi
im trying get players awp weapon
i dont know what is wrong!
it is no working



HTML Code:
#include <sourcemod>
#include <sdktools>

new countawp=0;
new String:weaponlist2[1024] = "weapon_awp";

public OnPluginStart()
{
    HookEvent("player_spawn", Event_PlayerSpawn);
    countawp=0;
}
public OnMapStart()
{
    countawp=0;
}

public Action Event_PlayerSpawn(Handle event, const char[] name, bool dontBroadcast) 
{
    int client = GetClientOfUserId(GetEventInt(event, "userid"));
    CreateTimer(0.5, Timer1, GetClientUserId(client), TIMER_REPEAT);
    countawp=0;
}

public Action Timer1(Handle timer, any userid)
{
    
    
    if(GameRules_GetProp("m_bWarmupPeriod") == 0)
    {
        for (new i = 0; i < MaxClients; i++)
        {
            new iWeapon = GetPlayerWeaponSlot(i, 0);
            char WeaponName2[32];
            GetEdictClassname(iWeapon, WeaponName2, sizeof(WeaponName2));
            if(!StrContains(weaponlist2, WeaponName2, false))
                {
                countawp++;
                }
            PrintToChatAll(" \x02AWP = %i", countawp);
        }
    }
    return Plugin_Continue;
}
mrmiki is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 08-18-2021 , 16: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
mrmiki
Junior Member
Join Date: Mar 2021
Old 08-18-2021 , 16:38   Re: a little help please
Reply With Quote #3

Quote:
Originally Posted by `666 View Post
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;
}


wow thanks bro

but it prints AWP = 0
what is wrong?
mrmiki is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 08-18-2021 , 16:55   Re: a little help please
Reply With Quote #4

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) {
	g_iCountawp = 0;
	for (int i = 1; i <= MaxClients; i++) {
		if (IsClientInGame(i) && !IsFakeClient(i) && IsPlayerAlive(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;
}

Last edited by `666; 08-18-2021 at 17:05. Reason: 1 more correction
`666 is offline
`666
AlliedModders Donor
Join Date: Jan 2006
Old 08-18-2021 , 17:00   Re: a little help please
Reply With Quote #5

just added to make sure player is alive or get errors.
`666 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 15:31.


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