This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

[TUT] Modules and efficient scripting


Post New Thread Reply   
 
Thread Tools Display Modes
joaquimandrade
Veteran Member
Join Date: Dec 2008
Location: Portugal
Old 04-18-2009 , 15:35   Re: [TUT] Modules and efficient scripting
Reply With Quote #81

Quote:
Originally Posted by Nextra View Post
You can also prove that by simple example codes. For example, this will make the compiler throw warnings but on runtime you won't see a difference compared to correct tagging:

PHP Code:
#include <amxmodx>

public plugin_init( )
{
    
register_plugin"Tagmix""1337""Nextra" );

    new 
bool:bTest;

    for( new 
03i++ )
    {
        
bTest random_float0.03.0 );

        
log_amx"%f"bTest );
    }

Output:

Code:
L 04/18/2009 - 21:25:44: [tags.amxx] 1.831825
L 04/18/2009 - 21:25:44: [tags.amxx] 2.950227
L 04/18/2009 - 21:25:44: [tags.amxx] 0.513996
Yes.
__________________
joaquimandrade is offline
Empowers
BANNED
Join Date: Feb 2009
Location: Ukraine
Old 04-20-2009 , 08:07   Re: [TUT] Modules and efficient scripting
Reply With Quote #82

is it possible to make somethink like this?
PHP Code:
new is_pev_valid[1366
So we can use it like pev_valid(ent) native

Last edited by Empowers; 04-20-2009 at 08:11.
Empowers is offline
Send a message via ICQ to Empowers
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-20-2009 , 08:15   Re: [TUT] Modules and efficient scripting
Reply With Quote #83

Not worth to do that because an entity can be not valid at any time because of plugins and others. So you will have to update constantly the entity state. No, really not safe and it will not be an optimization.
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 04-20-2009 , 08:18   Re: [TUT] Modules and efficient scripting
Reply With Quote #84

Quote:
Originally Posted by arkshine View Post
Not worth to do that because an entity can be not valid at any time because of plugins and others. So you will have to update constantly the entity state. No, really not safe and it will not be an optimization.
This is same as using
PHP Code:
new g_isAlive[33];

// ..... 
__________________
xPaw is offline
Empowers
BANNED
Join Date: Feb 2009
Location: Ukraine
Old 04-20-2009 , 08:23   Re: [TUT] Modules and efficient scripting
Reply With Quote #85

Quote:
Originally Posted by xPaw View Post
This is same as using
PHP Code:
new g_isAlive[33]; 
why? g_isAlive is a good optimization & it's pretty save:
PHP Code:
//code by MeRcyLeZZ
public fw_PlayerSpawnid )
{
    if ( !
is_user_aliveid ) || !cs_get_user_teamid ) )
        return;
    
    
g_isAlive[id] = true
}

public 
fw_PlayerKilledid )
{
    
g_isAlive[id] = false


Last edited by Empowers; 04-20-2009 at 08:25.
Empowers is offline
Send a message via ICQ to Empowers
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-20-2009 , 08:25   Re: [TUT] Modules and efficient scripting
Reply With Quote #86

@ xPaw : Not really. You don't have a forward which says you this entity is valid or not. Plus the number of max entity can be changed and is different whereas the max slots of server, it's not a good idea to harcode a value.
Arkshine is offline
Empowers
BANNED
Join Date: Feb 2009
Location: Ukraine
Old 04-20-2009 , 08:26   Re: [TUT] Modules and efficient scripting
Reply With Quote #87

Quote:
Originally Posted by arkshine View Post
the number of max entity can be changed and is different whereas the max slots of server, it's not a good idea to harcode a value.
When there a 32 slots on the server.. MAX_ENTs = 1365
Empowers is offline
Send a message via ICQ to Empowers
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-20-2009 , 08:28   Re: [TUT] Modules and efficient scripting
Reply With Quote #88

But it can be changed using the -num_edicts switch and for people which don't have a 32 slots, you will harcode such value it will be a waste of memory.
Arkshine is offline
Empowers
BANNED
Join Date: Feb 2009
Location: Ukraine
Old 04-20-2009 , 08:31   Re: [TUT] Modules and efficient scripting
Reply With Quote #89

Quote:
Originally Posted by arkshine View Post
But it can be changed using the -num_edicts switch and for people which don't have a 32 slots, you will harcode such value it will be a waste of memory.
So we can use bitsum for that

PHP Code:
new bitsum_pev_valid 
Empowers is offline
Send a message via ICQ to Empowers
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 04-20-2009 , 14:15   Re: [TUT] Modules and efficient scripting
Reply With Quote #90

Quote:
Originally Posted by Empowers View Post
So we can use bitsum for that

PHP Code:
new bitsum_pev_valid 
No because a bitsum can only go to (1<<31)

Quote:
Originally Posted by arkshine View Post
You don't have a forward which [tells] you this entity is valid or not.
That is the main reason why you cannot do it with entites at all.
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Reply



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 05:08.


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