Raised This Month: $ Target: $400
 0% 

callfunc_push_str(string, true) only return single letter


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 07-07-2012 , 11:27   callfunc_push_str(string, true) only return single letter
Reply With Quote #1

Why? Here's my code....in an API where the core asks an extension for a string, gives it the string buffer and max length, then the function returns it in that buffer. But it only seems to be returning a single letter. Does anyone know why?

Core calling function.....
PHP Code:
public setHud(id)
{
        
// Set Powerups Message on HUD
    // Variables for controlling the HUD message
    
new pus[90], RGB[3]
    
//new const pus[] = "This woks, yes?"
    // X location for HUD, Y location for HUD, DURATION of message
    
const Float:0.26
    
const Float:0.9
    
const Float:duration 10.0
    
    
if( !getColor(pucolor_pcvarRGB) )
    {
        
RGB[0] = 10
        RGB
[1] = 10
        RGB
[2] = 10
    
}
    
set_hudmessage(RGB[0], RGB[1], RGB[2], XY01.0duration0.10.2, .channel=1)
    
//formatex(pus, charsmax(pus), "%L:", id, "PU_STD", level)
    //client_print(id, print_chat, "Set Powers has been executed. This is number 2. Your level: %d", level)
    
new level getLevel(id)
    switch(
level)
    {
        case -
1
        {
            
client_print(idprint_chat"Your level has been executed as -1. Level: %d"level)
            return 
PLUGIN_HANDLED    // this is error state of client
        
}
        case 
0
        {
            
formatex(puscharsmax(pus), "%L: %L"id"PU_STD"levelid"PU_LOW")
            
client_print(idprint_chat"Set Powers has been executed. This is level 0.")
        }
        case 
1formatex(puscharsmax(pus), "%L: %L"id"PU_STD"levelid"PU_NORMAL")
        case 
2:
        {    
// Run faster
            
formatex(puscharsmax(pus), "%L: %L"id"PU_STD"levelid"PU_SPEED")
        }
        case 
3:
        {    
// jump higher
            
formatex(puscharsmax(pus), "%L: %L"id"PU_STD"levelid"PU_GRAVITY")
        }
        case 
4formatex(puscharsmax(pus), "%L: %L"id"PU_STD"levelid"PU_DAMAGE")
        
// case 5: power ups
    #if defined INSTAKILL
        
case INSTAKILL:
        {
            
client_print(idprint_chat"You have instakill!")
            
formatex(puscharsmax(pus), "Powers{level %d): %L"levelid"PU_INSTAKILL")
        }
    
#endif
        
default: 
        {
        
#if defined INSTAKILL
            
if(level INSTAKILL)
                
formatex(puscharsmax(pus), "%L: %L"id"PU_STD"levelid"PU_DAMAGE")
            else 
//(level > INSTAKILL
                
formatex(puscharsmax(pus), "%L: %L"id"PU_STD"levelid"PU_INSTAKILL")
        
#else
            
formatex(puscharsmax(pus), "%L: %L"id"PU_STD"levelid"PU_DAMAGE")
        
#endif
        
}
    }
    
        
// This is where i call all extensions to retrieve their powers string.
        // Each string must then be added to the 'pus' string and displayed on the HUD
    /*new retVal
    if( !ExecuteForward(g_hudFwd, retVal, id ,g_PowerHud, pus, charsmax(pus)) )
    {
        ShowSyncHudMsg(id, g_PowerHud, pus)    // show hud message of powers
        log_amx("[BKF] bkf_setHud was not fired properly.")
    }
    else if(!retVal)
    {
        ShowSyncHudMsg(id, g_PowerHud, pus)
        client_print(id, print_chat, "bkf_setHud returned 0")
    }*/
    //else
        //ShowSyncHudMsg(id, g_PowerHud, pus)
    
new func[64], plugin[32], powerName[16]
    for(new 
0ArraySize(g_hudFuncs); i++)
    {
        
ArrayGetString(g_hudFuncsifunccharsmax(func) )
        
strtok(funcfunccharsmax(func), plugincharsmax(plugin), '.')
        
        
callfunc_begin(funcplugin)
        
callfunc_push_int(id)
        
callfunc_push_str(powerNametrue)
        
callfunc_push_int(15)
        if(
callfunc_end() )
            
format(puscharsmax(pus), "%s, %s"puspowerName)
        else        
// This just says when the extension didn't add strings
            
formatex(puscharsmax(pus), "%s, Vulgar Obscenities of Frustration."pus)
            
        
client_print(idprint_chatpowerName)
    }
        
    
ShowSyncHudMsg(idg_PowerHudpus)
    return 
PLUGIN_CONTINUE

Extension.....
Code:
public bkf_setHud(id, input[], len) {     static PowerClass:pwr     pwr = powers[id]     client_print(id, print_chat, "setHud executed.")     switch(pwr)     {         case PC_DAMAGE:         {             formatex(input, len, "Extra Damage")             return 1         }         case PC_HEALTH:         {             formatex(input, len, "Health Regenration")             return 1         }         case PC_SPEED:         {             formatex(input, len, "Constant Speed")             return 1         }         case PC_GRAVITY:         {             formatex(input, len, "Constant Gravity")             return 1         }         case PC_SILENT:         {             formatex(input, len, "Silent Run")             client_print(id, print_chat, input)             //ShowSyncHudMsg(id, hud, "%s, Silent Run", input)             return 1         }         default:         {             client_print(id, print_chat, "Default hud executed.")                     }     }     client_print(id, print_chat, "setHud executed. END")     return 0 }

I know it runs properly because the prints are displayed and the first letters are correct. Its just a single letter, not the whole string. I've been diong it mostly with PC_SILENT, which shows that Silent Run IS in the input string. But then when it returns and goes back to the core the string only shows as 'S'. Is this limitations in the engine or bugs in my code?

NOTE: i used a hardcoded 15 as the length for debug purposes. Wondering if charsmax was causing the problem. It wasn't. Just haven't changed it back yet.
Before anyone tries to "improve" it.
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 07-08-2012 at 10:17. Reason: Added my code.
Liverwiz is offline
 


Thread Tools
Display Modes

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


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