Raised This Month: $ Target: $400
 0% 

Change Knife Model With Player Model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zombie Lurker
Senior Member
Join Date: Mar 2009
Old 05-21-2009 , 08:33   Change Knife Model With Player Model
Reply With Quote #1

Hey everyone. I need help with this plugin I'm making. Here's what I have so far.

Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
#include <fakemeta>
#include <zombieplague>
new const model_weapon_view[] = "models/zombie_plague/hands5.mdl"
new const model_weapon_view2[] = "models/zombie_plague/girl_knife.mdl"
public plugin_init() {
 register_plugin("Zombie Knife Model","0.1","Zombie Lurker")
 register_event("CurWeapon", "event_curweapon", "be", "1=1")
}
public plugin_precache() {
 engfunc(EngFunc_PrecacheModel, model_weapon_view)
 engfunc(EngFunc_PrecacheModel, model_weapon_view2)
}
public event_curweapon(id) {
 new weaponID = read_data(2)
 if (zp_get_user_zombie(id) && is_user_alive(id) && weaponID != CSW_HEGRENADE) {
  new usermodel[33]
  cs_get_user_model(id, usermodel,32)
 
  usermodel[32] = strtolower(usermodel)
 
  if(containi(usermodel, "zombi_host")) {
  set_pev(id, pev_viewmodel2, model_weapon_view)
  } else if(containi(usermodel, "zombi_origin")) {
  set_pev(id, pev_viewmodel2, model_weapon_view)
  } else if(containi(usermodel, "speed_zombi_host")) {
   set_pev(id, pev_viewmodel2, model_weapon_view2)
  } else if(containi(usermodel, "speed_zombi_origin")) {
   set_pev(id, pev_viewmodel2, model_weapon_view2)
  }
 }
}
This code has a problem. It only changes the knife to the first model (hands5.mdl). Can someone help me to modify the code to work with the second model? E.G. I am the speed_zombi_host or speed_zombi_origin model but it doesnt change the knife model to girl_knife.mdl
I tried changing containi to equali but it doesnt work. All help accepted! And the code doesnt need to be converted because I'm not releasing this... but you can convert if you want.
__________________

Last edited by Zombie Lurker; 05-21-2009 at 08:39.
Zombie Lurker is offline
kernelInspired
Junior Member
Join Date: Apr 2009
Old 06-08-2009 , 06:36   Re: Change Knife Model With Player Model
Reply With Quote #2

Hey, "containi()" definition says: function returns -1 value on failure, not 0.

Look at the first "if" block:
"if(containi(usermodel, "zombi_host"))" equals to "if(-1)"
so "if" body will be executed, and all further "else if" will be skipped.

You have to compare "containi()" return value to -1 explicitly.

Why not to define an array, with "usermodels" as indexes, and "model_weapon_view(2)" as values? ("zombi_host", "zombi_origin" are constants, I guess)
In this case, it is possible to switch to 1-2 commands(check array index is present and fetch that value) instead of annoying "if-else" blocks.
Array values can be loaded from file(s) also, so you don't need to modify source code when you want new model(s)


"containti()" is case insensitive, you don't need to "strtolower(usermodel)", until "contain()" is preferred.


Cheers.
kernelInspired is offline
Reply



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 01:26.


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