Raised This Month: $32 Target: $400
 8% 

Plugin to All Spec Admin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Masterofks
AlliedModders Donor
Join Date: Sep 2016
Location: Poland
Old 04-08-2018 , 06:58   Plugin to All Spec Admin
Reply With Quote #1

Hi!

I wrote plugin but it dosent work. Can someone help me with this plugin?

Code:
#pragma semicolon 1

#include <sourcemod>
#include <cstrike>

#pragma newdecls required

Handle cv_mp_forcecamera = null;

public void OnPluginStart()
{
RegConsoleCmd("sm_allspec", CMD_ALLSPEC);

cv_mp_forcecamera = FindConVar("mp_forcecamera");

if(!cv_mp_forcecamera)
{
SetFailState("Nie znaleziono: mp_forcecamera");
}
}

public Action CMD_ALLSPEC(int client, int args)
{
if(GetUserFlagBits(client) & ADMFLAG_ROOT)
{
SendConVarValue(client, cv_mp_forcecamera, "0");
PrintToChat(client, "[ADMIN] Zmieniłeś Cvar na 0");
return Plugin_Handled;
}
else
{
PrintToChat(client, "[ADMIN] Brak permisji");
return Plugin_Handled;
}
}

Last edited by DarkDeviL; 04-08-2018 at 11:34. Reason: Restored post
Masterofks is offline
Masterofks
AlliedModders Donor
Join Date: Sep 2016
Location: Poland
Old 04-27-2018 , 08:36   Re: Plugin to All Spec Admin
Reply With Quote #2

I tried this also doesnt work.

Code:
#pragma semicolon 1

#include <sourcemod>
#include <cstrike>

#pragma newdecls required

Handle cv_mp_forcecamera = -1;

public void OnPluginStart()
{
	RegConsoleCmd("sm_allspec", CMD_ALLSPEC);

	cv_mp_forcecamera = FindConVar("mp_forcecamera");
	
	if(!cv_mp_forcecamera)
	{
		SetFailState("Nie znaleziono: mp_forcecamera");
	}
}

public Action CMD_ALLSPEC(int client, int args)
{
	if(GetUserFlagBits(client) & ADMFLAG_BAN)
	{
		SendConVarValue(client, cv_mp_forcecamera, "0");
		PrintToChat(client, "[ADMIN] Włączyłeś możliwość oglądania przeciwnej drużyny");
		return Plugin_Handled;
	}
	else
	{
		PrintToChat(client, "[ADMIN] Brak permisji");
		return Plugin_Handled;
	}
}
Masterofks is offline
Qes
AlliedModders Donor
Join Date: Jul 2014
Old 04-27-2018 , 18:39   Re: Plugin to All Spec Admin
Reply With Quote #3

Check this
Code:
#include <sourcemod>
#include <cstrike>

new teamplayer[MAXPLAYERS+1];

public Plugin myinfo =
{
    name = "FreeLook",
    author = "CSC",
    description = "",
    version = "1.0",
    url = ""
};

public OnPluginStart()
{
		HookEvent("player_death", PlayerDeath, EventHookMode_Post);
		HookEvent("round_end", RoundEnd, EventHookMode_PostNoCopy);
		HookEvent("player_team", PlayerTeam, EventHookMode_Pre);
}

stock HasFlag(client, AdminFlag:flag)
{
	new AdminId:admin = GetUserAdmin(client);
	if((admin != INVALID_ADMIN_ID) && (GetAdminFlag(admin, flag, Access_Effective) == true))
	{
		return true;
	}
	return false;
}

public OnClientDisconnect(id)
{
	if(IsClientInGame(id))
	{
		teamplayer[id] = 0;
	}
}

public OnClientPutInServer(client)
{
	if(0 < client <= MaxClients)
	{
		teamplayer[client] = 0;
	}
}

public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    SetEventBroadcast(event, true);
    return Plugin_Continue;
}

public PlayerDeath(Handle:event, const String:EventName[], bool:nobroadcast)
{
	new id = GetClientOfUserId(GetEventInt(event, "userid"));

	if(!(0 < id <=MaxClients))
	return;

	if(!IsClientInGame(id))
  return;

  if(!HasFlag(id, Admin_Ban))
	return;

	teamplayer[id] = GetClientTeam(id);

	CreateTimer(3.0, freelook, id, TIMER_FLAG_NO_MAPCHANGE);
}

public RoundEnd(Handle:event, const String:name[], bool:dnt)
{
	for(new id=1; id<=MaxClients; id++)
	{
		if(!IsClientInGame(id))
		continue;

		if(GetClientTeam(id) == 0 && teamplayer[id] != 0 && HasFlag(id, Admin_Ban))
		{
			ChangeClientTeam(id, teamplayer[id]);
		}
	}
}

public Action:freelook(Handle:timer, any:id)
{
	if(!IsClientInGame(id))
	return;

	if(IsPlayerAlive(id))
	return;

	ChangeClientTeam(id, CS_TEAM_SPECTATOR);
}

Last edited by Qes; 04-27-2018 at 18:51. Reason: My bad
Qes is offline
Mitchell
~lick~
Join Date: Mar 2010
Old 04-27-2018 , 23:27   Re: Plugin to All Spec Admin
Reply With Quote #4

