Raised This Month: $ Target: $400
 0% 

KnifeModels Error


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
MayroN
Senior Member
Join Date: Aug 2017
Location: Kyiv
Old 05-24-2018 , 07:34   KnifeModels Error
Reply With Quote #1

Tell me how to fix the error

PHP Code:
L 05/24/2018 02:20:06Invalid cellvector handle provided (1:9:9
L 05/24/2018 02:20:06: [AMXXDisplaying debug trace (plugin "KnifeModels.amxx"
L 05/24/2018 02:20:06: [AMXXRun time error 10native error (native "ArrayGetArray"
L 05/24/2018 02:20:06: [AMXX] [0KnifeModels.sma::player_spawn (line 80
PHP Code:
public player_spawn(id

if(
is_user_bot(id) && get_pcvar_num(g_pAtSpawn) && !g_iKnife[id] && g_bFirstTime[id]) 

g_bFirstTime[id] = false 
new iRandom random_num(0g_iKnivesNum);
g_iKnife[id] = iRandom;
ArrayGetArray(g_aKnivesiRandomg_eKnife[id]);
OnSelectKnife(id);


All code
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <formatin>
#include <hamsandwich>

#define PLUGIN_VERSION "2.0"
#define DEFAULT_V "models/v_knife.mdl"
#define DEFAULT_P "models/p_knife.mdl"

enum
{
    
SOUND_NONE 0,
    
SOUND_DEPLOY,
    
SOUND_HIT,
    
SOUND_HITWALL,
    
SOUND_SLASH,
    
SOUND_STAB
}

enum _:Knives
{
    
NAME[32],
    
V_MODEL[128],
    
P_MODEL[128],
    
DEPLOY_SOUND[128],
    
HIT_SOUND[128],
    
HITWALL_SOUND[128],
    
SLASH_SOUND[128],
    
STAB_SOUND[128],
    
FLAG,
    
bool:HAS_CUSTOM_SOUND
}

new 
mcbTEST
new Array:g_aKnives,
    
bool:g_bFirstTime[33],
    
g_eKnife[33][Knives],
    
g_iKnife[33],
    
g_pAtSpawn,
    
g_iKnivesNum,
    
g_iSayText

public plugin_init()
{
    
register_plugin("Knife Models"PLUGIN_VERSION"OciXCrom")
    
register_cvar("CRXKnifeModels"PLUGIN_VERSIONFCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED)
    
    if(!
g_iKnivesNum)
        
set_fail_state("No knives found in the configuration file.")
    
    
register_dictionary("KnifeModels.txt")
    
    
register_event("CurWeapon""OnSelectKnife""be""1=1""2=29")
    
RegisterHam(Ham_CS_RoundRespawn"player""OnPlayerSpawn"1)
    
register_forward(FM_EmitSound,    "OnEmitSound")
    
    
register_clcmd("knife""ShowMenu")
    
    
g_pAtSpawn register_cvar("km_open_at_spawn""1")
    
g_iSayText get_user_msgid("SayText")
}

public 
client_authorized(id

if(
is_user_bot(id)) set_task(0.1"register_bot"id);

public 
register_bot(id

RegisterHamFromEntity(Ham_Spawnid"player_spawn"1


public 
player_spawn(id

if(
is_user_bot(id) && get_pcvar_num(g_pAtSpawn) && !g_iKnife[id] && g_bFirstTime[id]) 

g_bFirstTime[id] = false 
new iRandom random_num(0g_iKnivesNum);
g_iKnife[id] = iRandom;
ArrayGetArray(g_aKnivesiRandomg_eKnife[id]);
OnSelectKnife(id);

}

public 
client_connect(id)
{
        
client_cmd(id"bind ^"x^" ^"knife^"")     
    return 
PLUGIN_CONTINUE
}

public 
plugin_precache()
{
    
g_aKnives ArrayCreate(Knives)
    
ReadFile()
}

public 
plugin_end()
    
ArrayDestroy(g_aKnives)

ReadFile()
{
    new 
szConfigsName[256], szFilename[256]
    
get_configsdir(szConfigsNamecharsmax(szConfigsName))
    
formatex(szFilenamecharsmax(szFilename), "%s/KnifeModels.ini"szConfigsName)
    new 
iFilePointer fopen(szFilename"rt")
    
    if(
iFilePointer)
    {
        new 
szData[160], szKey[32], szValue[128]
        new 
eKnife[Knives]
        
        while(!
feof(iFilePointer))
        {
            
fgets(iFilePointerszDatacharsmax(szData))
            
trim(szData)
            
            switch(
szData[0])
            {
                case 
EOS';': continue
                case 
'[':
                {
                    if(
szData[strlen(szData) - 1] == ']')
                    {
                        if(
g_iKnivesNum)
                            
PushKnife(eKnife)
                            
                        
g_iKnivesNum++
                        
replace(szDatacharsmax(szData), "[""")
                        
replace(szDatacharsmax(szData), "]""")
                        
copy(eKnife[NAME], charsmax(eKnife[NAME]), szData)
                    }
                    else continue
                }
                default:
                {
                    
strtok(szDataszKeycharsmax(szKey), szValuecharsmax(szValue), '=')
                    
trim(szKey); trim(szValue)
                    
                    if(
equal(szKey"FLAG"))
                        
eKnife[FLAG] = read_flags(szValue)
                    else if(
equal(szKey"V_MODEL"))
                    {
                        
copy(eKnife[V_MODEL], charsmax(eKnife[V_MODEL]), szValue)
                        
precache_model(szValue)
                    }
                    else if(
equal(szKey"P_MODEL"))
                    {
                        
copy(eKnife[P_MODEL], charsmax(eKnife[P_MODEL]), szValue)
                        
precache_model(szValue)
                    }
                    else if(
equal(szKey"DEPLOY_SOUND"))
                    {
                        
eKnife[HAS_CUSTOM_SOUND] = true
                        copy
(eKnife[DEPLOY_SOUND], charsmax(eKnife[DEPLOY_SOUND]), szValue)
                        
precache_sound(szValue)
                    }
                    else if(
equal(szKey"HIT_SOUND"))
                    {
                        
eKnife[HAS_CUSTOM_SOUND] = true
                        copy
(eKnife[HIT_SOUND], charsmax(eKnife[HIT_SOUND]), szValue)
                        
precache_sound(szValue)
                    }
                    else if(
equal(szKey"HITWALL_SOUND"))
                    {
                        
eKnife[HAS_CUSTOM_SOUND] = true
                        copy
(eKnife[HITWALL_SOUND], charsmax(eKnife[HITWALL_SOUND]), szValue)
                        
precache_sound(szValue)
                    }
                    else if(
equal(szKey"SLASH_SOUND"))
                    {
                        
eKnife[HAS_CUSTOM_SOUND] = true
                        copy
(eKnife[SLASH_SOUND], charsmax(eKnife[SLASH_SOUND]), szValue)
                        
precache_sound(szValue)
                    }
                    else if(
equal(szKey"STAB_SOUND"))
                    {
                        
eKnife[HAS_CUSTOM_SOUND] = true
                        copy
(eKnife[STAB_SOUND], charsmax(eKnife[STAB_SOUND]), szValue)
                        
precache_sound(szValue)
                    }
                }
            }
        }
        
        if(
g_iKnivesNum)
            
PushKnife(eKnife)
        
        
fclose(iFilePointer)
    }
}

public 
client_putinserver(id)
{
    
g_bFirstTime[id] = true
    ArrayGetArray
(g_aKnives0g_eKnife[id])
    
g_iKnife[id] = 0
}

public 
OnEmitSound(idiChannel, const szSample[])
{
    if(!
is_user_connected(id) || !g_eKnife[id][HAS_CUSTOM_SOUND] || !is_knife_sound(szSample))
        return 
FMRES_IGNORED
    
    
switch(detect_knife_sound(szSample))
    {
        case 
SOUND_DEPLOY: if(g_eKnife[id][DEPLOY_SOUND][0]) { play_knife_sound(idg_eKnife[id][DEPLOY_SOUND][0]); return FMRES_SUPERCEDE; }
        case 
SOUND_HIT: if(g_eKnife[id][HIT_SOUND][0]) { play_knife_sound(idg_eKnife[id][HIT_SOUND][0]); return FMRES_SUPERCEDE; }
        case 
SOUND_HITWALL: if(g_eKnife[id][HITWALL_SOUND][0]) { play_knife_sound(idg_eKnife[id][HITWALL_SOUND][0]); return FMRES_SUPERCEDE; }
        case 
SOUND_SLASH: if(g_eKnife[id][SLASH_SOUND][0]) { play_knife_sound(idg_eKnife[id][SLASH_SOUND][0]); return FMRES_SUPERCEDE; }
        case 
SOUND_STAB: if(g_eKnife[id][STAB_SOUND][0]) { play_knife_sound(idg_eKnife[id][STAB_SOUND][0]); return FMRES_SUPERCEDE; }
    }
    
    return 
FMRES_IGNORED
}

public 
ShowMenu(id)
{
    new 
szTitle[128]
    
formatex(szTitlecharsmax(szTitle), "%L"id"KM_MENU_TITLE")
    
        
mcbTEST menu_makecallback("mcb_TEST")
    new 
iMenu menu_create(szTitle"MenuHandler")
    
    for(new 
eKnife[Knives], iFlags get_user_flags(id), ig_iKnivesNumi++)
    {
        
ArrayGetArray(g_aKnivesieKnife)
        
        if(
eKnife[FLAG] == ADMIN_ALL || iFlags eKnife[FLAG])
            
menu_additem(iMenuformatin("%s %s"eKnife[NAME], g_iKnife[id] == formatin(""id"") : formatin("")), eKnife[NAME], .callback mcbTEST)
        else
            
menu_additem(iMenuformatin(""eKnife[NAME], id""), eKnife[NAME], eKnife[FLAG], .callback mcbTEST)
    }
    
    if(
menu_pages(iMenu) > 1)
        
menu_setprop(iMenuMPROP_TITLEformatin("%s"szTitleid""))
    
        
menu_setprop(iMenuMPROP_PERPAGE0);     
    
menu_display(idiMenu)
    return 
PLUGIN_HANDLED
}

public 
mcb_TEST(idmenuitem)
{
if(
item == g_iKnife[id]) return ITEM_DISABLED

return ITEM_ENABLED
}

public 
MenuHandler(idiMenuiItem)
{
    if(
iItem != MENU_EXIT)
    {
        if(
g_iKnife[id] == iItem)
            
ColorChat(id"%L"id"")
        else
        {
            
g_iKnife[id] = iItem
            ArrayGetArray
(g_aKnivesiItemg_eKnife[id])
            
            if(
is_user_alive(id) && get_user_weapon(id) == CSW_KNIFE)
                
OnSelectKnife(id)
            
            new 
szName[32], iUnused
            menu_item_getinfo
(iMenuiItemiUnusedszNamecharsmax(szName), .callback iUnused)
            
ColorChat(id"%L"id"KM_CHAT_SELECTED"szName)
        }
    }
    
    
menu_destroy(iMenu)
    return 
PLUGIN_HANDLED
}

public 
OnPlayerSpawn(id)
{
    if(
is_user_alive(id) && get_pcvar_num(g_pAtSpawn) && !g_iKnife[id] && g_bFirstTime[id])
    {
        
g_bFirstTime[id] = false
        ShowMenu
(id)
    }
}

public 
OnSelectKnife(id)
{
    
set_pev(idpev_viewmodel2g_eKnife[id][V_MODEL])
    
set_pev(idpev_weaponmodel2g_eKnife[id][P_MODEL])
}

PushKnife(eKnife[Knives])
{
    if(!
eKnife[V_MODEL][0])
        
copy(eKnife[V_MODEL], charsmax(eKnife[V_MODEL]), DEFAULT_V)
        
    if(!
eKnife[P_MODEL][0])
        
copy(eKnife[P_MODEL], charsmax(eKnife[P_MODEL]), DEFAULT_P)
        
    
ArrayPushArray(g_aKniveseKnife)
}

bool:is_knife_sound(const szSample[])
    return 
bool:equal(szSample[8], "kni"3)

detect_knife_sound(const szSample[])
{
    static 
iSound
    iSound 
SOUND_NONE
    
    
if(equal(szSample"weapons/knife_deploy1.wav"))
        
iSound SOUND_DEPLOY
    
else if(equal(szSample[14], "hit"3))
        
iSound szSample[17] == 'w' SOUND_HITWALL SOUND_HIT
    
else if(equal(szSample[14], "sla"3))
        
iSound SOUND_SLASH
    
else if(equal(szSample[14], "sta"3))
        
iSound SOUND_STAB
        
    
return iSound
}

play_knife_sound(id, const szSound[])
    
engfunc(EngFunc_EmitSoundidCHAN_WEAPONszSound1.0ATTN_NORM0PITCH_NORM)
    
ColorChat(const id, const szInput[], any:...)
{
    new 
iPlayers[32], iCount 1
    
static szMessage[191]
    
vformat(szMessagecharsmax(szMessage), szInput3)
    
format(szMessage[0], charsmax(szMessage), "%L %s"id id LANG_PLAYER"KM_CHAT_PREFIX"szMessage)
    
    
replace_all(szMessagecharsmax(szMessage), "!g""^4")
    
replace_all(szMessagecharsmax(szMessage), "!n""^1")
    
replace_all(szMessagecharsmax(szMessage), "!t""^3")
    
    if(
id)
        
iPlayers[0] = id
    
else
        
get_players(iPlayersiCount"ch")
    
    for(new 
iiCounti++)
    {
        if(
is_user_connected(iPlayers[i]))
        {
            
message_begin(MSG_ONE_UNRELIABLEg_iSayText_iPlayers[i])
            
write_byte(iPlayers[i])
            
write_string(szMessage)
            
message_end()
        }
    }

Thanks a lot for your help
MayroN is offline
Send a message via ICQ to MayroN Send a message via Skype™ to MayroN
 


Thread Tools
Display Modes

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 04:37.


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