Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
|
02-01-2016
, 15:08
Re: Armoury Manager
|
#13
|
Hi Bugsy, good code. Looks like you spend a quite some time on it. But if you still interest, I have some ideas: - To have unlimited entities using a dynamic array instead of static. It is a script peek up, to help anyone who is reading this and beginning to script, see the changes from static to dynamic:
Spoiler
Code:
new g_aCurrentElement[ ArmouryInfo ]
ProcessEntities()
{
new iEntity , Float:fOrigin[ 3 ] , Float:fEntOrigin[ 3 ] , szClassname[ 15 ];
new Float:fCurrentDistance , Float:fNearestDistance , iClosestEnt;
//Loop through all entities in the array.
for ( new iCurrent = 0 ; iCurrent < g_iMapEntityCount ; iCurrent++ )
{
ArrayGetArray( g_EntityData, iCurrent, g_aCurrentElement )
if ( g_aCurrentElement[ aiCreated ] )
{
g_aCurrentElement[ aiEntityIndex ] = CreateEntity( GetArmouryType( iCurrent ) , GetArmouryCount( iCurrent ) , g_aCurrentElement[ aiOrigin ] , false );
set_pev( g_aCurrentElement[ aiEntityIndex ] , pev_iuser4 , iCurrent );
...
do
{
iBytesRead += fread_blocks( iFile , g_aCurrentElement[ ArmouryInfo:0 ] , sizeof( g_aCurrentElement ) , BLOCK_INT );
ArrayPushArray( g_EntityData, g_aCurrentElement )
//This is a work-around. !feof() condition was not working as expected and I would always end up with 2 of the very last
//item in the file in my array.
} while ( ( iBytesRead * BLOCK_INT ) < iSize )
Instead of:
Code:
ProcessEntities()
{
new iEntity , Float:fOrigin[ 3 ] , Float:fEntOrigin[ 3 ] , szClassname[ 15 ];
new Float:fCurrentDistance , Float:fNearestDistance , iClosestEnt;
//Loop through all entities in the array.
for ( new iCurrent = 0 ; iCurrent < g_iMapEntityCount ; iCurrent++ )
{
if ( g_EntityData[ iCurrent ][ aiCreated ] )
{
g_EntityData[ iCurrent ][ aiEntityIndex ] = CreateEntity( GetArmouryType( iCurrent ) , GetArmouryCount( iCurrent ) , g_EntityData[ iCurrent ][ aiOrigin ] , false );
set_pev( g_EntityData[ iCurrent ][ aiEntityIndex ] , pev_iuser4 , iCurrent );
...
while ( ( iLoaded < MaxEntities ) /* && !feof( iFile ) */ )
{
iBytesRead += fread_blocks( iFile , g_EntityData[ iLoaded++ ][ ArmouryInfo:0 ] , sizeof( g_EntityData[] ) , BLOCK_INT );
//This is a work-around. !feof() condition was not working as expected and I would always end up with 2 of the very last
//item in the file in my array.
if ( ( iBytesRead * BLOCK_INT ) == iSize )
break;
}
- To use the newer 'client_disconnected' when compiling at the AMXX 183. Snippet:
Code:
#if AMXX_VERSION_NUM < 183
public client_disconnect( id )
#else
public client_disconnected( id )
#endif
{
- To put the small menu functions 'ShowTypeMenu' and 'ShowCountMenu' a little up on the code after 'SaveAndResetVars', because they are now 9 functions away from its caller separed by big functions as 'DeleteConfig', 'DisableManager', 'EnableManager' and 'RoundStart'.
-
Code:
//Shows a MOTD status of any entities that have been created or changed. The MOTD character limit is too low to allow displaying
//every entity on a map that has > ~12 entities.
public DisplayInfo( id , level , cid )
{
If I understand correctly, you could write various 'motd_page1.html', 'motd_page2.hmtl', etc, on disk and create links between them. Ex: [Page fotter] Next page - Previous page - First Page - Last Page. So, you could show all weapons working around this limitation using several pages, instead of just one big and scrollable one.
__________________
Last edited by addons_zz; 02-01-2016 at 16:58.
Reason: spelling fix
|
|