AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting Array from Array (https://forums.alliedmods.net/showthread.php?t=224987)

Kia 08-30-2013 13:11

Getting Array from Array
 
Hello everybody,

I've made a API using this tutorial from Exolent and want to get the data from the selected Item in menu, but I always get these errors

Code:

L 08/30/2013 - 19:05:08: Invalid cellvector handle provided (7:2:1)
L 08/30/2013 - 19:05:08: [AMXX] Displaying debug trace (plugin "lol_core.amxx")
L 08/30/2013 - 19:05:08: [AMXX] Run time error 10: native error (native "ArrayGetArray")
L 08/30/2013 - 19:05:08: [AMXX]    [0] lol_core.sma::_set_hero (line 200)
L 08/30/2013 - 19:05:08: Unhandled dynamic native error
L 08/30/2013 - 19:05:08: [AMXX] Displaying debug trace (plugin "lol_hero_kia.amxx")
L 08/30/2013 - 19:05:08: [AMXX] Run time error 10: native error (native "lol_set_hero")
L 08/30/2013 - 19:05:08: [AMXX]    [0] lol_hero_kia.sma::hero_selected (line 45)

Affected Code

PHP Code:

// ===============================================================================
//     hero_selected - Gets called a Hero gets selected
// ===============================================================================

public hero_selected(idiHeroIndex)
{
    if(
g_iHeroIndex == iHeroIndex)
        
lol_set_hero(idg_iHeroIndex// This line


PHP Code:

// ===============================================================================
//     _set_hero - Sets hero to player
// ===============================================================================

public _set_hero(idiHeroIndex)
{
    new 
eItemData[HeroData]

    
ArrayGetArray(g_aHeroesiHeroIndexeItemData// this line
    
    
formatex(g_szHeroName[id], charsmax(g_szHeroName), eItemData[HeroName])
    
formatex(g_szHeroType[id], charsmax(g_szHeroType), eItemData[HeroType])
    
    
g_flBaseDamage[id]         = eItemData[BaseDamage]
    
g_flBaseAbilityPower[id]     = eItemData[BaseAbilityPower
    
g_flBaseArmor[id]         = eItemData[BaseArmor]
    
g_flBaseMagicResist[id]     = eItemData[BaseMagicResist]
    
g_flBaseHealth[id]         = eItemData[BaseHealth
    
g_flBaseMana[id]                = eItemData[BaseMana]
    
g_flBaseLifeSteal[id]         = eItemData[BaseLifeSteal]
    
g_flBaseSpellVamp[id]         = eItemData[BaseSpellVamp
    
g_flBaseCooldown[id]         = eItemData[BaseCooldown]
    
g_flBaseHealthRegen[id]     = eItemData[BaseHealthRegen]
    
g_flBaseManaRegen[id]        = eItemData[BaseManaRegen]
    
g_flBaseCritChance[id]         = eItemData[BaseCritChance]
    
g_flBaseRange[id]         = eItemData[BaseRange]


Anyone knows what I'm doing wrong?

UchihaSkills 08-30-2013 13:33

Re: Getting Array from Array
 
all

Kia 08-30-2013 13:36

Re: Getting Array from Array
 
Quote:

Originally Posted by UchihaSkills (Post 2018074)
send me the thread where i spammed you pls ?

You're not helpful.

Smatify 08-30-2013 13:39

Re: Getting Array from Array
 
Quote:

Originally Posted by UchihaSkills (Post 2024868)
all

that's a nasty answer :D

Black Rose 08-30-2013 13:43

Re: Getting Array from Array
 
Does ArrayGetArray() support enum-arrays?

Kia 08-30-2013 13:45

Re: Getting Array from Array
 
It seems to work at the Menu like in the tutorial

PHP Code:

new eItemData[HeroData]
    new 
szItem[128]
    
    new 
szNum[3]
    
    for(new 
0g_iTotalHeroesi++)
    {
        
ArrayGetArray(g_aHeroesieItemData)
        
        
formatex(szItemcharsmax(szItem), "%s | %s"eItemData[HeroName], eItemData[HeroType]) 


Arkshine 08-30-2013 13:47

Re: Getting Array from Array
 
Kia, for someone who is supposed to know how to code, it seems you have not tried to search.

You see that :Invalid cellvector handle provided (7:2:1), why you don't even try to figure out what it means ?!

If you don't know, you just search.
So, go to amxx source and search "Invalid cellvector handle provided", you find something like :

LogError(amx, AMX_ERR_NATIVE, "Invalid cellvector handle provided (%d:%d:%d)", params[1], params[2], vec->Size());

Now, you know what each values are, it's easy to understand :

- Your handle is valid
- You're passing 2 as index
- Size of array : 1

Conclusion : You're passing an index above the size of the array, meaning you get an out of bound error. Basically your code sucks, and you should check the code.

Kia 08-30-2013 13:58

Re: Getting Array from Array
 
I've tried to search, but I didn't understand that, thats why I ask.
But how could the index be 2 when I only register 1 item?

Arkshine 08-30-2013 14:08

Re: Getting Array from Array
 
You don't show all the code.

Kia 08-30-2013 14:15

Re: Getting Array from Array
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <fun>

#define PLUGIN "League of Legends Mod - Core"
#define VERSION "1.0.0"
#define AUTHOR "Kia"

// ===============================================================================
//     Notes from DevTeam (Kia)
// ===============================================================================

#define GOLD_NORMAL 300
#define GOLD_KILLINGSPREE 425
#define GOLD_RAMPAGE 500

// ===============================================================================
//     Variables
// ===============================================================================

/* Defines */

#define VGUI_SELECT_TEAM        2

/* Enums */

enum ( += 1000 )
{
    
TASK_ID_HUD_WAIT 319,
    
TASD_ID_HUD_LEFT,
    
TASK_ID_HUD_TR,
    
TASK_ID_HUD_SB
}

enum _:HeroData
{
    
HeroName[64], 
    
HeroType[64],
    
Float:BaseDamage,
    
Float:BaseAbilityPower,
    
Float:BaseArmor,
    
Float:BaseMagicResist,
    
Float:BaseHealth,
    
Float:BaseMana,
    
Float:BaseLifeSteal,
    
Float:BaseSpellVamp,
    
Float:BaseCooldown,
    
Float:BaseHealthRegen,
    
Float:BaseManaRegen,
    
Float:BaseCritChance,
    
Float:BaseRange,
}

/* Arrays */

new Array:g_aHeroes

/* Strings */

new g_szHeroName[33][64]
new 
g_szHeroType[33][64]

/* Integer */

new g_iTotalHeroes

/* Floats */

new Float:g_flBaseDamage[33]
new 
Float:g_flBaseAbilityPower[33]
new 
Float:g_flBaseArmor[33]
new 
Float:g_flBaseMagicResist[33]
new 
Float:g_flBaseHealth[33]
new 
Float:g_flBaseMana[33]
new 
Float:g_flBaseLifeSteal[33]
new 
Float:g_flBaseSpellVamp[33]
new 
Float:g_flBaseCooldown[33]
new 
Float:g_flBaseHealthRegen[33]
new 
Float:g_flBaseManaRegen[33]
new 
Float:g_flBaseCritChance[33]
new 
Float:g_flBaseRange[33]

/* Floats */

new Float:g_flTime

/* Forwards */

new g_hSelectHeroForward

// ===============================================================================
//     plugin_init
// ===============================================================================

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
/* Commands */
    
    
register_clcmd("say /test",    "cmd_Test")
    
register_clcmd("say /champ",    "func_OpenHeroSelection")
    
    
/* Hamsandwich */
    
    
RegisterHamHam_Killed"player""fw_HamKilled")
    
RegisterHamHam_Spawn"player""fw_HamSpawn")

    
/* Creating Array */
    
    
g_aHeroes ArrayCreate(HeroData)
    
    
/* Creating Forward */
    
    
g_hSelectHeroForward CreateMultiForward("hero_selected"ET_IGNOREFP_CELLFP_CELL)
}

public 
cmd_Test(id)
{
    
set_hudmessage(02550, -1.00.01)
    
show_hudmessage(id"%s^n %s^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n %1.f^n",
    
g_szHeroName[id], g_szHeroType[id], g_flBaseDamage[id], g_flBaseAbilityPower[id], g_flBaseArmor[id], g_flBaseMagicResist[id], g_flBaseHealth[id], g_flBaseMana[id],
    
g_flBaseLifeSteal[id], g_flBaseSpellVamp[id], g_flBaseCooldown[id], g_flBaseHealthRegen[id], g_flBaseManaRegen[id], g_flBaseCritChance[id], g_flBaseRange[id])
}
    

// ===============================================================================
//     plugin_natives
// ===============================================================================

public plugin_natives()
{
    
register_library("lol")
    
    
register_native("lol_add_hero""_add_hero")
    
register_native("lol_set_hero""_set_hero")
}

// ===============================================================================
//     _add_hero - Adds Hero to plugin
// ===============================================================================

public _add_hero(iPluginiParams)
{
    new 
eItemData[HeroData];
    
    
/*
    HeroName[64], 
    HeroType[64],
    Float:BaseDamage,
    Float:BaseAbilityPower,
    Float:BaseArmor,
    Float:BaseMagicResist,
    Float:BaseHealth,
    Float:BaseMana,
    Float:BaseLifeSteal,
    Float:BaseSpellVamp,
    Float:BaseCooldown,
    Float:BaseHealthRegen,
    Float:BaseManaRegen,
    Float:BaseCritChance,
    Float:BaseRange,
    */
    
    
get_string(1eItemData[HeroName], charsmax(eItemData[HeroName]))
    
get_string(2eItemData[HeroType], charsmax(eItemData[HeroType]))
    
    
eItemData[BaseDamage]         = get_param(3)
    
eItemData[BaseAbilityPower]     = get_param(4)
    
eItemData[BaseArmor]         = get_param(5)
    
eItemData[BaseMagicResist]     = get_param(6)
    
eItemData[BaseHealth]         = get_param(7)
    
eItemData[BaseMana]        = get_param(8)
    
eItemData[BaseLifeSteal]     = get_param(9)
    
eItemData[BaseSpellVamp]     = get_param(10)
    
eItemData[BaseCooldown]        = get_param(11)
    
eItemData[BaseHealthRegen]    = get_param(12)
    
eItemData[BaseManaRegen]    = get_param(13)
    
eItemData[BaseCritChance]    = get_param(14)
    
eItemData[BaseRange]        = get_param(15)
    
    
ArrayPushArrayg_aHeroeseItemData );
    
g_iTotalHeroes++;
    
    return ( 
g_iTotalHeroes );
}

// ===============================================================================
//     _set_hero - Sets hero to player
// ===============================================================================

public _set_hero(idiHeroIndex)
{
    new 
eItemData[HeroData]

    
ArrayGetArray(g_aHeroesiHeroIndexeItemData)
    
    
formatex(g_szHeroName[id], charsmax(g_szHeroName), eItemData[HeroName])
    
formatex(g_szHeroType[id], charsmax(g_szHeroType), eItemData[HeroType])
    
    
g_flBaseDamage[id]         = eItemData[BaseDamage]
    
g_flBaseAbilityPower[id]     = eItemData[BaseAbilityPower
    
g_flBaseArmor[id]         = eItemData[BaseArmor]
    
g_flBaseMagicResist[id]     = eItemData[BaseMagicResist]
    
g_flBaseHealth[id]         = eItemData[BaseHealth
    
g_flBaseMana[id]        = eItemData[BaseMana]
    
g_flBaseLifeSteal[id]         = eItemData[BaseLifeSteal]
    
g_flBaseSpellVamp[id]         = eItemData[BaseSpellVamp
    
g_flBaseCooldown[id]         = eItemData[BaseCooldown]
    
g_flBaseHealthRegen[id]     = eItemData[BaseHealthRegen]
    
g_flBaseManaRegen[id]        = eItemData[BaseManaRegen]
    
g_flBaseCritChance[id]         = eItemData[BaseCritChance]
    
g_flBaseRange[id]         = eItemData[BaseRange]
}


// ===============================================================================
//     func_OpenHeroSelection - Opens menu with all available heroes
// ===============================================================================

public func_OpenHeroSelection(idiPage)
{
    if(!
g_iTotalHeroes)    
        return;
        
    
iPage clamp(iPage0, (g_iTotalHeroes 1) / 7)

    new 
menu menu_create("League of Legends Mod^nChoose your Hero""func_OpenHeroSelection_handler")
    
    new 
eItemData[HeroData]
    new 
szItem[128]
    
    new 
szNum[3]
    
    for(new 
0g_iTotalHeroesi++)
    {
        
ArrayGetArray(g_aHeroesieItemData)
        
        
formatex(szItemcharsmax(szItem), "%s | %s"eItemData[HeroName], eItemData[HeroType])
        
num_to_str(iszNumcharsmax(szNum))
        
        
menu_additem(menuszItemszNum)
    }
    
    
menu_display(idmenuiPage)
}

// ===============================================================================
//     func_OpenHeroSelection_handler - Handler for menu
// ===============================================================================

public func_OpenHeroSelection_handler(idmenuitem)
{
    if(
item == MENU_EXIT)
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}
    
    new 
iAccessszNum[3], hCallback
    menu_item_getinfo
menuitemiAccessszNumcharsmaxszNum ), __hCallback )
    
menu_destroymenu )
    
    new 
iItemIndex str_to_numszNum )
    
    new 
eItemData[HeroData]
    
ArrayGetArrayg_aHeroesiItemIndexeItemData )
    
    new 
iReturn
    ExecuteForward
(g_hSelectHeroForwardiReturnidiItemIndex)
    
    return 
PLUGIN_HANDLED
}


// ===============================================================================
//     fw_HamKilled - Called on players Death
// ===============================================================================

public fw_HamKillediVictimiKillerbShouldGib )
{
    static 
Float:GameTimeiMin
    GameTime 
get_gametime() - g_flTime
    iMin 
floatround(GameTimefloatround_floor) / 60
    
    set_task
(iMin 10.0"respawn_player"iVictim)
}

// ===============================================================================
//     fw_HamSpawn - Called on players spawn
// ===============================================================================

public fw_HamSpawn(id)
{
    if(!
is_user_alive(id))
        return;
        
    
strip_user_weapons(id)
    
give_item(id"weapon_knife")
}
    

// ===============================================================================
//     func_StartGame - Will be called if game starts
// ===============================================================================

public func_StartGame()
{
    
g_flTime get_gametime()
}

// ===============================================================================
//     Stocks
// ===============================================================================

stock respawn_player(id)
    
ExecuteHamBHam_CS_RoundRespawnid)

/* Death Timer : Game Time in minutes + 10 seconds

InGame XP Table :

1 - 2 = 280
2 - 3 = 390
3 - 4 = 500
4 - 5 = 610
5 - 6 = 720
6 - 7 = 830
7 - 8 = 940
8 - 9 = 1050
9 - 10 = 1160
10 - 11 = 1270
11 - 12 = 1380
12 - 13 = 1490
13 - 14 = 1600
14 - 15 = 1710
15 - 16 = 1820
16 - 17 = 1930
17 - 18 = 2040 

/* 



All times are GMT -4. The time now is 18:45.

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