Skip to content

Commit

Permalink
add checks for lr nade give, renable remove weapons on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
destoer committed Jan 21, 2024
1 parent b4e82e2 commit 56e2b6e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/LastRequest/Dodgeball.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public override void player_hurt(int damage, int health, int hitgroup)
public override void grenade_thrown()
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);
Lib.give_event_nade_delay(player,1.4f,"weapon_flashbang");
give_lr_nade_delay(1.4f,"weapon_flashbang");
}

public override void ent_created(CEntityInstance entity)
Expand Down
2 changes: 1 addition & 1 deletion src/LastRequest/Grenade.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ public override void grenade_thrown()
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);
player.strip_weapons(true);
Lib.give_event_nade_delay(player,1.4f,"weapon_hegrenade");
give_lr_nade_delay(1.4f,"weapon_hegrenade");
}
}
22 changes: 22 additions & 0 deletions src/LastRequest/LRBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,28 @@ public virtual bool weapon_equip(String name)
return (winner,loser,winner_lr);
}


public void give_lr_nade_delay(float delay, String name)
{
if(JailPlugin.global_ctx == null)
{
return;
}

JailPlugin.global_ctx.AddTimer(delay,() =>
{
CCSPlayerController? player = Utilities.GetPlayerFromSlot(player_slot);
// need to double check LR is actually still active...
if(player != null && player.is_valid_alive() && manager.in_lr(player))
{
//Server.PrintToChatAll("give nade");
player.strip_weapons(true);
player.GiveNamedItem(name);
}
});
}

static public void print_countdown(LRBase lr, int delay)
{
if(lr.partner == null)
Expand Down
8 changes: 2 additions & 6 deletions src/Lib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,12 +302,8 @@ static public void strip_weapons(this CCSPlayerController? player, bool remove_k
return;
}

// buggy on windows (Wrong gamedata issue)
if(!is_windows())
{
player.RemoveWeapons();
}

player.RemoveWeapons();

// dont remove knife its buggy
if(!remove_knife)
{
Expand Down
2 changes: 1 addition & 1 deletion src/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ async void insert_player(String steam_id, String player_name)

public void inc_db(CCSPlayerController? player,LastRequest.LRType type, bool win)
{
if(player == null || !player.is_valid() || type == LastRequest.LRType.NONE)
if(player == null || !player.is_valid() || type == LastRequest.LRType.NONE || player.IsBot)
{
return;
}
Expand Down

0 comments on commit 56e2b6e

Please sign in to comment.