Raised This Month: $32 Target: $400
 8% 

Solved [Bug] Human models shop


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-04-2020 , 12:10   [Bug] Human models shop
Reply With Quote #1

I'm have made plugin for human models shop but i have bug when i buy skin not shows!!




Code:
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);     } }
Code:
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; }

The bug is here, but i dont know the solve :
Code:
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!");                     }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 11-05-2020 at 19:34.
Supremache is offline
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 11-04-2020 , 18:28   Re: [Bug] Human models shop
Reply With Quote #2

ZP Version ?
__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'
r0ma is offline
Send a message via MSN to r0ma
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-04-2020 , 18:54   Re: [Bug] Human models shop
Reply With Quote #3

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.



Here is the bug:
PHP Code:
}
        else {
            if( 
g_HasModel[g_ChosenMenu] ) {
                Print(
g_ChosenMenu"You already have bought this model!");
                
menu_destroy(iMenu)
                return 
PLUGIN_HANDLED;
            }
            
                
g_iModelNameg_ChosenMenu ] = g_HumanModel[iItem][MODEL_NAME]
            
g_iModelCostg_ChosenMenu ] = g_HumanModel[iItem][MODEL_COST]
            
            if( 
iFlags g_HumanModelg_ChosenMenu ][MODEL_FLAG] ) {
                
zp_set_user_zp_pointsg_ChosenMenuiPoints)
                
cs_set_user_modelg_ChosenMenug_HumanModelg_ChosenMenu ][MODEL_NAME]);
                
g_HasModel[g_ChosenMenu] = true;
                Print( 
g_ChosenMenu "You have bought^04 %s^01."g_HumanModelg_ChosenMenu ][MODEL_NAME]);
            }
            else Print( 
g_ChosenMenu "You dont have access to buy this model!");
            
        } 
Full Plugin:
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 }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 11-04-2020 at 18:56.
Supremache is offline
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 11-04-2020 , 21:42   Re: [Bug] Human models shop
Reply With Quote #4

try with:

PHP Code:
/**
 * Overrides ZP player model with a different custom model.
 *
 * Note: This will last until player's next infection/humanization/respawn.
 *
 * Note: Don't call more often than absolutely needed.
 *
 * @param id        Player index.
 * @param newmodel    Model name.
 * @param modelindex    Modelindex (optional).
 */
native zp_override_user_model(id, const newmodel[], modelindex 0
__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'
r0ma is offline
Send a message via MSN to r0ma
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-05-2020 , 16:29   Re: [Bug] Human models shop
Reply With Quote #5

Quote:
Originally Posted by r0ma View Post
try with:

PHP Code:
/**
 * Overrides ZP player model with a different custom model.
 *
 * Note: This will last until player's next infection/humanization/respawn.
 *
 * Note: Don't call more often than absolutely needed.
 *
 * @param id        Player index.
 * @param newmodel    Model name.
 * @param modelindex    Modelindex (optional).
 */
native zp_override_user_model(id, const newmodel[], modelindex 0
It's human shop so should when i buy model i get it but in this native the model will load when i get respawn or die etc

Quote:
This will last until player's next infection/humanization/respawn.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
r0ma
Senior Member
Join Date: Apr 2012
Location: Great Tomb of Nazarick
Old 11-05-2020 , 18:39   Re: [Bug] Human models shop
Reply With Quote #6

try:

PHP Code:
public HumanModelShop(iPlayeriMenuiItem)
{
    
menu_destroy(menu);
    
    if(
iItem == MENU_EXIT)
        return;
    
    new 
iPoints zp_get_user_zp_points(iPlayer);
            
    if(
iPoints g_HumanModel[g_ChosenMenu][MODEL_COST]) {
        Print(
iPlayer"You don't have enough points to this model!");
        
        return;
    }
    
    if( 
g_HasModel[iPlayer] ) {
        Print(
iPlayer"You already have bought this model!");
        return;
    }
    
    
//??
    
g_iModelNameiPlayer ] = g_HumanModel[iItem][MODEL_NAME];
    
g_iModelCostiPlayer ] = g_HumanModel[iItem][MODEL_COST];
    
    if(
get_user_flags(id) & g_HumanModel[iPlayer][MODEL_FLAG]) {
        
zp_set_user_zp_points(iPlayeriPoints g_HumanModel[iItem][MODEL_COST]);
        
cs_set_user_model(iPlayerg_HumanModel[iItem][MODEL_NAME]);
        
g_HasModel[iPlayer] = true;
        Print(
iPlayer "You have bought^04 %s^01."g_HumanModel[iItem][MODEL_NAME]);
    }
    else 
        Print(
iPlayer "You dont have access to buy this model!");

__________________
Discord:FluffyDeveloper#4753
Github: https://github.com/francoromaniello
AMX-ES: https://amxmodx-es.com/r0ma'
r0ma is offline
Send a message via MSN to r0ma
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-05-2020 , 19:34   Re: [Bug] Human models shop
Reply With Quote #7

@r0ma - Thanks for help but it still not working but i got the idea from your codes and i fixed it

Code:
public HumanModelShop(id, iMenu, iItem) {     if(iItem != MENU_EXIT) {         new iAccess, iCallBack, szDate[11];         menu_item_getinfo(iMenu, iItem, iAccess, szDate, charsmax(szDate), _, _, iCallBack);                 new iPoints = zp_get_user_zp_points(iPlayer);             if(iPoints < g_HumanModel[iItem][MODEL_COST]) {             Print(id, "You don't have enough points to this model!");                     return;         }             if( g_HasModel[id] ) {             Print(id, "You already have bought this model!");             return;         }                 if( get_user_flags(id) & g_HumanModel[iItem][MODEL_FLAG]) {             zp_set_user_zp_points(id, iPoints - g_HumanModel[iItem][MODEL_COST]);             cs_set_user_model(id, g_HumanModel[iItem][MODEL_NAME]);             g_HasModel[id] = true;             Print(id , "You have bought^04 %s^01.", g_HumanModel[iItem][MODEL_NAME]);         }         else             Print(id , "You dont have access to buy this model!");     }     menu_destroy(iMenu); }
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache 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 09:39.


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