I don't know why this code isn't working, I have tried different things to call it and to get it to work but it just doesn't work. These pieces are both in a client file.
[lua]
function GetMap()
local worldspawn = ents.GetByIndex( 0 );
local mapname = worldspawn:GetModel();
mapname = string.gsub( mapname, "(%w*/)", "" );
mapname = string.gsub( mapname, ".bsp", "" );
return mapname;
end
TS.MapViews = { }
TS.MapViews["gm_construct"] = { ang = Angle( 20.314821243286, 47.419368743896, 0 ),
pos = Vector( -1063.2745361328, -1709.8194580078, 610.81103515625 ) }
TS.MapViews["rp_c18_v1"] = { pos = Vector( -756.96539306641, -251.11378479004, 1040.7036132813 ),
ang = Angle( -11.148345947266, -16.038745880127, 0 ) }
TS.MapViews["rp_tb_city45_v02n"] = { pos = Vector( 259.531250, 3688.125000, 777.312500 ),
ang = Angle( 21.999979, -120.679893, 0 ) }
[/lua]
[lua]
local function CalcMapView( ply, origin, angles, fov )
if( CreateCharacterMenu ) then
print( "MAP VIEW ON.. " );
if( TS.MapViews[GetMap()] ) then
view.origin = TS.MapViews[GetMap()].pos;
view.angles = TS.MapViews[GetMap()].ang;
return view;
end
end
return view;
end
hook.Add( "CalcView", "TSMapView", CalcMapView );
[/lua]
Nothing happens.
Is there another way?
Are you getting any errors?
[editline]09:53PM[/editline]
Also, have you checked if your GetMap function actually returns what you think it does. Place a few prints in there to make sure.
No errors what so ever. I'll try that now.
[editline]09:56PM[/editline]
[lua]
function PrintMap()
print( "Getting map:" );
print( "Map: " .. GetMap() );
end
concommand.Add( "getmapname", PrintMap );
[/lua]
When I was on C18 it returned the map name "rp_c18_v1", seems to be working.
Looks like the hook isn't been called.
Anyone? Any different way to create a fake camera view?
[highlight](User was banned for this post ("Bumpity bump" - mahalis))[/highlight]
game.GetMap() anyone? Doesn't solve your problem but it's alot easier.
[lua]
concommand.Add("lolmap", function(p,c,a)
print("YOU WANT TO KNO THE MAP NAME DO YA? WELL HERE YOU GO "..game.GetMap())
end
[/lua]
Gave me:
YOU WANT TO KNO THE MAP NAME DO YA? WELL HERE YOU GO rp_evocity2_v1p
[editline]01:52AM[/editline]
Also try.
print(CreateCharacterMenu) and see if it's actually true.
[lua]
local function CalcMapView( ply, origin, angles, fov )
print( CreateCharacterMenu ); -- Do we really have a CreateCharacterMenu? If not, let us know.
if( CreateCharacterMenu ) then
print( "MAP VIEW ON.. " );
if( TS.MapViews[game.GetMap()] ) then
local view = {}; -- Previously view was nil.
view.origin = origin;
view.angles = angles;
view.fov = fov;
view.origin = TS.MapViews[GetMap()].pos;
view.angles = TS.MapViews[GetMap()].ang;
return view;
end
end
-- We didn't change anything so we won't return anything.
end
hook.Add( "CalcView", "TSMapView", CalcMapView );
[/lua]
Sorry, you need to Log In to post a reply to this thread.