AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Offset MODELINDEX (https://forums.alliedmods.net/showthread.php?t=106925)

xbatista 10-20-2009 14:31

Offset MODELINDEX
 
So I saw how in zplague is setting modelindex offset , I set in my plugin too, is this correct?
PHP Code:

// Other
#define MAX_CLASSES 4

new const ZOMBIE_CLASSES[MAX_CLASSES][]= {
    
"zombieap1"// Player Model of hunter
    
"panic"// Player Model of boomer
    
"mummy"// Player Model of smoker
    
"zombieap4" // Player Model of tank


new 
PlayerClass[33];

new Array:
g_modelindex_zombie;

// plugin_precache
g_modelindex_zombie ArrayCreate(11);

new 
modelpath_human[100];
for(new 
0MAX_CLASSESi++)
{
    
formatex(modelpath_humansizeof modelpath_human 1"models/player/%s/%s.mdl"ZOMBIE_CLASSES[i], ZOMBIE_CLASSES[i])
    if( !
file_existsmodelpath_human ) )
    {
        return 
0;
    }

    
ArrayPushCell(g_modelindex_zombieengfunc(EngFunc_PrecacheModelmodelpath_human))

    
formatex(modelpath_humansizeof modelpath_human 1"models/player/%s/%st.mdl"ZOMBIE_CLASSES[i], ZOMBIE_CLASSES[i])
    if ( 
file_existsmodelpath_human ) )
    {
        
engfunc(EngFunc_PrecacheModelmodelpath_human);

        return 
1;
    }

    
formatex(modelpath_humansizeof modelpath_human 1"models/player/%s/%sT.mdl"ZOMBIE_CLASSES[i], ZOMBIE_CLASSES[i])
    if ( 
file_existsmodelpath_human ) )
    {
        
engfunc(EngFunc_PrecacheModelmodelpath_human);

        return 
1;
    }
}
// Ham Spawn Post
PlayerClass[id] = random_num(03)

fm_cs_set_user_model_index(idArrayGetCell(g_modelindex_zombiePlayerClass[id]))

// Stock
// Set the precached model index (updates hitboxes server side)
stock fm_cs_set_user_model_index(idvalue)
{
    
set_pdata_int(id491value5)


Btw I don't know anything about Arrays... But I learned a bit from zplague.
I'm just confused...

Hawk552 10-20-2009 16:52

Re: Offset MODELINDEX
 
It looks correct to me. I don't really know what else to say. I guess I should qualify it by stating that I only looked at your ArrayPushCell() and fm_cs_set_user_model_index() calls.

Nextra 10-20-2009 18:12

Re: Offset MODELINDEX
 
Generally you can assume that code from such plugins is in a working state.

Nevertheless, if you have a problem understanding the arrays, you should make things easier to understand everything in it's entirety. The base method of setting the index shouldn't be a problem.

xbatista 10-21-2009 09:03

Re: Offset MODELINDEX
 
Btw all says that it eats MUCH CPU, dunno why you think that ,but in my server with 32 slots works normally as was previous maybe + 0.3; +0.5 it really eats ,but not much.Also it will eat more CPU if you use more models , I have only 4, seems no problem.


All times are GMT -4. The time now is 17:37.

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