Senior Member
|
11-07-2016
, 10:24
Re: Run time error 4: index out of bounds
|
#25
|
E.g.
1#
Code:
public client_disconnect( id )
{
if( is_user_bot( id ) ) return;
if( gPlayerInfo[ id ][ piClass ][ pciIdentificator ] != -1 )
{
new classBuffer[ classInfo ];
ArraySetArray( gPlayerInfo[ id ][ piClasses ], gPlayerInfo[ id ][ piClass ][ pciIdentificator ], gPlayerInfo[ id ][ piClass ] );
ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
new iForward, iRet;
iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_DISABLE )
DestroyForward( iForward );
gPlayerInfo[ id ][ piClass ][ pciIdentificator ] = -1;
}
if( gPlayerInfo[ id ][ piPerk ] != -1 )
{
new perkBuffer[ itemInfo ];
ArrayGetArray( gaPerks, gPlayerInfo[ id ][ piPerk ], perkBuffer );
new iForward, iRet;
iForward = CreateOneForward( perkBuffer[ iiPlugin ], "ncod_perkChangeState", FP_CELL, FP_CELL, FP_CELL );
ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piPerk ], NCODSTATE_DISABLE )
DestroyForward( iForward );
gPlayerInfo[ id ][ piPerk ] = -1;
gPlayerInfo[ id ][ piPerkDurability ] = 0;
}
savePlayer( id );
}
2#
Code:
public eventChangeTeam( )
{
static iOldTeam[ 33 ];
new id = read_data( 1 );
if( is_user_bot( id ) || iOldTeam[ id ] == get_user_team( id ) )
return;
new classBuffer[ classInfo ];
if( gPlayerInfo[ id ][ piClass ][ pciIdentificator ] != -1 )
{
ArraySetArray( gPlayerInfo[ id ][ piClasses ], gPlayerInfo[ id ][ piClass ][ pciIdentificator ], gPlayerInfo[ id ][ piClass ] );
ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
new iForward, iRet;
iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_DISABLE )
DestroyForward( iForward );
}
gPlayerInfo[ id ][ piClass ] = { -1, 0, 0, 0, 0, 0, 0, 0, 0 };
gPlayerInfo[ id ][ piMenuFirstTime ] = true;
format( gPlayerBuffer[ id ][ cInfo ][ ciName ], 127, "Brak" );
gPlayerBuffer[ id ][ bLastC ] = -1;
iOldTeam[ id ] = get_user_team( id );
}
3#
Code:
public fwEmitSound( id, iChannel, szSound[], Float: fVol, Float: fAttn, iFlags, iPitch )
{
if( !is_user_alive( id ) )
return FMRES_IGNORED;
if( strfind( szSound, "wpn_denyselect.wav" ) != -1 )
{
if( gPlayerInfo[ id ][ piClass ][ pciIdentificator ] == -1 )
return FMRES_IGNORED;
new classBuffer[ classInfo ];
ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
new iRet, iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_USE );
DestroyForward( iForward );
return FMRES_SUPERCEDE;
}
return FMRES_IGNORED;
}
4#
Code:
public setPlayerAbilities( id )
{
set_pev( id, pev_health, 100.0 + float( gPlayerInfo[ id ][ piClass ][ pciHealth ] ) );
new classBuffer[ classInfo ];
ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
new bool:bC4 = false, szWeapon[ 64 ];
if( pev( id, pev_weapons ) & CSW_C4 ) bC4 = true;
fm_strip_user_weapons( id );
fm_give_item( id, "weapon_knife" );
for( new i = 1; i < 33; i ++ )
{
if( !( classBuffer[ ciWeapons ] & ( 1 << i ) ) )
continue;
get_weaponname( i, szWeapon, 63 );
fm_give_item( id, szWeapon );
fm_give_item( id, szWeapon );
fm_give_item( id, szWeapon );
fm_give_item( id, szWeapon );
}
if( bC4 ) fm_give_item( id, "weapon_c4" );
new iRet, iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_SPAWN );
DestroyForward( iForward );
}
5#
Code:
public cmdClassH( id, iMenu, iItem )
{
client_cmd( id, "spk %s", gszPluginSounds[ psSelectMenuItem ] );
if( iItem == MENU_EXIT )
{
menu_destroy( iMenu );
return PLUGIN_HANDLED;
}
new iAccess, iCallback, iClassID, iForward;
new szClassID[ 5 ], szName[ 33 ];
menu_item_getinfo( iMenu, iItem, iAccess, szClassID, 4, szName, 32, iCallback );
iClassID = str_to_num( szClassID );
new classBuffer[ classInfo ];
new iRet;
if( gPlayerInfo[ id ][ piClass ][ pciIdentificator ] != -1 )
{
ArraySetArray( gPlayerInfo[ id ][ piClasses ], gPlayerInfo[ id ][ piClass ][ pciIdentificator ], gPlayerInfo[ id ][ piClass ] );
ArrayGetArray( gaClasses, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], classBuffer );
iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
ExecuteForward( iForward, iRet, id, gPlayerInfo[ id ][ piClass ][ pciIdentificator ], NCODSTATE_DISABLE )
DestroyForward( iForward );
}
ArrayGetArray( gaClasses, iClassID, classBuffer );
if( classBuffer[ ciAccessFlags ] != 0 && !( get_user_flags( id ) & classBuffer[ ciAccessFlags ] ) )
{
printInformation( id, NCODINFOTYPE_CHAT, NCODINFOCOLOR_NORMAL, "Nie masz dostepu do tej klasy." )
cmdClass( id )
return PLUGIN_HANDLED
}
ArrayGetArray( gPlayerInfo[ id ][ piClasses ], iClassID, gPlayerInfo[ id ][ piClass ] );
iForward = CreateOneForward( classBuffer[ ciPlugin ], "ncod_classChangeState", FP_CELL, FP_CELL, FP_CELL );
ExecuteForward( iForward, iRet, id, iClassID, NCODSTATE_ENABLE )
DestroyForward( iForward );
checkPlayerLevel( id );
if( gPlayerInfo[ id ][ piMenuFirstTime ] )
{
setPlayerAbilities( id )
gPlayerInfo[ id ][ piMenuFirstTime ] = false;
}
return PLUGIN_HANDLED
}
Full .sma in attachment: https://forums.alliedmods.net/showpo...75&postcount=1
|
|