Raised This Month: $12 Target: $400
 3% 

Index out of bound


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
N3v3rM1nd
Junior Member
Join Date: Apr 2021
Old 07-21-2021 , 16:20   Index out of bound
#1

PHP Code:
#include amxmodx

new iNormalVotes[2], iSpeedVotes[4], iJumpsVotes[3]

public 
_reset_votes()
{
arrayset(iNormalVotes0sizeof(iNormalVotes))
arrayset(iSpeedVotes0sizeof(iSpeedVotes))
arrayset(iJumpsVotes0sizeof(iJumpsVotes))
}

public 
vote_smth(idmenuitem)
{
iNormalVotes[item]++ // index out of bounds

switch(item)
{
case 
0// print smth
case 1// print smth
}

return 
PLUGIN_HANDLED
}

public 
vote_smth2(idmenuitem)
{
iSpeedVotes[item]++ // index out of bounds

switch(item)
{
case 
0// print smth
case 1// print smth
case 2// print smth
case 3// print smth
}
return 
PLUGIN_HANDLED
}

public 
vote_smth2(idmenuitem)
{
iJumpsVotes[item]++

switch(
item)
{
case 
0// print smth
case 1// print smth
case 2// print smth
}
return 
PLUGIN_HANDLED
}

public 
vote_smth3(idmenuitem)
{
iNormalVotes[item]++ // index out of bounds

switch(item)
{
case 
0// print smth
case 1// print smth
}
return 
PLUGIN_HANDLED
}

public 
vote_smth4(idmenuitem)
{
iNormalVotes[item]++ // index out of bounds

switch(item)
{
case 
0// print smth
case 1// print smth

}
return 
PLUGIN_HANDLED

the problem is when the variable is incremented the result is index out of bounds

Last edited by Bugsy; 07-21-2021 at 17:10. Reason: removed
N3v3rM1nd is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-21-2021 , 16:32   Re: Index out of bound
#2

Because item argument can be negative.

For example when exiting a menu item will be -3


Add a new case called MENU_EXIT and return PLUGIN_HANDLED in it and just after that do the votes Increment.

Most important thing don't forget to free/destroy the menu after done using it if it gets recreated.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 07-21-2021 at 16:35.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Natsheh
Veteran Member
Join Date: Sep 2012
Old 07-21-2021 , 16:36   Re: Index out of bound
#3

Please dont remove your thread after you got an answer.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Closed Thread


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 11:26.


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