If you want no shooting during noclip use:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
enum PlayerData
{
bool:isCamera,
Float:lastlocx,
Float:lastlocy,
Float:lastlocz
}
new players[MAXPLAYERS+1][PlayerData];
public Plugin:myinfo =
{
name = "Camera Mode",
author = "Internet Bully",
description = "Let's a user type !camera to scope out a jump",
url = "http://www.sourcemod.net/"
}
public OnPluginStart()
{
HookEvent("player_spawn", OnSpawn, EventHookMode_Post);
RegConsoleCmd("camera", Cmd_Camera);
}
public Action:Cmd_Camera(client, args)
{
if(players[client][isCamera]) //teleport them back and turn off noclip
{
new Float:vec[3];
vec[0] = players[client][lastlocx];
vec[1] = players[client][lastlocy];
vec[2] = players[client][lastlocz]
Teleport(client, vec);
players[client][isCamera] = false;
SetEntityMoveType(client, MOVETYPE_WALK)
ReplyToCommand(client, "You are out of camera mode");
}
else //save where they were and put them in noclip
{
new Float:origin[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", origin);
players[client][lastlocx] = origin[0];
players[client][lastlocy] = origin[1];
players[client][lastlocz] = origin[2];
players[client][isCamera] = true;
SetEntityMoveType(client, MOVETYPE_NOCLIP);
ReplyToCommand(client, "You are in camera mode, !camera to return")
}
return Plugin_Handled;
}
public OnClientPutInServer(client)
{
InitPlayer(client);
SDKHook(client, SDKHook_TraceAttack, OnTakeDamage);
}
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
if(players[attacker][isCamera])
return Plugin_Handled;
return Plugin_Continue;
}
public InitPlayer(client)
{
players[client][isCamera] = false;
players[client][lastlocx] = 0.0;
players[client][lastlocy] = 0.0;
players[client][lastlocz] = 0.0;
}
Teleport(client, Float:location[3])
{
new Float:origin[3];
GetEntPropVector(client, Prop_Send, "m_vecOrigin", origin);
TeleportEntity(client, location, NULL_VECTOR, NULL_VECTOR);
}
public OnSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
SetEntData(GetClientOfUserId(GetEventInt(event, "userid")) , FindSendPropOffs("CBaseEntity", "m_CollisionGroup"), 2, 4, true); // set noblock on if you don't have it
}
If you want no shooting at all (it just blocks the damage, you can still shoot, it just doesn't do anything)
change
PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
if(players[attacker][isCamera])
return Plugin_Handled;
return Plugin_Continue;
}
to -->
PHP Code:
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotype, hitbox, hitgroup)
{
return Plugin_Handled;
}
I tested this a bit on my CSGO server and it seems to be fine. Rememberer it'll be whatever your trigger is in front, by default it's !.