PDA

View Full Version : [Question] Tinkering with FOV


SamuraiBarbi
09-10-2007, 18:57
Hello everyone. I was trying to tinker with clients FOV, ( not by execing anything on their end, but just something temporary that undoes itself when they leave the server ) and what I think should work isn't. I'm coding this specifically for Counterstrike Source, not sure if it matters or not.

What I've attempted was:

SetEntProp(client, Prop_Send, "m_iFOV", 145, 4);

If it helps any, the es_tools equivalent would be:
es_setplayerprop event_var(userid) "CCSPlayer.baseclass.m_iFOV" 45


Anywho, if anyone could please toss a hint my way as to what the problem is I'd big time appreciate it.

Thanks!

BAILOPAN
09-10-2007, 21:19
That looks like the right equivalent.

Nican
09-10-2007, 21:19
Never mind D:

SamuraiBarbi
09-10-2007, 21:38
yeah, it looks right but for some reason it doesn't work. doesn't seem to change the FOV at all.

SamuraiBarbi
09-10-2007, 21:43
wtf, did valve break something? when i type fov in console nothing even pops up, and i can't change it at all. i tried using fov 145 in console just to see if it might had been me. can someone else try changing their own fov in console ( preferably in counterstrike source ) and verify if they experience the same thing?

SamuraiBarbi
09-10-2007, 22:30
sorry for the triple post but I just wanted to let you guys know i figured it out. for some reason altering FOV now requires a user to run sv_cheats 1, IE. sv_cheats 1;fov 90

to my knowledge this wasn't the case several months ago. anywho, just fyi! thanks for trying guys!

Nican
09-10-2007, 22:33
Hm... I tried this:

new test2;

public OnPluginStart()
{
RegConsoleCmd("test", Command_Test);

test2 = FindSendPropOffs("CBasePlayer","m_iFOV");
}

public Action:Command_Test(client ,argc){
SetEntData(client, test2, 145, 4, true);
}


I did change my view to something strange, but it did work...

SamuraiBarbi
09-10-2007, 23:07
OOO! That's perfect! Thank you so much!

SamuraiBarbi
09-25-2007, 07:56
Hey, I was looking around on the wiki and saw something interesting so I figured I'd ask how to properly use it. The page I found had all these different signatures on it and one is for setting a clients fov ( only for their duration on the server I'm assuming ).

http://wiki.alliedmods.net/Useful_Signatures_%28Source%29#CBasePlayer::S etFOV

I'm not exactly sure how to use it though. Can someone post an example?

Nican
09-25-2007, 16:08
http://forums.alliedmods.net/showthread.php?t=57448

You see there is supercmds.gamedata.txt file and this:
StartPrepSDKCall(SDKCall_Player)
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "SetModel")
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer)
hSetModel = EndPrepSDKCall()


Read a little from other people plugins so you can learn from it

SamuraiBarbi
09-25-2007, 17:13
http://forums.alliedmods.net/showthread.php?t=57448

You see there is supercmds.gamedata.txt file and this:
StartPrepSDKCall(SDKCall_Player)
PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "SetModel")
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer)
hSetModel = EndPrepSDKCall()
Read a little from other people plugins so you can learn from it

I tried doing something like that and it didn't work. I do alot of research on the forums, the wiki and looking through peoples plugins I think use what I'm looking for before I post questions. I posted because I'm stumped.

This was the km.mod gamedata I used

"Games"
{
"cstrike"
{
"Signatures"
{
"SetFOV"
{
"library" "server"
"windows" "\x53\x57\x8b\x7c\x24\x03\x85\xff\x8b\xd9\x75\ x07\x5f\x32\xc0\x5b\xc2\x0c\x00\x8b\x83\x08\x 0a\x00\x00\x83\xf8\xff\x56\x8d\xb3\x08\x0a\x0 0\x00"
"linux" "_ZN11CBasePlayer13SetDefaultFOVEi"
}
}
}
}
This was my code

#pragma semicolon 1

#include <sourcemod>
#include <clients>
#include <sdktools>
#include <sdktools_trace>

new Handle:hsetFOV;

public OnPluginStart()
{
HookEvent("player_spawn", HookPlayerSpawn, EventHookMode_Pre);
InitGameData();
}


public Action:HookPlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{

new userID = GetEventInt(event,"userid");
new user = GetClientOfUserId(userID);
SetFOV(user,145);
}
public Action:SetFOV(user,fov)
{
SDKCall(hsetFOV,user,fov);
}


InitGameData()
{
hgameConf = LoadGameConfigFile("km.mod");

StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(hgameConf, SDKConf_Signature, "SetFOV");
PrepSDKCall_AddParameter(SDKType_PlainOldData , SDKPass_Plain);
hsetFOV = EndPrepSDKCall();
}
It didn't work when I tried it. Can please someone post an example or lemme know what I'm doing wrong?

Nican
09-25-2007, 18:38
did you try use EventHookMode_Post on HookEvent
Because as far as I can understand, you setting his fov even before the player spawn

SamuraiBarbi
09-26-2007, 04:04
Alrighty I changed the EventHookMode_Pre to EventHookMode_Post and but nothing happens ingame. I should note also I don't receive any compiler errors.

sslice
10-02-2007, 00:50
You should use the SetEntData etc. instead of using signatures. It looks like Nican posted a working example.

SamuraiBarbi
10-02-2007, 02:43
His previous example, although it did work if I altered my fov and then changed weapons, my fov would reset.

EDIT: Found a way around the weapons thing so now I can just go with Nicans original solution to altering FOV. Thanks for the suggestions and all your help Nican!