Junior Member
|
12-30-2020
, 08:56
[Problem] Model set
|
#1
|
So:
Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <fakemeta>
#define PLUGIN "knife menu"
#define VERSION "1.0"
#define AUTHOR "author"
new const choose[][] = {
"Classic Knives",
"VIP Knives"
}
enum _:Knives
{
Name,
bool:Special,
vModel,
pModel
}
//new _iData[Knives];
new knife_model[33];
new const knifeData[2][Knives][] =
{
{ "Classic Knife", false, "models/v_knife.mdl", "models/p_knife.mdl" },
{ "Test", true, "models/v_vip_katana.mdl", "models/p_knife.mdl" }
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say /knife", "ChooseMenu");
register_event("CurWeapon", "CurWeapon", "be", "1=1");
}
public plugin_precache()
{
for(new i; i < sizeof(knifeData); i++)
{
precache_model(knifeData[i][vModel]);
precache_model(knifeData[i][pModel]);
}
}
public ChooseMenu(id)
{
if(!is_user_connected(id))
return PLUGIN_CONTINUE
new menu = menu_create("\wKnife Menu", "ChooseMenuH");
for(new i; i < sizeof(choose); i++)
{
new _choose[512];
formatex(_choose, charsmax(_choose), "%s", choose[i]);
menu_additem(menu, _choose);
}
menu_display(id, menu);
return PLUGIN_CONTINUE;
}
public ChooseMenuH(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_CONTINUE;
}
switch(item)
{
case 0: ClassicKnivesMenu(id);
case 1:
{
if(get_user_flags(id) & ADMIN_LEVEL_H)
VIPKnivesMenu(id);
else
ColorChat(id, GREEN, "[Knife] ^1You don't have access to this menu.");
}
}
return PLUGIN_CONTINUE;
}
public ClassicKnivesMenu(id)
{
if(!is_user_connected(id))
return PLUGIN_CONTINUE;
new menu = menu_create("\wClassic Knives", "ClassicKnivesMenuH");
new new_menu[64];
for(new i; i < sizeof(knifeData); i++)
{
if(knifeData[i][Special][0] == 0)
{
formatex(new_menu, charsmax(new_menu), "%s", knifeData[i][Name]);
menu_additem(menu, new_menu);
}
}
menu_display(id, menu);
return PLUGIN_CONTINUE;
}
public ClassicKnivesMenuH(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_CONTINUE;
}
new command[6], name[64], access, callback;
menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);
SetKnife(id, item);
ColorChat(id, GREEN, "Set");
menu_destroy(menu);
return PLUGIN_CONTINUE;
}
public VIPKnivesMenu(id)
{
if(!is_user_connected(id))
return PLUGIN_CONTINUE;
new menu = menu_create("\wVIP Knives", "VIPKnivesMenuH");
new new_menu[64];
for(new i; i < sizeof(knifeData); i++)
{
if(knifeData[i][Special][0] == 1)
{
formatex(new_menu, charsmax(new_menu), "%s", knifeData[i][Name]);
menu_additem(menu, new_menu);
}
}
menu_display(id, menu);
return PLUGIN_CONTINUE;
}
public VIPKnivesMenuH(id, menu, item)
{
if(item == MENU_EXIT)
{
menu_destroy(menu);
return PLUGIN_CONTINUE;
}
new command[6], name[64], access, callback;
menu_item_getinfo(menu, item, access, command, sizeof command - 1, name, sizeof name - 1, callback);
SetKnife(id, item);
ColorChat(id, GREEN, "VIP Set");
menu_destroy(menu);
return PLUGIN_CONTINUE;
}
public SetKnife(id, knife)
{
new clip, ammo, weapon = get_user_weapon(id, clip, ammo);
if(weapon != CSW_KNIFE)
return;
knife_model[id] = knife;
new v_Model[56];
new p_Model[56];
format(v_Model, 55, knifeData[knife][vModel]);
format(p_Model, 55, knifeData[knife][pModel]);
set_pev(id, pev_viewmodel2, v_Model)
set_pev(id, pev_weaponmodel2, p_Model)
}
public CurWeapon(id)
{
SetKnife(id, knife_model[id]);
}
This is the first problem I've encountered in years, and uhm I don't exactly know what's wrong here, am I blind that I can't see the problem or is it just wrong like this (I have one mod I made on this writing and it's working fine and this part of the code isn't for some reason).
So let's go straight to the problem. The problem is that when I choose knife model I wanna set on me (in this case Test), it doesn't work. I tried to see, is the function even working at all (Set / VIP Set) and it seems it works, so I guess the problem is in SetKnife or that I didn't add something very important which it seems I can't guess what it is. So yeah in short setting model on a knife isn't working.
Code:
public SetKnife(id, knife)
{
new clip, ammo, weapon = get_user_weapon(id, clip, ammo);
if(weapon != CSW_KNIFE)
return;
knife_model[id] = knife;
new v_Model[56];
new p_Model[56];
format(v_Model, 55, knifeData[knife][vModel]);
format(p_Model, 55, knifeData[knife][pModel]);
set_pev(id, pev_viewmodel2, v_Model)
set_pev(id, pev_weaponmodel2, p_Model)
}
public CurWeapon(id)
{
SetKnife(id, knife_model[id]);
}
Btw I was doing some tests and I wrote this literally like 30m ago and it surprised me that it isn't working whatever I try, so that's why I'm curious what is the problem here. Would mean a lot if someone could explain
Last edited by Ognjen7; 12-30-2020 at 09:02.
|
|