Raised This Month: $ Target: $400
 0% 

Proplem with setting view model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Explas
Junior Member
Join Date: Nov 2009
Old 11-15-2011 , 23:18   Proplem with setting view model
Reply With Quote #1

Hi, everyone
Today i'm trying to make dotsight for the aug, it worked, however, when i switch to another weapon, its view model is set to the aug!
Can anyone fix it for me?
Here is the code:
[php]
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#include <fakemeta>
#include <fakemeta_util>
#include <engine>
#include <hamsandwich>

#define PLUGIN "Scope Dot"
#define VERSION "1.0"
#define AUTHOR "Explas"


public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_PlayerPreThink, "PlayerPreThink")

// Add your code here...
}
/[php]
public plugin_precache()
{
precache_model("models/v_aug_scope.mdl")
precache_model("models/v_aug.mdl")
}

public PlayerPreThink(id)
{
if( get_user_weapon(id) == CSW_AUG)
{
if( cs_get_user_zoom(id) == CS_SET_AUGSG552_ZOOM)
{
set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, "models/v_aug_scope.mdl"))
}
if( cs_get_user_zoom(id) == CS_SET_NO_ZOOM)
{

set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, "models/v_aug.mdl"))
}
}

}

Last edited by Explas; 11-15-2011 at 23:22.
Explas is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-16-2011 , 01:22   Re: Proplem with setting view model
Reply With Quote #2

Don't use PlayerPreThink to set a model.
Use rather Ham_Item_Deploy POST registered.

Also, if you don't cache AllocString string model, use directly the string with pev_viewmodel2 instead pev_viewmodel.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Explas
Junior Member
Join Date: Nov 2009
Old 11-16-2011 , 07:21   Re: Proplem with setting view model
Reply With Quote #3

But i want to change the model when the player is using scope, does ham_item_deploy only run when the player pick up a weapon?
Explas is offline
mrhellish
Junior Member
Join Date: Jun 2010
Old 11-16-2011 , 08:18   Re: Proplem with setting view model
Reply With Quote #4

try with CurWeapon and add check:
new wpn = read_data(2);
if (wpn!=get_user_weapon(id)) return;
mrhellish is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-16-2011 , 10:58   Re: Proplem with setting view model
Reply With Quote #5

Quote:
Originally Posted by mrhellish View Post
try with CurWeapon and add check:
new wpn = read_data(2);
if (wpn!=get_user_weapon(id)) return;
That doesn't make any sense.
Your statement will always be false IIRC.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 11-16-2011 at 10:59. Reason: I was wrong :p
drekes is offline
Send a message via MSN to drekes
mrhellish
Junior Member
Join Date: Jun 2010
Old 11-16-2011 , 11:19   Re: Proplem with setting view model
Reply With Quote #6

Quote:
Originally Posted by drekes View Post
That doesn't make any sense.
Your statement will always be false IIRC.
nope ;) if you pick up the weapon the current weapon and the weapon in the event CurWeapon are different..

Last edited by mrhellish; 11-16-2011 at 11:20.
mrhellish is offline
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 11-16-2011 , 11:22   Re: Proplem with setting view model
Reply With Quote #7

Quote:
Originally Posted by mrhellish View Post
nope ;) if you pick up the weapon the current weapon and the weapon in the event CurWeapon are different..
And how does that help OP ?

Best thing is to use ConnorMcLeod's method.
__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.
drekes is offline
Send a message via MSN to drekes
Explas
Junior Member
Join Date: Nov 2009
Old 11-16-2011 , 18:23   Re: Proplem with setting view model
Reply With Quote #8

But... does the ham_item_deploy run when i toggle zooming on/off ?
Explas is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-17-2011 , 00:02   Re: Proplem with setting view model
Reply With Quote #9

Hook Fov event then, with right filters.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Explas
Junior Member
Join Date: Nov 2009
Old 11-17-2011 , 07:55   Re: Proplem with setting view model
Reply With Quote #10

Quote:
Originally Posted by ConnorMcLeod View Post
Hook Fov event then, with right filters.
er.. how to hook? Sorry because i'm new to amx
Explas is offline
Reply


Thread Tools
Display Modes

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 08:29.


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