Leave the version or which mod i use.
When I replace "g_ChosenMenu -> iPlayer" it works but not showing the model but the points go down and I get a message in the chat Iam bought this model.
Code:
#include <amxmodx>
#include <cstrike>
#define COLORCHAT
#if defined COLORCHAT
#include <colorchat>
#endif
#if !defined MAX_MENU_LENGTH
const MAX_MENU_LENGTH = 512
#endif
#if !defined MAX_PLAYERS
const MAX_PLAYERS = 32
#endif
native zp_get_user_zombie(id);
native zp_get_user_zp_points(id);
native zp_set_user_zp_points( iPlayer, iPacks );
enum HumanModel {
MODEL_NAME[ MAX_PLAYERS + 1 ],
MODEL_COST,
MODEL_FLAG
}
// Model Name , Model Cost, Model Flag
new const g_HumanModel[][HumanModel] = {
{ "admin1", 10, ADMIN_LEVEL_A },
{ "admin2", 20, ADMIN_LEVEL_B },
{ "admin3", 30, ADMIN_LEVEL_C },
{ "admin4", 40, ADMIN_LEVEL_D },
{ "admin5", 50, ADMIN_LEVEL_E },
{ "admin6", 60, ADMIN_LEVEL_F }
}
new const SayHumanModel[][] = {
"say /hm",
"say_team /humanmodel",
"say hm",
"say_team humanmodel"
};
new bool:g_HasModel[MAX_PLAYERS + 1]
new const g_szPrefix[] = "ZP";
new g_iModelName[ MAX_PLAYERS + 1 ] = 0;
new g_iModelCost[ MAX_PLAYERS + 1 ] = 0;
public plugin_init() {
register_plugin("HumanModelShop", "0.0.1", "Supremache")
for(new i = 0; i < sizeof(SayHumanModel); i++)
register_clcmd(SayHumanModel[i], "CustomShopHuman");
}
public plugin_precache() {
new szBuffer[64];
for(new i; i < sizeof( g_HumanModel ); i++) {
formatex(szBuffer, charsmax(szBuffer), "models/player/%s/%s.mdl", g_HumanModel[i][MODEL_NAME], g_HumanModel[i][MODEL_NAME]);
precache_model(szBuffer);
}
}
public CmdHumanModelMenu(id)
{
if( !zp_get_user_zombie(id) )
CustomShopHuman(id)
else
Print(id, "This is only available to humans.");
return PLUGIN_HANDLED;
}
public CustomShopHuman(id)
{
new g_iMainMenu,
szData[MAX_MENU_LENGTH],
iPoints = zp_get_user_zp_points(id),
iFlags = get_user_flags(id);
formatex(szData, charsmax(szData), "\yHuman Model\r: ^n\yPoint\r: %d", iPoints)
g_iMainMenu = menu_create(szData, "HumanModelShop")
for(new i; i < sizeof( g_HumanModel ); i++) {
formatex(szData, charsmax(szData), "%s%s \rCost:\y%d", iFlags & g_HumanModel[i][MODEL_FLAG] ? "\w" : "\d", g_HumanModel[i][MODEL_NAME], g_HumanModel[i][MODEL_COST])
menu_additem(g_iMainMenu, szData, "")
}
menu_setprop(g_iMainMenu, MPROP_BACKNAME, "Previous page")
menu_setprop(g_iMainMenu, MPROP_NEXTNAME, "Next page")
menu_setprop(g_iMainMenu, MPROP_EXITNAME, "\rClose")
menu_setprop(g_iMainMenu, MPROP_EXIT, MEXIT_ALL)
menu_display(id, g_iMainMenu)
return PLUGIN_HANDLED;
}
public HumanModelShop(iPlayer, iMenu, iItem)
{
if(iItem != MENU_EXIT) {
new iAccess,
szData[6],
szName[32],
iCallback,
g_ChosenMenu,
iPoints,
iFlags = get_user_flags(iPlayer);
menu_item_getinfo(iMenu, iItem, iAccess, szData, charsmax(szData), szName, charsmax(szName), iCallback);
g_ChosenMenu = str_to_num(szData)
iPoints = zp_get_user_zp_points(iPlayer) - g_HumanModel[g_ChosenMenu][MODEL_COST]
if ( zp_get_user_zp_points(iPlayer) < g_HumanModel[g_ChosenMenu][MODEL_COST]) {
Print(iPlayer, "You don't have enough points to this model!");
menu_destroy(iMenu)
return PLUGIN_HANDLED;
}
else {
if( g_HasModel[g_ChosenMenu] ) {
Print(g_ChosenMenu, "You already have bought this model!");
menu_destroy(iMenu)
return PLUGIN_HANDLED;
}
g_iModelName[ g_ChosenMenu ] = g_HumanModel[iItem][MODEL_NAME]
g_iModelCost[ g_ChosenMenu ] = g_HumanModel[iItem][MODEL_COST]
if( iFlags & g_HumanModel[ g_ChosenMenu ][MODEL_FLAG] ) {
zp_set_user_zp_points( g_ChosenMenu, iPoints)
cs_set_user_model( g_ChosenMenu, g_HumanModel[ g_ChosenMenu ][MODEL_NAME]);
g_HasModel[g_ChosenMenu] = true;
Print( g_ChosenMenu , "You have bought^04 %s^01.", g_HumanModel[ g_ChosenMenu ][MODEL_NAME]);
}
else Print( g_ChosenMenu , "You dont have access to buy this model!");
}
}
menu_destroy(iMenu);
return PLUGIN_HANDLED;
}
Print(id, const szMessage[], any:...)
{
static szBuffer[192];
vformat(szBuffer, charsmax(szBuffer), szMessage, 3);
#if defined COLORCHAT
ColorChat(id, GREEN, "[%s]^01 %s", g_szPrefix, szBuffer);
#else
replace_all(szBuffer, charsmax(szBuffer), "^01", "");
replace_all(szBuffer, charsmax(szBuffer), "^03", "");
replace_all(szBuffer, charsmax(szBuffer), "^04", "");
client_print(id, print_chat, "[%s] %s", g_szPrefix, szBuffer);
#endif
}