Raised This Month: $ Target: $400
 0% 

Solved Read file backwards


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-16-2019 , 23:17   Re: Read file backwards
Reply With Quote #8

Quote:
Originally Posted by EFFx View Post
Simplesmente, você le o arquivo normalmente de cima pra baixo e quando você for registrar o menu, comece do ultimo, pegando os valores decrescentes. Tipo, normalmente se utiliza o loop usando ++, é só você trocar pro --, tipo assim:

PHP Code:
// "i" will start with the MAX_VALUE readed, the loop will continue 'til the "i" be equal to or less than 0.
for(new ArraySize(g_arIniFileData);0;i--) 
E provavelmente, quando você for registrar o menu, mesmo usando o loop ao contrário, quando você for selecionar a opção ele ainda vai começar do 0 ao valor maximo que você registrar, então é necessário você passar a ID do item também pro handler, assim você pode saber que opção EXATA o jogador vai selecionar.

Basically:

Simply, you read the file normally, and when you'd create the menu, use the loop backwards, instead of increasing, you decrese the value, something like I showed. And probably, when you do register the menu, even using the reverse loop, after you select the option it'll still start from the 0 to the max value you registered without the menu_get_iteminfo, so you'll need to pass the ID of the item to the menu handler, with this, you'll be able to know which EXACT option the player would select.
for(new i = ArraySize(g_arIniFileData);i > 0;i--)

should be

for(new i = ArraySize(g_arIniFileData) - 1 ; i >= 0 ;i--)

or you will get an index out of bounds on the first pass using g_arIniFileData[ i ] and you also want to allow 0 to be accessed so >= 0 should be used.
__________________
Bugsy is offline
 



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 02:42.


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