Raised This Month: $ Target: $400
 0% 

Problems with FM_KeyValue forward


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 07-02-2007 , 00:19   Problems with FM_KeyValue forward
Reply With Quote #1

Hi ,i've been working on a weapon management plugin,and i'm trying to log keyvalues from all armoury_entity.
Code:
PHP Code:
public forward_keyvalue(enthandle) {
    
    
// Skip Players and check if entity is valid
    
if (ent <= get_maxplayers() || !pev_valid(ent) || g_WeapIndexSize >= MAX_ARMOURY_ENTITIES)
        return 
FMRES_IGNORED
        
    
// Start reading of KeyValues
    
static class[32]
    
    
get_kvd(handleKV_ClassName, class,31)
    
    
// Too Obvious
    
if (!equali(class, "armoury_entity",14))
        return 
FMRES_IGNORED
    
    
static key[32], value[32
    new 
numvalue
    
    get_kvd
(handleKV_KeyNamekey31)
    
get_kvd(handleKV_Valuevalue31)
    
numvalue str_to_num(value)
    
    
// Log the keys and values of the weapons to an array
    
if (equali(key,"count",5)) {
        
server_print("Ent #%d count=%d"entnumvalue)
        
g_WeapCount[g_WeapIndexSize] = numvalue
    
}
    
    if(
equali(key,"item",4)) {
        new 
solid pev(ent,pev_solid)
        
server_print("Ent #%d item=%d solid=%d"entnumvalue,solid)
        
g_WeapItem[g_WeapIndexSize] = numvalue
    
}
    
    
// Check if entity's position haven't been logged yet
    // and do it
        
    
if (ent != g_LastEnt) {
        
pev(entpev_origing_WeapOrigin[g_WeapIndexSize])
        if (
g_LastEnt 0) {
            
g_WeapIndex[g_WeapIndexSize] = ent
            g_WeapIndexSize
++
        }
        
// Prevent skipping 1st weapon's item
        
g_LastEnt ent
    
}
    
        
    return 
FMRES_IGNORED

the console output is
Code:
Ent #66 count=1
Ent #67 count=1
Ent #68 item=16 solid=0
Ent #68 count=1
Ent #69 item=16 solid=0
Ent #69 count=1
Ent #103 item=4 solid=0
Ent #103 count=1
...
Why is it skipping 1st ent. item? Can anyone help me with this ?
danielkza is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 07-02-2007 , 04:29   Re: Problems with FM_KeyValue forward
Reply With Quote #2

ent <= get_maxplayers()

Why skip on that equality?

All players would have an id < get_maxplayers() so surely you want < get_maxplayers() there.
purple_pixie is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 07-02-2007 , 12:26   Re: Problems with FM_KeyValue forward
Reply With Quote #3

Quote:
Originally Posted by purple_pixie View Post
ent <= get_maxplayers()

Why skip on that equality?

All players would have an id < get_maxplayers() so surely you want < get_maxplayers() there.
no,i'm processing the weapons on the floor,and obviously,players don't have item and count keyvalues.
danielkza 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 21:24.


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