Raised This Month: $ Target: $400
 0% 

origin, angles and touch optimisation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 01-01-2010 , 08:19   origin, angles and touch optimisation
Reply With Quote #1

I would like to know why commented part doesnt work, and why uncommented works, cause i see no reason not to work.

PHP Code:
        // SET ORIGIN AND ANGLES
        
new randspawn random_num (0g_TotalSpawns 1)
        
//new Float:origin[3] = {g_SpawnVecs[randspawn][0], g_SpawnVecs[randspawn][1], g_SpawnVecs[randspawn][2]}
        //new Float:angles[3] = {g_SpawnAngles[randspawn][0], g_SpawnAngles[randspawn][1], g_SpawnAngles[randspawn][2]}
        
new Float:origin[3]
        new 
Float:angles[3]
        
origin g_SpawnVecs[randspawn]
        
angles g_SpawnAngles[randspawn]
        
//CREATE ENTITY
        
create_ent(origin,angles
__________________


Last edited by Jack86; 01-01-2010 at 09:32.
Jack86 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-01-2010 , 08:21   Re: origin and angles
Reply With Quote #2

try

new Float:origin[3] = g_SpawnVecs[randspawn];
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-01-2010 , 08:23   Re: origin and angles
Reply With Quote #3

Commented : Because you need to provide a constant value. How the compiler could know the value at the compilation ? Not possible that's why you can't.

Uncommented : Because origin and g_SpawnVecs have the same size and you are allowed to do that.
__________________
Arkshine is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 01-01-2010 , 09:29   Re: origin and angles
Reply With Quote #4

Ok, tnx. I have 2 more q, is sound emitted with client_cmd( id , spk...) heard by everyone or just that player, and is it ok to remove is_valid_ent check if i change

PHP Code:
public pfn_touch(ptr,ptd) {
    if(!
is_valid_ent(ptd)) { // invalid toucher
        
return PLUGIN_CONTINUE;
    }
    
    
// now check for more invalid entities or players
    
if(!is_valid_ent(ptr) || !is_valid_ent(ptd) || !is_user_connected(ptd)) {
        return 
PLUGIN_CONTINUE;
    }

    new 
classname[32];
    
entity_get_string(ptr,EV_SZ_classname,classname,31); // get name of touched
    
    
if(equal(classname,g_ent_classname)) {
        
// ASSIGN OWNER TO QUAD
        
g_quad_owner ptd 
        
        
// REMOVE ENTRY
        
remove_entity(ptr);
        
        
// enable quad for user
        
quad_enable(ptd);
        return 
PLUGIN_CONTINUE;
    }    
    return 
PLUGIN_CONTINUE;

with

PHP Code:
register_touch("dm_quad","player","touched")

public 
touched(quad,id)
{
    if(!
is_valid_ent(quad) || !is_valid_ent(id) || !is_user_connected(id))
    {
        return 
PLUGIN_CONTINUE;
    }
    
// ASSIGN OWNER TO QUAD
    
g_quad_owner id 
        
    
// REMOVE ENTRY
    
remove_entity(quad);
        
    
// enable quad for user
    
quad_enable(id);
    return 
PLUGIN_CONTINUE;


__________________

Jack86 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 01-01-2010 , 09:41   Re: origin, angles and touch optimisation
Reply With Quote #5

you can remove is_valid_ent(id) check
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-01-2010 , 10:08   Re: origin, angles and touch optimisation
Reply With Quote #6

Quote:
Ok, tnx. I have 2 more q, is sound emitted with client_cmd( id , spk...) heard by everyone or just that player, and is it ok to remove is_valid_ent check if i change
Just by that player, since you provide his index.

Better to use register_touch() when you can ( called only on the classname provided, and the check is done internally so more efficient ). About the check, the entity should be always checked (quad). Id should be checked ( or not ) depending your need. (alive, connected, etc. )
__________________

Last edited by Arkshine; 01-01-2010 at 10:19.
Arkshine is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 01-01-2010 , 10:37   Re: origin, angles and touch optimisation
Reply With Quote #7

Tnx once again.
__________________

Jack86 is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 01-02-2010 , 22:23   Re: origin, angles and touch optimisation
Reply With Quote #8

What would be better to do if i have plugin already done in fakemeta, to handle touch in fakemeta with check

PHP Code:
new classname[32]
    
entity_get_string(ptr,EV_SZ_classname,classname,31
if ( 
equal(classnameclassname2) ) 
or to include engine just for register_touch("customclass1","customslass2"
because i dont see fakemeta function for register_touch
__________________

Jack86 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-03-2010 , 04:44   Re: origin, angles and touch optimisation
Reply With Quote #9

Think, do you think that a forward called for all entities and checking classname manually is more efficient than a forward called only for the entites with the classname provided and so the check is done internally ?
__________________
Arkshine is offline
Jack86
Veteran Member
Join Date: Dec 2008
Location: Belgrade, Serbia
Old 01-03-2010 , 06:29   Re: origin, angles and touch optimisation
Reply With Quote #10

Yea, i thought so too, but i dont know how much another included module raises resource consumption so i asked
__________________

Jack86 is offline
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 04:16.


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