Skip to content

Commit

Permalink
Updated to 1.2.1 version, fixed bot hooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
xharen committed Jul 6, 2023
1 parent 8b21521 commit e1c786d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 53 deletions.
2 changes: 1 addition & 1 deletion scripts/nst_weapons.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include <hamsandwich>

#define PLUGIN "NST Weapons"
#define VERSION "1.2.0"
#define VERSION "1.2.1"
#define AUTHOR "github.com/kruz1337"

const MAX_PLAYER = 32
Expand Down
23 changes: 19 additions & 4 deletions scripts/nst_weapons_melee.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string_stocks>

#define PLUGIN "NST Melee Weapons"
#define VERSION "1.2.0"
#define VERSION "1.2.1"
#define AUTHOR "github.com/kruz1337"

const m_pPlayer = 41
Expand Down Expand Up @@ -62,8 +62,6 @@ public plugin_init() {
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")

RegisterHam(Ham_TakeDamage, "player", "Ham_TakeDamage_Pre")
RegisterHam(Ham_TakeDamage, "bot", "Ham_TakeDamage_Pre")
RegisterHam(Ham_Spawn, "bot", "Ham_BotSpawn_Post")
RegisterHam(Ham_Item_Deploy, "weapon_knife", "Weapon_Deploy_Post", 1)
RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "Primary_Attack_Post", 1)
RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "Secondary_Attack_Post", 1)
Expand Down Expand Up @@ -742,7 +740,9 @@ public Ham_TakeDamage_Pre(victim, inflictor, attacker, Float: damage) {
}

