Quote:
Originally Posted by OciXCrom
Not even close to good. This is somewhat better:
PHP Code:
if(g_isalive[id]) { switch(g_level[id]) { case 100 .. 199: { switch(get_user_team(id)) { case 1: cs_set_user_model(id, "Model_1_T") case 2: cs_set_user_model(id, "Model_1_CT") } } case 200: { switch(get_user_team(id)) { case 1: cs_set_user_model(id, "Model_2_T") case 2: cs_set_user_model(id, "Model_2_CT") } } } }
|
Don't ever do something like "100 .. 199", as that actually creates 100 entries in the jump table of the switch. Having just a simple "if" will probably be faster there. It's okay to use it when you are dealing with small ranges, like 10-20 or whatever, but not with hundreds. I believe that's the reason Bailopan switched off that feature in SourcePawn.
Quote:
Originally Posted by siriusmd99
yes?
how plugin works:
death - is_alive[id] = false;
disconnect is_alive[id] = false;
spawn - is_alive[id] = true;
native_is_user_alive(id)
return is_alive(id)
when you use is_user_alive(id), don't you get already cached value?
the thing is that when you use is_alive , you acces global array from plugin but when you call native is_user_alive, you call array from module, which is faster.
|
While module (C++) code will most likely run faster than pawn code, native calling is what is expensive and slow, at least compared to retrieving a value from an array.