View Single Post
MasterMind420
BANNED
Join Date: Nov 2010
Old 04-06-2019 , 10:50   Re: Check if player has grenade/equip on spawn
Reply With Quote #7

[QUOTE=MatoBoost;2646550]
Code:
#include <cstrike>
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>

public Plugin:myinfo = 
{
	name = "Grenade strip VIP",
	author = "MatoBoost",
	description = "Removes grenades at the end of the round for VIP",
	version = "0.1",
	url = "http://games-town.eu"
}

public OnPluginStart(){
}

public OnRoundEnd(Handle:event, const String:name[], bool:dontBroadcast){

	int client = GetClientOfUserId(GetEventInt(event, "userid"))	
	int ent = -1;  
	
	for(int i = 1; i <= MaxClients; i++){
		if(((CheckCommandAccess(client, "", ADMFLAG_RESERVATION)) == 1) && IsClientInGame(i)){
		
			while ((ent = GetPlayerWeaponSlot(client, CS_SLOT_GRENADE)) != -1)
			{
				RemovePlayerItem(client, ent);
				RemoveEntity(ent);
			}
	
		}
	}
}
Removing entities on Round_End event is a bad idea...instead do everything your trying to do during player_activate event...if the game your doing has it. Player Spawn would work but doesn't just fire at the beginning of rounds. Player activate fires once per player when they first connect each round. Or just use player spawn event with a delay timer. Just check when the player spawns what weapons they have and adjust accordingly...Also use RemovePlayerItem(client,ent); as well as AcceptEntityInput(ent, "Kill");...i never use RemoveEntity... I'm guessing your having issues because your doing it at the end of the round...some players may not make it thru the loop. I've had weird behavior like that happen trying to do some things within round_end...also no need for that while loop...its overkill for what your doing...simply check the playerweaponslot has a grenade...if it does remove it like i showed u.
MasterMind420 is offline