Raised This Month: $ Target: $400
 0% 

Let players freecam.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Internet Bully
Member
Join Date: Apr 2014
Old 05-10-2014 , 20:02   Re: Let players freecam.
Reply With Quote #1

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"OnSpawnEventHookMode_Post);
    
RegConsoleCmd("camera"Cmd_Camera);
}

public 
Action:Cmd_Camera(clientargs)
{
    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(clientvec);
        
players[client][isCamera] = false;
        
SetEntityMoveType(clientMOVETYPE_WALK)
        
ReplyToCommand(client"You are out of camera mode");
    }
    else 
//save where they were and put them in noclip
    
{
        new 
Float:origin[3];
        
GetEntPropVector(clientProp_Send"m_vecOrigin"origin);
        
players[client][lastlocx] = origin[0];
        
players[client][lastlocy] = origin[1];
        
players[client][lastlocz] = origin[2];
        
players[client][isCamera] = true;
        
SetEntityMoveType(clientMOVETYPE_NOCLIP);
        
ReplyToCommand(client"You are in camera mode, !camera to return")
    }
    return 
Plugin_Handled;
}

public 
OnClientPutInServer(client)
{
    
InitPlayer(client);
    
SDKHook(clientSDKHook_TraceAttackOnTakeDamage);
}

public 
Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotypehitboxhitgroup)
{
    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(clientFloat:location[3])
{
    new 
Float:origin[3];
    
GetEntPropVector(clientProp_Send"m_vecOrigin"origin);
    
TeleportEntity(clientlocationNULL_VECTORNULL_VECTOR);
}

public 
OnSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    
SetEntData(GetClientOfUserId(GetEventInt(event"userid")) , FindSendPropOffs("CBaseEntity""m_CollisionGroup"), 24true); // 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, &ammotypehitboxhitgroup)
{
    if(
players[attacker][isCamera])
        return 
Plugin_Handled;
        
    return 
Plugin_Continue;

to -->
PHP Code:
 public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &ammotypehitboxhitgroup)
{
    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 !.

Last edited by Internet Bully; 05-10-2014 at 20:15.
Internet Bully is offline
Catface100
Junior Member
Join Date: Apr 2014
Old 05-13-2014 , 19:14   Re: Let players freecam.
Reply With Quote #2

Thanks for this, it works great on my server!

However, the problem I am finding now is players are using the save location plugin to save while in the camera, effectively treating it as noclip, which is what I wanted to avoid.

Is there any way you can block people from saving their location while in the camera mode? This is the location saver I'm using: https://forums.alliedmods.net/showth...18215?t=118215

EDIT:

Some more problems I've found:
- Engineers can place sentries while in camera (which could mess people up, especially on jump servers)
- Rockets still do damage to players
- Pyros can airblast
- Upon changing team while in camera, you can then go back to where you activated it still (as the !camera command obviously toggles and doesn't reset on death/team swap)

If it's possible to fix any of these, it would be greatly appreciated.

Note: I am by no means belittling the plugin, as I think it's great so far, it's just that these are some of the issues I've found that could be solved to take it further.

Last edited by Catface100; 05-13-2014 at 19:30.
Catface100 is offline
Internet Bully
Member
Join Date: Apr 2014
Old 05-14-2014 , 17:25   Re: Let players freecam.
Reply With Quote #3

I'm fairly sure I fixed all of these issues. You'll need smlib to compile, or just use a webcompiler.

PHP Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
#include <smlib>

new bool:Camera[MAXPLAYERS+1];
new 
Float:originSaves[MAXPLAYERS+1][3];
new 
Float:angleSaves[MAXPLAYERS+1][3];

public 
Plugin:myinfo 
{
    
name "Camera Mode",
    
author "Internet Bully",
    
description "Lets a user type !camera to scope out a jump",
    
url "http://www.sourcemod.net/"
}

public 
OnPluginStart()
{
    
HookEvent("player_spawn"OnSpawnEventHookMode_Post);
    
RegConsoleCmd("camera"Cmd_Camera);
    
AddCommandListener(BlockCPSave"sm_cpsave");
}

public 
Action:Cmd_Camera(clientargs)
{
    if(
Camera[client])   //teleport them back and turn off noclip
    
{
        
TeleportEntity(clientoriginSaves[client], angleSaves[client], NULL_VECTOR);
        
Camera[client] = false;
        
SetEntityMoveType(clientMOVETYPE_WALK)
        
ReplyToCommand(client"You are out of camera mode");
    }
    else 
//save where they were and put them in noclip
    
{
        
GetClientAbsOrigin(clientoriginSaves[client]);
        
GetClientAbsAngles(clientangleSaves[client]);
        
Camera[client] = true;
        
SetEntityMoveType(clientMOVETYPE_NOCLIP);
        
ReplyToCommand(client"You are in camera mode, !camera to return")
    }
    return 
Plugin_Handled;
}

public 
OnClientPutInServer(client)
{
    
InitPlayer(client);
}

public 
InitPlayer(client)
{
    
SetEntityMoveType(clientMOVETYPE_WALK);
    
Camera[client] = false;
    
originSaves[client] = NULL_VECTOR;
    
angleSaves[client] = NULL_VECTOR;
}

public 
OnSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
SetEntData(clientFindSendPropOffs("CBaseEntity""m_CollisionGroup"), 24true); // set noblock on if you don't have it
    
Client_RemoveAllWeapons(client""true);
    
InitPlayer(client);
}

public 
Action:BlockCPSave(client, const String:command[], args)
{
    if(
Camera[client])
    {
        
ReplyToCommand(client"Stop trying to cheat!");
        
TeleportEntity(clientoriginSaves[client], angleSaves[client], NULL_VECTOR);
        
Camera[client] = false;
        
SetEntityMoveType(clientMOVETYPE_WALK)
        
ReplyToCommand(client"You are out of camera mode");
        return 
Plugin_Handled;
    }
    return 
Plugin_Continue;

Flatout removed all weapons on spawn, cleared all saved locations/noclip on respawn, added viewangles to be saved, in my limited testing, it wouldn't let me save a point (sm_cpsave) if I was in camera mode. I'm not testing on TF2 though, so you'll have to let me know if it actually removed all the weapons. If you try to save a point while in camera, it'll turn it off and teleport you back to the original location.

Last edited by Internet Bully; 05-14-2014 at 17:30.
Internet Bully is offline
Catface100
Junior Member
Join Date: Apr 2014
Old 05-14-2014 , 17:28   Re: Let players freecam.
Reply With Quote #4

Ok, thanks so much!

I'll test it asap, the problem with renting a server from multiplay is they have to put everything on themselves which sometimes takes a little while.

Would you mind if I post back here with any more issues people find while using it?
Catface100 is offline
Internet Bully
Member
Join Date: Apr 2014
Old 05-14-2014 , 17:42   Re: Let players freecam.
Reply With Quote #5

Not a problem, I'll be around.
Internet Bully 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 04:52.


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