View Single Post
nikooo777
AlliedModders Donor
Join Date: Apr 2010
Location: Lugano, Switzerland
Old 12-08-2012 , 17:53   Re: CS:S Source Plugin Request.
Reply With Quote #3

credits thanks
Code:
/* Plugin Template generated by Pawn Studio */
//THIS IS THE FIXED VERSION!!
#include <sourcemod>
#include <sdktools>
#include <cstrike>
new index =-1;
new index2 = -1;
new String:map[64];
public Plugin:myinfo = 
{
	name = "4way doors hack",
	author = "Niko with special thanks to Bacardi",
	description = "informs the admins when a door is closed and who did it",
	version = "3.4",
	url = "http://forum.elite-hunterz.info"
}

public OnPluginStart() 
{
	GetCurrentMap(map,sizeof(map))
	if (!strcmp(map,"zm_4way_tunnel_v2",false)) //wrong lol
	{
		HookEvent("round_start", round_start); 
		RegConsoleCmd("sm_open",Command_Doors);
		HookEntityOutput( "func_button", "OnPressed", func_button);
		LogError("pluginload, map: %s",map);
	}
}

public round_start(Handle:event, const String:name[], bool:dontBroadcast) 
{ 
	
	LogError("roundstart, map: %s",map);
	new ent = -1, String:clsname[30]; 
	while((ent = FindEntityByClassname(ent, "func_button")) != -1) 
	{ 
		GetEntPropString(ent, Prop_Data, "m_iName", clsname, sizeof(clsname)); 
		if(StrContains(clsname, "Shutter_") == 0) 
		{ 
			/** These buttons in zm_4way_tunnel_v2 map 
			Shutter_left01_switch_close 
			Shutter_left01_switch_open 
			Shutter_right01_switch_close 
			Shutter_right01_switch_open 
			*/ 
			//LogError("changing prop data on map: %s",map);
			SetEntProp(ent, Prop_Data, "m_spawnflags", GetEntProp(ent, Prop_Data, "m_spawnflags")|512); // Add spawnflag 512 "Damage Activates"
			if (strcmp(clsname,"Shutter_left01_switch_open") == 0)
			{
				index = ent;
			}
			else if (strcmp(clsname,"Shutter_right01_switch_open") == 0)
			{
				index2 = ent;
			}
		} 
	} 
	//LogError("roundstart actions ended");
}


public func_button(const String:output[], caller, activator, Float:delay) 
{ 
	if(activator > 0 && activator <= MaxClients) // Is valid client index 
	{ 
		new String:entity[512];
		new String:name[MAX_NAME_LENGTH];
		new String:steamid[32];
		new maxplayers = GetMaxClients();
		GetEntPropString(caller, Prop_Data, "m_iName", entity, sizeof(entity));
		//PrintToChatAll("%i",caller);
		GetClientName(activator,name,sizeof(name));
		GetClientAuthString(activator,steamid,sizeof(steamid));
		if(strcmp(entity, "Shutter_left01_switch_close") == 0) 
		{
			for (new x = 1; x <= maxplayers; x++)
			{
				if (!IsClientInGame(x))
					continue;
				new AdminId:admin_id = GetUserAdmin(x);
				if (admin_id != INVALID_ADMIN_ID && (GetUserFlagBits(x) & ADMFLAG_CUSTOM4))
				{           
					PrintToChat(x,"The left door was closed by %s - %s", name, steamid);
				}
			}
		}
		else if (strcmp(entity, "Shutter_right01_switch_close") == 0) 
		{
			for (new x = 1; x <= maxplayers; x++)
			{
				if (!IsClientInGame(x))
					continue;
				new AdminId:admin_id = GetUserAdmin(x);
				if (admin_id != INVALID_ADMIN_ID && (GetUserFlagBits(x) & ADMFLAG_CUSTOM4))
				{           
					PrintToChat(x,"The right door was closed by %s - %s", name, steamid);
				}
			}
		}
	}
	LogError("button press on map: %s",map);
}

public Action:Command_Doors(client,args)
{
	LogError("command doors executed on map: %s",map);
	new AdminId:admin_id = GetUserAdmin(client);
	if (IsClientInGame(client) && (admin_id != INVALID_ADMIN_ID) && (GetUserFlagBits(client) & ADMFLAG_CUSTOM4))
	{
		if(AcceptEntityInput(index,"Press",-1,-1,0) == false){
			PrintToChatAll("there was an error opening the left door");
			LogError("error opening left door, map: %s",map);
		}
		if(AcceptEntityInput(index2,"Press",-1,-1,0) == false){
			PrintToChatAll("there was an error opening the right door");
			LogError("error opening left door, map: %s",map);
		}
		else 
		ReplyToCommand(client,"Doors are now open");
	}
	else
	{
		ReplyToCommand(client,"Sorry You're Not Authorized to use this command");
	}
	return Plugin_Handled;
}
as i said work on this, it has everything you need
__________________

Last edited by nikooo777; 12-08-2012 at 17:56.
nikooo777 is offline