public Ham_BotSpawn_Post(client) {
if (IsConfigBroken || !get_cvar_num("nst_give_bot")) {
if (IsConfigBroken ||
!get_cvar_num("nst_give_bot") ||
!is_user_alive(client)) {
return HAM_IGNORED
}

Expand Down Expand Up @@ -909,4 +909,19 @@ public Task_BotWeapons(client) {
if (random_weapon_id != 0) {
Buy_Weapon(client, random_weapon_id)
}
}

public client_putinserver(client) {
if (IsConfigBroken ||
!is_user_bot(client)) {
return PLUGIN_CONTINUE
}

set_task(0.1, "Do_RegisterHam_Bot", client)
return PLUGIN_HANDLED
}

public Do_RegisterHam_Bot(client) {
RegisterHamFromEntity(Ham_Spawn, client, "Ham_BotSpawn_Post")
RegisterHamFromEntity(Ham_TakeDamage, client, "Ham_TakeDamage_Pre")
}
39 changes: 16 additions & 23 deletions scripts/nst_weapons_primary.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string_stocks>

#define PLUGIN "NST Primary Weapons"
#define VERSION "1.2.0"
#define VERSION "1.2.1"
#define AUTHOR "github.com/kruz1337"

const m_pPlayer = 41
Expand Down Expand Up @@ -98,8 +98,6 @@ public plugin_init() {
register_forward(FM_CmdStart, "fw_CmdStart")

RegisterHam(Ham_TakeDamage, "player", "Ham_TakeDamage_Pre")
RegisterHam(Ham_TakeDamage, "bot", "Ham_TakeDamage_Pre")
RegisterHam(Ham_Spawn, "bot", "Ham_BotSpawn_Post")
RegisterHam(Ham_Touch, "weaponbox", "Ham_PlayerTouchWeaponBox")
RegisterHam(Ham_TraceAttack, "worldspawn", "Ham_TraceAttack_Post", 1)
RegisterHam(Ham_TraceAttack, "func_breakable", "Ham_TraceAttack_Post", 1)
Expand Down Expand Up @@ -1751,26 +1749,6 @@ public Event_Death() {
return PLUGIN_HANDLED
}

/*
public client_putinserver(client) {
if (IsConfigBroken || !is_user_bot(client)) {
return PLUGIN_CONTINUE
}
set_task(0.1, "Do_RegisterHam_Bot", client)
return PLUGIN_HANDLED
}
public Do_RegisterHam_Bot(client) {
if (IsConfigBroken || !is_user_alive(client)) {
return
}
RegisterHamFromEntity(Ham_Item_PostFrame, client, "Rifles_PostFrame_Pre")
RegisterHamFromEntity(Ham_Item_Deploy, client, "Weapon_Deploy_Post", 1)
RegisterHamFromEntity(Ham_Touch, client, "Ham_PlayerTouchWeaponBox")
}*/

public Task_BotWeapons(client) {
if (IsConfigBroken || !is_valid_ent(client)) {
return
Expand All @@ -1791,4 +1769,19 @@ public Task_BotWeapons(client) {
} else if (random_weapon_id != 0) {
Buy_Weapon(client, random_weapon_id)
}
}

public client_putinserver(client) {
if (IsConfigBroken ||
!is_user_bot(client)) {
return PLUGIN_CONTINUE
}

set_task(0.1, "Do_RegisterHam_Bot", client)
return PLUGIN_HANDLED
}

public Do_RegisterHam_Bot(client) {
RegisterHamFromEntity(Ham_Spawn, client, "Ham_BotSpawn_Post")
RegisterHamFromEntity(Ham_TakeDamage, client, "Ham_TakeDamage_Pre")
}
43 changes: 18 additions & 25 deletions scripts/nst_weapons_secondary.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <string_stocks>

#define PLUGIN "NST Secondary Weapons"
#define VERSION "1.2.0"
#define VERSION "1.2.1"
#define AUTHOR "github.com/kruz1337"

const m_pPlayer = 41
Expand Down Expand Up @@ -86,8 +86,6 @@ public plugin_init() {
register_event("TextMsg", "Event_Commencing", "a", "2=#Game_Commencing", "2=#Game_End", "2=#Game_will_restart_in")

RegisterHam(Ham_TakeDamage, "player", "Ham_TakeDamage_Pre")
RegisterHam(Ham_TakeDamage, "bot", "Ham_TakeDamage_Pre")
RegisterHam(Ham_Spawn, "bot", "Ham_BotSpawn_Post")
RegisterHam(Ham_Touch, "weaponbox", "Ham_PlayerTouchWeaponBox")
RegisterHam(Ham_TraceAttack, "worldspawn", "Ham_TraceAttack_Post", 1)
RegisterHam(Ham_TraceAttack, "func_breakable", "Ham_TraceAttack_Post", 1)
Expand Down Expand Up @@ -1556,26 +1554,6 @@ public Event_Death() {
return PLUGIN_CONTINUE
}

/*
public client_putinserver(client) {
if (IsConfigBroken || !is_user_bot(client)) {
return PLUGIN_CONTINUE
}
set_task(0.1, "Do_RegisterHam_Bot", client)
return PLUGIN_HANDLED
}
public Do_RegisterHam_Bot(client) {
if (IsConfigBroken || !is_valid_ent(client)) {
return
}
RegisterHamFromEntity(Ham_Item_PostFrame, client, "Pistols_PostFrame_Pre")
RegisterHamFromEntity(Ham_Item_Deploy, client, "Weapon_Deploy_Post", 1)
RegisterHamFromEntity(Ham_Touch, client, "Ham_PlayerTouchWeaponBox")
}*/

public Task_BotWeapons(client) {
if (IsConfigBroken || !is_valid_ent(client)) {
return
Expand All @@ -1585,10 +1563,10 @@ public Task_BotWeapons(client) {
new CHANGE_WEAPON = str_to_num(ParseConfig(CURRENT_WEAPON, "wpn_id"))
new wpnId = get_user_weapon(client)


/*
if (HasUserSecondary(client)) {
return
}
}*/

new random_weapon_id = random_num(0, ArraySize(Pistol_Names) - 1)

Expand All @@ -1597,4 +1575,19 @@ public Task_BotWeapons(client) {
} else if (random_weapon_id != 0) {
Buy_Weapon(client, random_weapon_id)
}
}

public client_putinserver(client) {
if (IsConfigBroken ||
!is_user_bot(client)) {
return PLUGIN_CONTINUE
}

set_task(0.1, "Do_RegisterHam_Bot", client)
return PLUGIN_HANDLED
}

public Do_RegisterHam_Bot(client) {
RegisterHamFromEntity(Ham_Spawn, client, "Ham_BotSpawn_Post")
RegisterHamFromEntity(Ham_TakeDamage, client, "Ham_TakeDamage_Pre")
}

0 comments on commit e1c786d

Please sign in to comment.