AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Proplem with setting view model (https://forums.alliedmods.net/showthread.php?t=172134)

Explas 11-15-2011 23:18

Proplem with setting view model
 
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"))
}
}

}

ConnorMcLeod 11-16-2011 01:22

Re: Proplem with setting view model
 
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.

Explas 11-16-2011 07:21

Re: Proplem with setting view model
 
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?

mrhellish 11-16-2011 08:18

Re: Proplem with setting view model
 
try with CurWeapon :) and add check:
new wpn = read_data(2);
if (wpn!=get_user_weapon(id)) return;
:)

drekes 11-16-2011 10:58

Re: Proplem with setting view model
 
Quote:

Originally Posted by mrhellish (Post 1597376)
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.

mrhellish 11-16-2011 11:19

Re: Proplem with setting view model
 
Quote:

Originally Posted by drekes (Post 1597466)
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..

drekes 11-16-2011 11:22

Re: Proplem with setting view model
 
Quote:

Originally Posted by mrhellish (Post 1597477)
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.

Explas 11-16-2011 18:23

Re: Proplem with setting view model
 
But... does the ham_item_deploy run when i toggle zooming on/off ?

ConnorMcLeod 11-17-2011 00:02

Re: Proplem with setting view model
 
Hook Fov event then, with right filters.

Explas 11-17-2011 07:55

Re: Proplem with setting view model
 
Quote:

Originally Posted by ConnorMcLeod (Post 1597911)
Hook Fov event then, with right filters.

er.. how to hook? Sorry because i'm new to amx


All times are GMT -4. The time now is 08:29.

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