|
Veteran Member
Join Date: Feb 2010
Location: Maryland
|

07-07-2012
, 11:27
callfunc_push_str(string, true) only return single letter
|
#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:X = 0.26 const Float:Y = 0.9 const Float:duration = 10.0 if( !getColor(pucolor_pcvar, RGB) ) { RGB[0] = 10 RGB[1] = 10 RGB[2] = 10 } set_hudmessage(RGB[0], RGB[1], RGB[2], X, Y, 0, 1.0, duration, 0.1, 0.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(id, print_chat, "Your level has been executed as -1. Level: %d", level) return PLUGIN_HANDLED // this is error state of client } case 0: { formatex(pus, charsmax(pus), "%L: %L", id, "PU_STD", level, id, "PU_LOW") client_print(id, print_chat, "Set Powers has been executed. This is level 0.") } case 1: formatex(pus, charsmax(pus), "%L: %L", id, "PU_STD", level, id, "PU_NORMAL") case 2: { // Run faster formatex(pus, charsmax(pus), "%L: %L", id, "PU_STD", level, id, "PU_SPEED") } case 3: { // jump higher formatex(pus, charsmax(pus), "%L: %L", id, "PU_STD", level, id, "PU_GRAVITY") } case 4: formatex(pus, charsmax(pus), "%L: %L", id, "PU_STD", level, id, "PU_DAMAGE") // case 5: power ups #if defined INSTAKILL case INSTAKILL: { client_print(id, print_chat, "You have instakill!") formatex(pus, charsmax(pus), "Powers{level %d): %L", level, id, "PU_INSTAKILL") } #endif default: { #if defined INSTAKILL if(level < INSTAKILL) formatex(pus, charsmax(pus), "%L: %L", id, "PU_STD", level, id, "PU_DAMAGE") else //(level > INSTAKILL formatex(pus, charsmax(pus), "%L: %L", id, "PU_STD", level, id, "PU_INSTAKILL") #else formatex(pus, charsmax(pus), "%L: %L", id, "PU_STD", level, id, "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 i = 0; i < ArraySize(g_hudFuncs); i++) { ArrayGetString(g_hudFuncs, i, func, charsmax(func) ) strtok(func, func, charsmax(func), plugin, charsmax(plugin), '.') callfunc_begin(func, plugin) callfunc_push_int(id) callfunc_push_str(powerName, true) callfunc_push_int(15) if(callfunc_end() ) format(pus, charsmax(pus), "%s, %s", pus, powerName) else // This just says when the extension didn't add strings formatex(pus, charsmax(pus), "%s, Vulgar Obscenities of Frustration.", pus) client_print(id, print_chat, powerName) } ShowSyncHudMsg(id, g_PowerHud, pus) 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.
|
|