AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Panel, radio style (https://forums.alliedmods.net/showthread.php?t=65836)

skulk_on_dope 01-17-2008 18:35

Panel, radio style
 
Hi,
I'm trying to create a Panel which provides some information's.
It should have the AMX Style (Radio Style). But all I get is a Valve Style menu :/

its for the mod Empires and this mod supports the style, as it is described here: http://www.empiresmod.com/forums/sho...nu+style+radio

It would be nice if anyone can tell me where I'm making a mistake with it.
Code:

public Plugin:myinfo =
{
        name = "dummy",
        author = "skulk_on_dope",
        description = "dummy",
        version = "0.0",
        url = "http://www.sek2000.net/"
};

public OnPluginStart()
{
        RegConsoleCmd("say", Command_Say);
        RegConsoleCmd("say_team", Command_Say);
}

public Action:Command_Say(client, args)
{
        decl String:text[192];
        new startidx = 0;
        if (GetCmdArgString(text, sizeof(text)) < 1)
        {
                return Plugin_Continue;
        }
       
        if (text[strlen(text)-1] == '"')
        {
                text[strlen(text)-1] = '\0';
                startidx = 1;
        }
       
        if (strncmp(text[startidx], "say2", 4, false) == 0)
                startidx += 4;
       
        // Teamsay detection, need to remove Location (EMPIRES ONLY!!)
        if((strncmp(text[startidx], "(", 1, false) == 0) && (strncmp(text[startidx + 3], ")", 1, false) == 0))
                startidx += 5;
       
        if (strcmp(text[startidx], ".lvl", false) == 0)
        {
                decl String:targetName[64];
                GetClientName(client, targetName, sizeof(targetName));
                new Handle:panelStyle = GetMenuStyleHandle(MenuStyle_Radio);
                new Handle:panel = CreatePanel(panelStyle);
                decl String:line[80];
               
                SetPanelTitle(panel, "Ranking Stats" );
                DrawPanelText(panel, " ")
                DrawPanelItem(panel, "Basic Stats:")
                Format(line,sizeof(line),"Information on %s(DB Name: %s)", targetName, "Dummy");
                DrawPanelText(panel, line);
                Format(line,sizeof(line),"Client has a total score of %d", 0);
                DrawPanelText(panel, line);
                Format(line,sizeof(line),"and reached rank %d(%s)", 0, "dummy");
                DrawPanelText(panel, line);
                DrawPanelText(panel, " ");
                DrawPanelItem(panel, "Exit")
                SendPanelToClient(panel, client, BlankMenuHandler, 20)
               
                CloseHandle(panel)
               
                return Plugin_Handled;
        }
       
        return Plugin_Continue;
}

public BlankMenuHandler(Handle:menu, MenuAction:action, param1, param2)
{
       
}


KMFrog 01-17-2008 22:56

Re: Panel, radio style
 
Empires does not fully support radio menus so its disabled by default.

You can create a menu, but none of the clients have the slot keys bound - This means you cant make a selection on the menu.

See this thread for the (ignored) bug report: http://forums.empiresmod.com/showthread.php?t=4642

skulk_on_dope 01-18-2008 06:49

Re: Panel, radio style
 
I'll just want to use it for informations so there is no need for bound keys

BAILOPAN 01-18-2008 07:12

Re: Panel, radio style
 
You can manually enable it by editing the menu section of core.games.txt. SourceMod can't distinguish between a menu intended for information or actual use, so we have to make a blanket restriction.

skulk_on_dope 01-18-2008 09:42

Re: Panel, radio style
 
thanks now it works :)

but why doesn't:
native Handle:GetMenuStyleHandle(MenuStyle:style);
return a INVALID_HANDLE as it is described in the include file ?

I've tested that...
Code:

public Action:CMD_Debug(args)
{
    new Handle:RStyle = GetMenuStyleHandle(MenuStyle_Radio);
    new Handle:VStyle = GetMenuStyleHandle(MenuStyle_Valve);
    new Handle:DStyle = GetMenuStyleHandle(MenuStyle_Default);
   
    if(RStyle == INVALID_HANDLE)
    {
        PrintToServer("RStyle: INVALID_HANDLE");
    }
    else
    {
        PrintToServer("RStyle: VALID!");
    }
   
    if(VStyle == INVALID_HANDLE)
    {
        PrintToServer("VStyle: INVALID_HANDLE");
    }
    else
    {
        PrintToServer("VStyle: VALID");
    }
   
    if(DStyle == VStyle)
    {
        PrintToServer("DStyle: VStyle!");
    }
    else if(DStyle == RStyle)
    {
        PrintToServer("DStyle: RStyle!");
    }
   
    new Handle:panel = CreatePanel(RStyle);
   
    new Handle:PStyle = GetPanelStyle(panel);
   
    if(PStyle == RStyle)
    {
        PrintToServer("PanelStyle -> Radio");
    }
   
    CloseHandle(panel);
}


BAILOPAN 01-19-2008 01:52

Re: Panel, radio style
 
I'm not sure what you're asking. In which situation does what not work?

skulk_on_dope 01-19-2008 08:15

Re: Panel, radio style
 
in the documentation it says:
"A Handle, or INVALID_HANDLE if not found or unusable."
but it returns a valid handle aswell even if its unusable

BAILOPAN 01-19-2008 10:06

Re: Panel, radio style
 
Sounds like a bug then.

KMFrog 01-19-2008 11:05

Re: Panel, radio style
 
which line of code do you think causes the error?

If its something like this:
Code:

new Handle:Style = GetPanelStyle(panel);
Then the handle will always be valid, since you create a new one each time even if GetPanelStyle fails to return a value.

You also might want to sort out some of the memory issues in this code (each handle must be closed at some point)


All times are GMT -4. The time now is 17:02.

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