AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problems with FM_KeyValue forward (https://forums.alliedmods.net/showthread.php?t=57299)

danielkza 07-02-2007 00:19

Problems with FM_KeyValue forward
 
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 ?

purple_pixie 07-02-2007 04:29

Re: Problems with FM_KeyValue forward
 
ent <= get_maxplayers()

Why skip on that equality?

All players would have an id < get_maxplayers() so surely you want < get_maxplayers() there.

danielkza 07-02-2007 12:26

Re: Problems with FM_KeyValue forward
 
Quote:

Originally Posted by purple_pixie (Post 497368)
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.


All times are GMT -4. The time now is 21:24.

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