AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Custom weapon models (https://forums.alliedmods.net/showthread.php?t=25928)

M4Maniac 03-23-2006 19:42

Custom weapon models
 
Code:

#include <amxmodx>
#include <engine> // this plugin requires Engine

public plugin_init()
{
register_plugin("oh hello" , "1.0" , "v3x");
register_event("CurWeapon" , "set_models" , "be" , "1=1"); // if we don't check for the isActive parameter then the skins will act up and change unexpectedly on you (if 0)
}
public plugin_precache()
{
precache_model("models/v_newdeag.mdl"); // the view model
precache_model("models/p_newdeag.mdl"); // the player (view) model
}

public set_models(id)
{
if(!is_user_alive(id)) // if the player is dead for some reason, prevent the rest of the function from being executed
{
return PLUGIN_HANDLED;
}

new weapid = read_data(2); // get the weapon ID
switch(weapid)
{
case CSW_DEAGLE: // check if it's the weapon ID we want (see below for weapon constants)
{
entity_set_string(id , EV_SZ_viewmodel , "models/v_newdeag.mdl"); // set the view model
entity_set_string(id , EV_SZ_weaponmodel , "models/p_newdeag.mdl"); // set the player (view) model
}
}
return PLUGIN_CONTINUE;
}

Thats what i have

heres what i did:
1) Make that plugin an SMA

2) Compile it with AMXX Compiler

3) Got my Model for the deagle and replaced it with the old one

4) Put my plugin in my plugins folder

5) Added it to plugins.ini

6) Restarted my server

7) Tried to use it but it didn't work....

What am I doing wrong?
[/code]

akysiev 03-24-2006 07:20

I had a similar problem and resorted to using get_user_weapon instead of reading the message data.

Replace

Code:
new weapid = read_data(2); // get the weapon ID

with

Code:
new clip, ammo, weapid = get_user_weapon(id, clip, ammo);

M4Maniac 03-24-2006 08:48

okay i did that but when i try to compile i get these errors:
Code:
/home/users/amxmodx/tmp3/texthwctJ8.sma(23) : error 029: invalid expression, assumed zero /home/users/amxmodx/tmp3/texthwctJ8.sma(23) : warning 215: expression has no effect /home/users/amxmodx/tmp3/texthwctJ8.sma(34) : warning 203: symbol is never used: "clip" 1 Error. Could not locate output file /home/groups/amxmodx/public_html/websc3/texthwctJ8.amx (compile failed).

[ --<-@ ] Black Rose 03-24-2006 08:53

how can you fail replacing one line? dear man, try again.

M4Maniac 03-24-2006 09:40

Okay i got it to compile but the plugin still isnt working..

[ --<-@ ] Black Rose 03-24-2006 15:04

well i can't se any errors, what exactly did you do with the files? what are they named? in wich directory?

M4Maniac 03-24-2006 18:25

Okay i will tell you what i just did:
Code:
#include <amxmodx> #include <engine> // this plugin requires Engine public plugin_init() { register_plugin("oh hello" , "1.0" , "v3x"); register_event("CurWeapon" , "set_models" , "be" , "1=1"); // if we don't check for the isActive parameter then the skins will act up and change unexpectedly on you (if 0) } public plugin_precache() { precache_model("models/v_glock18.mdl"); // the view model precache_model("models/p_glock18.mdl"); // the player (view) model } public set_models(id) { if(!is_user_alive(id)) // if the player is dead for some reason, prevent the rest of the function from being executed { return PLUGIN_HANDLED; } new clip, ammo, weapid = get_user_weapon(id, clip, ammo); switch(weapid) { case CSW_DEAGLE: // check if it's the weapon ID we want (see below for weapon constants) { entity_set_string(id , EV_SZ_viewmodel , "models/v_glcok18.mdl"); // set the view model entity_set_string(id , EV_SZ_weaponmodel , "models/p_glcok18.mdl"); // set the player (view) model } } return PLUGIN_CONTINUE; }

1) I took the files i dled and i put my p_glock18, v_glock18, and w_glock18 in the Models folder.

2) I took the plugin and placed it in my plugins folder

3) i edited the plugins.ini

v3x 03-24-2006 19:30

God, just use the web compiler.

M4Maniac 03-24-2006 19:49

I did but i still get no result do i have to type something when in console in the game to get it to work?

v3x 03-24-2006 20:04

Quote:

models/v_glock18.mdl
models/p_glock18.mdl
Won't work because those are the names of the default model files. Rename them or move them to a different directory.


All times are GMT -4. The time now is 16:45.

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