How to clear a controlspanel ?

Hello,

I don’t know how I can clear a controlspanel.

Could you help me please ?

Please explain yourself more

I make a controlspanel in the event : **[TOOL.BuildCPanel

http://wiki.garrysmod.com/favicon.ico](wiki.garrysmod.com/?title=TOOL.BuildCPanel)**

[lua]
TOOL.Category = “Pulp MMORPG Tools”
TOOL.Name = “NPC Auto Spawner”
TOOL.Command = nil
TOOL.ConfigName = nil

local selected_npc = nil;

if CLIENT then
language.Add( “Tool_NPCSpawner_name”, “NPC Auto Spawner” )
language.Add( “Tool_NPCSpawner_desc”, “Utiliser pour creer un npc qui reapparait quand il meurt.” );
language.Add( “Tool_NPCSpawner_0”, “Clique-gauche : Faire apparaitre/ajouter un NPC Auto spawner. Clique-droit: Enlever le NPC Auto Spawner.” );
end

function TOOL:LeftClick( trace )
if(selected_npc == nil and trace.Entity:IsNPC()) then
selected_npc = trace.Entity;

            return true;
    end

end

function TOOL:RightClick( trace )
end

function TOOL.BuildCPanel( panel )
–Spanel:RemoveAll();
if(selected_npc != nil) then
local options = {};
options[“Allie”] = {type_npc = 0};
options[“Ennemi neutre”] = {type_npc = 1};
options[“Ennemi total”] = {type_npc = 2};

            panel:AddControl("ListBox", {
                    Label = "Hostilite",
                    Description = "Type du npc qui apparaitra.",
                    Options = options,
                    MenuButton = 1
            });
    else
            panel:AddControl("Label", {
                    Text = "Veuillez selectionner un npc !"
            });
    end

end
[/lua]

But the controlspanel isn’t edited when I select a npc…

How I can this ?

[lua]function TOOL:BuildCPanel( panel )[/lua]

instead of

[lua]function TOOL.BuildCPanel( panel ) [/lua]

Also, for gods sake learn english.

Now, it return this error :

[@gamemodes\sandbox\gamemode\spawnmenu\controlpanel.lua:99] ControlPanelBuildFunction Error: [addons estmod\lua\weapons\gmod_tool\stools
pcspawner.lua:40] attempt to index local ‘panel’ (a nil value)

Do you have an idea ?

I know the error but I don’t know how repair it.

Can you help me please ?