Setting the player's team to 0 would be okay, but you should move them back to their original team, or use sendproxy to fake their team to spectate.
Mitchell is offline
Qes
AlliedModders Donor
Join Date: Jul 2014
Old 04-28-2018 , 04:53   Re: Plugin to All Spec Admin
Reply With Quote #5

Quote:
Originally Posted by Mitchell View Post
or use sendproxy to fake their team to spectate.
Can you add example, please?

UPDATE for my plugin
Code:
#include <sourcemod>
#include <cstrike>

new teamplayer[MAXPLAYERS+1];

public Plugin myinfo =
{
    name = "Free look for admin",
    author = "-_-",
    description = "",
    version = "1.0",
    url = ""
};

public OnPluginStart()
{
		HookEvent("player_death", PlayerDeath, EventHookMode_Post);
		HookEvent("round_end", RoundEnd, EventHookMode_PostNoCopy);
		HookEvent("player_team", PlayerTeam, EventHookMode_Pre);
}

stock HasFlag(client, AdminFlag:flag)
{
	new AdminId:admin = GetUserAdmin(client);
	if((admin != INVALID_ADMIN_ID) && (GetAdminFlag(admin, flag, Access_Effective) == true))
	{
		return true;
	}
	return false;
}

public OnClientDisconnect(id)
{
	if(IsClientInGame(id))
	{
		teamplayer[id] = 0;
	}
}

public OnClientPutInServer(client)
{
	if(0 < client <= MaxClients)
	{
		teamplayer[client] = 0;
	}
}

public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    SetEventBroadcast(event, true);
    return Plugin_Continue;
}

public PlayerDeath(Handle:event, const String:EventName[], bool:nobroadcast)
{
  new id = GetClientOfUserId(GetEventInt(event, "userid"));

  if(!(0 < id <=MaxClients))
  return;

  if(!IsClientInGame(id))
  return;

  if(!HasFlag(id, Admin_Ban))
  return;

  teamplayer[id] = GetClientTeam(id);

  CreateTimer(3.0, freelook, id, TIMER_FLAG_NO_MAPCHANGE);
}

public RoundEnd(Handle:event, const String:name[], bool:dnt)
{
	for(new id=1; id<=MaxClients; id++)
	{
		if(!IsClientInGame(id))
		continue;

		if(GetClientTeam(id) == 1 && teamplayer[id] > 1)
		{
			ChangeClientTeam(id, teamplayer[id]);
		}
	}
}

public Action:freelook(Handle:timer, any:id)
{
  if(!IsClientInGame(id))
  return;

  if(IsPlayerAlive(id))
  return;

  if(!HasFlag(id, Admin_Ban))
  return;

  ChangeClientTeam(id, CS_TEAM_SPECTATOR);
}
or
Code:
#include <sourcemod>
#include <cstrike>

new teamplayer[MAXPLAYERS+1];

public Plugin myinfo =
{
    name = "Free look for admin",
    author = "-_-",
    description = "",
    version = "1.0",
    url = "https://forum.cs-classic.pl/"
};

public OnPluginStart()
{
		HookEvent("player_death", PlayerDeath, EventHookMode_Post);
		//HookEvent("round_end", RoundEnd, EventHookMode_PostNoCopy);
		HookEvent("round_end", RoundEnd, EventHookMode_Pre);
		//HookEvent("player_team", PlayerTeam, EventHookMode_Pre);
}

stock HasFlag(client, AdminFlag:flag)
{
	new AdminId:admin = GetUserAdmin(client);
	if((admin != INVALID_ADMIN_ID) && (GetAdminFlag(admin, flag, Access_Effective) == true))
	{
		return true;
	}
	return false;
}

public OnClientDisconnect(id)
{
	if(IsClientInGame(id))
	{
		teamplayer[id] = 0;
	}
}

public OnClientPutInServer(client)
{
	if(0 < client <= MaxClients)
	{
		teamplayer[client] = 0;
	}
}

public Action:PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
    SetEventBroadcast(event, true);
    return Plugin_Continue;
}

public PlayerDeath(Handle:event, const String:EventName[], bool:nobroadcast)
{
  new id = GetClientOfUserId(GetEventInt(event, "userid"));

  if(!(0 < id <=MaxClients))
  return;

  if(!IsClientInGame(id))
  return;

  if(!HasFlag(id, Admin_Ban))
  return;

  teamplayer[id] = GetClientTeam(id);

  CreateTimer(3.0, freelook, id, TIMER_FLAG_NO_MAPCHANGE);
}

public RoundEnd(Handle:event, const String:name[], bool:dnt)
{
	for(new id=1; id<=MaxClients; id++)
	{
		if(!IsClientInGame(id))
		continue;

		if(GetClientTeam(id) == 1 && teamplayer[id] > 1)
		{
			//ChangeClientTeam(id, teamplayer[id]);
      SetEntProp(id, Prop_Send, "m_iTeamNum", teamplayer[id]);
		}
	}
}

public Action:freelook(Handle:timer, any:id)
{
  if(!IsClientInGame(id))
  return;

  if(IsPlayerAlive(id))
  return;

  if(!HasFlag(id, Admin_Ban))
  return;

  //ChangeClientTeam(id, CS_TEAM_SPECTATOR);
  SetEntProp(id, Prop_Send, "m_iTeamNum", CS_TEAM_SPECTATOR);
}

Last edited by Qes; 04-29-2018 at 06:24.
Qes is offline
Reply



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 20:40.


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