Raised This Month: $51 Target: $400
 12% 

Model Menu


Post New Thread Reply   
 
Thread Tools Display Modes
Pc349bds
New Member
Join Date: Jul 2008
Old 01-03-2009 , 17:25   Re: Model Menu
Reply With Quote #281

Quote:
Originally Posted by KillerSneak View Post

Somehow it reads this as the t flag (custom6) So there's no way in hell you can have seperate admin groups this way / seperate skins for seperate users a Update is really needed here. To bad that almost all plugin coders seem not to give a shit anymore.
Quote:
Originally Posted by dagg929 View Post
I can only get this to work by setting a single group to the single t flag. With sourcebans you can only have one group for all the users, and am curious if someone can take a look at this, and fix it so that a group with multiple flags, including the t flag, will have access to the skins. Currently, this does not function correctly - as today when swapping to sourcebans, I encountered this issue.
I found a work around for this but if u have a ton of groups that u would like to add this will not work. You mod his source code in 3 spots and make new names for them.

1.DL the source code open in note pad
2. find near the top
Code:
public Plugin:myinfo = 
{
    name = "Model Menu",
add some thing to help u separate this one from the others. like Model Menu for LVL 4. this is what pops up when u type (rcon sm plugins list)

3.Find
Code:
public OnPluginStart()
{
    RegConsoleCmd("sm_models"
replace sm_models with what u would like to use for this one for in game. keep sm_ like sm_modles4 that would be in game !modles4 or in ~ sm_modles4

4. find
Code:
Handle:BuildMainMenu()
{
    /* Create the menu Handle */
    new Handle:menu = CreateMenu(Menu_Group)
    
    kv = CreateKeyValues("Commands")
    new String:file[256]
    BuildPath(Path_SM, file, 255, "configs/models.ini")
    FileToKeyValues(kv, file)
change models.ini to some thing new like models4.ini

5. ctrl a ctrl c
6. go to the web compiler on SM home page and ctrl V in the code box add a new name at the top above the code box and hit compile
7. copy the models.ini and rename it to what u renamed it in step 4

the only new files are the new plugin file and the new models file all the others are shared.

I like this because it allows me to have fully customized stuff for the groups and works with SourceBans =).
I hope this helps.

Last edited by Pc349bds; 01-03-2009 at 19:09.
Pc349bds is offline
dagg929
Senior Member
Join Date: Jun 2008
Old 01-03-2009 , 17:44   Re: Model Menu
Reply With Quote #282

So what your saying is you didn't have to create a seperate group with only the t flag, you were able to just incorporate it all into one group, and it worked with the above code you changed?

I need it so that my full admins group, which has the t flag, will be able to use the skins - as of right now it tells them they do not have access, and with sourcebans a user can only be a member of a single group. So, this will let me set my one, single group, that has more than just the t flag, and will allow them to use the skins without messing up? I need it so I don't have to throw in a seperate group that runs just that single t flag.

Last edited by dagg929; 01-03-2009 at 17:48. Reason: More.
dagg929 is offline
Pc349bds
New Member
Join Date: Jul 2008
Old 01-03-2009 , 18:31   Re: Model Menu
Reply With Quote #283

It already dose 1 group that works with SB but I wanted more(if u don't have SB or only want 1 group to have skins you don't need to do this. SB only can do one group per user that's why i did this)
doing that you make more versions of the plug that will work but each plugin only dose 1 SB group so it kinda works for multiple groups but works grate if say u want a three groups vip's, payed admins, normal admins and all of them to have different models like I do.(I want people to be able to tell the differences just but looking at them.)
On my servers i have 5 lvl's of admin and 3, 4, and 5 get skins but only 5 gets extra sinks so this works great all you need to do is in the models4.ini
put the name of the group u want to have the skins like me for LVL 4 i put in the models4.ini (that's what i made it use for lvl 4 admins)
Code:
 "Admin"     "lvl 4"
and it works grate.

(To all not just with this mod to the plugin.)
Although I did find a bug in the program if you unload the plugins then any player that is changing there skin gets the admin model until you reload the plugins but they still have the models a map change fix's that.
__________________
My groups Web Site - free admin with referral from an admin
http://www.devildogs0311.com

Last edited by Pc349bds; 01-03-2009 at 19:13.
Pc349bds is offline
dbenoy
Junior Member
Join Date: Dec 2008
Old 01-04-2009 , 16:40   Re: Model Menu
Reply With Quote #284

Quote:
Originally Posted by Peoples Army View Post
good job , you beat me to it . bout time some one released model changer , nice menu feature , over all excelelnt plugin . 2 thumbs up

ill add this to my server tommarow


does this work only with .mdls or all of the source model and texture files (vtf vmp)?
Was this ever answered? I want to change just skins.
dbenoy is offline
RaGing*
Junior Member
Join Date: Oct 2008
Location: Belgium
Old 01-28-2009 , 07:40   Re: Model Menu
Reply With Quote #285

If you got eventscripts on your server

Try making a eventscript to change models
RaGing* is offline
ph
AlliedModders Donor
Join Date: Mar 2006
Old 02-04-2009 , 17:42   Re: Model Menu
Reply With Quote #286

It is working on css source but fails to work for dods.

All the files are downloaded but when selecting a option, it displays a standard model for dods.

Any fix / ideas ?
__________________
ph is offline
andi67
Veteran Member
Join Date: Mar 2007
Location: Somewhere near you!!!
Old 02-04-2009 , 18:24   Re: Model Menu
Reply With Quote #287

for DODS try this:
http://community.dodsourceplugins.ne...php?f=15&t=173
andi67 is offline
ph
AlliedModders Donor
Join Date: Mar 2006
Old 02-04-2009 , 22:14   Re: Model Menu
Reply With Quote #288

This works for DOD: Source, without models.ini

However everyone can access the models
Can someone add custom 6 / t flag for members to access.


Code:
#include <sourcemod>
#include <sdktools>

//class = GetEntProp(client, Prop_Send, "m_iPlayerClass")
//0 = Rifleman
//1 = Assault
//2 = Support
//3 = Sniper
//4 = MG
//5 = Rocket

#define TEAM_AMER 2
#define TEAM_AXIS 3


#define MDL_SNOW_AMER   "models/player/fragmasters/stars_camo_american/american_assault.mdl"
#define MDL_SNOW_AXIS   "models/player/fragmasters/skimask/american_assault.mdl"
#define MDL_SUMMER_AMER "models/player/fragmasters/pow_soldier/american_assault.mdl"
#define MDL_SUMMER_AXIS "models/player/fragmasters/misfitsdod123/american_assault.mdl"

new Handle:playermodelskv
new Handle:cvarAnnounce = INVALID_HANDLE;

new String:authid[MAXPLAYERS+1][35]
    
new String: g_modelAmerName[][] =
{
    "models/player/american_rifleman.mdl",
    "models/player/american_assault.mdl",
    "models/player/american_support.mdl",
    "models/player/american_sniper.mdl",
    "models/player/american_mg.mdl",
    "models/player/american_rocket.mdl"
}

new String: g_modelAxisName[][] =
{
    "models/player/german_rifleman.mdl",
    "models/player/german_assault.mdl",
    "models/player/german_support.mdl",
    "models/player/german_sniper.mdl",
    "models/player/german_mg.mdl",
    "models/player/german_rocket.mdl"
}

public Plugin:myinfo =
{
    name = "Model Choiser",
    author = "-=[SWD]=- AmerKnife",
    version = "1.0.0.1",
    url = "http://www.polygon4.net/"
};

public OnPluginStart()
{
    RegConsoleCmd("sm_models", Menu_Test1);
    cvarAnnounce = CreateConVar("sm_modelmenu_announce", "1", "Announcement preferences");
    HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post);

    new String:file[256];
    BuildPath(Path_SM, file, 255, "data/playermodels.ini");
    playermodelskv = CreateKeyValues("Models");
    FileToKeyValues(playermodelskv, file);
}

public OnClientPutInServer(client)
{
    GetClientAuthString( client, authid[client], sizeof(authid[]) );

    // Make the announcement in 30 seconds unless announcements are turned off
    if(GetConVarBool(cvarAnnounce))
        CreateTimer(30.0, TimerAnnounce, client);
}

public Action:TimerAnnounce(Handle:timer, any:client)
{
	if(IsClientInGame(client))
		PrintToChat(client, "Say !models or /models to set your models preferences");
}

public OnPluginEnd()
{
    new String:file[256];
    BuildPath(Path_SM, file, 255, "data/playermodels.ini");
    KeyValuesToFile(playermodelskv, file);
    CloseHandle(playermodelskv);
}

public OnMapStart()
{

    new String:file[256];
    BuildPath(Path_SM, file, 255, "configs/modeldownloads.ini");
    new Handle:fileh = OpenFile(file, "r");
    new String:buffer[256];

    while (ReadFileLine(fileh, buffer, sizeof(buffer)))
    {
        new len = strlen(buffer)
        if (buffer[len-1] == '\n')
            buffer[--len] = '\0';

        if (FileExists(buffer))
        {
            AddFileToDownloadsTable(buffer);
        }

        if (IsEndOfFile(fileh))
            break;
    }

    PrecacheModel(MDL_SNOW_AMER, true);
    PrecacheModel(MDL_SNOW_AXIS, true);
    PrecacheModel(MDL_SUMMER_AMER, true);
    PrecacheModel(MDL_SUMMER_AXIS, true);

    for (new i = 0; i < 6; i++)
    {
        PrecacheModel(g_modelAmerName[i], true);
        PrecacheModel(g_modelAxisName[i], true);
    }
}

public Action:Menu_Test1(client, args)
{

    new Handle:menu = CreateMenu(MenuHandler1);
    SetMenuTitle(menu, "Choise Model");

    if (GetClientTeam(client) == TEAM_AMER)
    {
        AddMenuItem(menu, MDL_SNOW_AMER, "American Camo Model");
        AddMenuItem(menu, MDL_SUMMER_AMER, "PoW Soldier Model");

        switch(GetEntProp(client, Prop_Send, "m_iPlayerClass"))
        {
            case 0:
            {
                AddMenuItem(menu, g_modelAmerName[0], "Standart Model")
            }
            case 1:
            {
                AddMenuItem(menu, g_modelAmerName[1], "Standart Model")
            }
            case 2:
            {
                AddMenuItem(menu, g_modelAmerName[2], "Standart Model")
            }
            case 3:
            {
                AddMenuItem(menu, g_modelAmerName[3], "Standart Model")
            }
            case 4:
            {
                AddMenuItem(menu, g_modelAmerName[4], "Standart Model")
            }
            case 5:
            {
                AddMenuItem(menu, g_modelAmerName[5], "Standart Model")
            }
        }

    }
    else if (GetClientTeam(client) == TEAM_AXIS)
    {

        AddMenuItem(menu, MDL_SNOW_AXIS, "Ski Masked Model");
        AddMenuItem(menu, MDL_SUMMER_AXIS, "Misfits Model");

        switch(GetEntProp(client, Prop_Send, "m_iPlayerClass"))
        {
            case 0:
            {
                AddMenuItem(menu, g_modelAxisName[0], "Standart Model")
            }
            case 1:
            {
                AddMenuItem(menu, g_modelAxisName[1], "Standart Model")
            }
            case 2:
            {
                AddMenuItem(menu, g_modelAxisName[2], "Standart Model")
            }
            case 3:
            {
                AddMenuItem(menu, g_modelAxisName[3], "Standart Model")
            }
            case 4:
            {
                AddMenuItem(menu, g_modelAxisName[4], "Standart Model")
            }
            case 5:
            {
                AddMenuItem(menu, g_modelAxisName[5], "Standart Model")
            }
        }
    }

    SetMenuExitButton(menu, true);
    DisplayMenu(menu, client, 20);

    return Plugin_Handled
}

//Handle:DefaultAmerPatch(client)
//{
//	switch(GetEntProp(client, Prop_Send, "m_iPlayerClass"))
//	{
//		case 0:{ return g_modelAmerName[0];}
//		case 1:{ return g_modelAmerName[1];}
//		case 2:{ return g_modelAmerName[2];}
//		case 3:{ return g_modelAmerName[3];}
//		case 4:{ return g_modelAmerName[4];}
//		case 5:{ return g_modelAmerName[5];}
//	}
//	return  g_modelAmerName[0]
//}

//Handle:DefaultAxisPatch(client)
//{
//
//	switch(GetEntProp(client, Prop_Send, "m_iPlayerClass"))
//	{
//      case 0:{ return g_modelAxisName[0]; }
//		case 1:{ return g_modelAxisName[1]; }
//		case 2:{ return g_modelAxisName[2]; }
//		case 3:{ return g_modelAxisName[3]; }
//		case 4:{ return g_modelAxisName[4]; }
//		case 5:{ return g_modelAxisName[5]; }
//	}
//	return g_modelAxisName[0]
//}

public MenuHandler1(Handle:menu, MenuAction:action, param1, param2)
{
    if (action == MenuAction_Select)
    {
        new String:info[256];
        new bool:found = GetMenuItem(menu, param2, info, sizeof(info));
        //PrintToConsole(param1, "You selected item: %d (found? %d info: %s)", param2, found, info)

        if (!found)
            return

        KvJumpToKey(playermodelskv, authid[param1], true);
        
        if (GetClientTeam(param1) == TEAM_AMER)
        {
            KvSetString(playermodelskv, "Team1", info);
        }
        else if (GetClientTeam(param1) == TEAM_AXIS)
        {
            KvSetString(playermodelskv, "Team2", info);
        }

        KvRewind(playermodelskv);

        if(IsModelPrecached(info))
        {
            SetEntityModel(param1, info);
            SetEntityRenderColor(param1, 255, 255, 255, 255);
        }
    }
    else if (action == MenuAction_End)
    {
        CloseHandle(menu);
    }
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{

    new String:model[256];

    new client = GetClientOfUserId(GetEventInt(event, "userid"));
    KvJumpToKey(playermodelskv,authid[client],true);

    if (GetClientTeam(client) == TEAM_AMER)
    {
        KvGetString(playermodelskv, "Team1", model, sizeof(model));
    }
    else if (GetClientTeam(client) == TEAM_AXIS)
    {
        KvGetString(playermodelskv, "Team2", model, sizeof(model));
    }

    if (!StrEqual(model,"") && IsModelPrecached(model))
    {
            SetEntityModel(client, model);
            SetEntityRenderColor(client, 255, 255, 255, 255);
    }
    KvRewind(playermodelskv);
}



This also works for DOD:Source with models.ini

Can someone fix this code, and add a option for "default skin" and to be used with custom6 / t flag users.


Code:
#include <sourcemod>
#include <sdktools>

//need a player spawn function to reset models every round
//also need to load and save players current models selection ( t & ct) from kv

new Handle:mainmenu
new Handle:kv
new Handle:playermodelskv
new Handle:cvarAnnounce = INVALID_HANDLE;

new String:authid[MAXPLAYERS+1][35]

#define TEAM2 1
#define TEAM1 0

#define PLUGIN_VERSION "0.14"

public Plugin:myinfo =
{
    name = "Model Menu",
    author = "pRED*",
    description = "Menu to select player models",
    version = PLUGIN_VERSION,
    url = "http://www.sourcemod.net/"
};

public OnPluginStart()
{
    RegConsoleCmd("sm_models",Command_Model)
    CreateConVar("sm_modelmenu_version", PLUGIN_VERSION, "Super Commands Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY)
    cvarAnnounce = CreateConVar("sm_modelmenu_announce", "1", "Announcement preferences");

    HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_Post)

    new String:file[256]
    BuildPath(Path_SM, file, 255, "data/playermodels.ini")
    playermodelskv = CreateKeyValues("Models")
    FileToKeyValues(playermodelskv, file)
    
}

public Action:TimerAnnounce(Handle:timer, any:client)
{
	if(IsClientInGame(client))
		PrintToChat(client, "Say !models or /models to set your models preferences");
}

public OnPluginEnd()
{
    new String:file[256]
    BuildPath(Path_SM, file, 255, "data/playermodels.ini")
    KeyValuesToFile(playermodelskv, file)
    CloseHandle(playermodelskv)
}

public OnMapStart()
{
    //open precache file and add everything to download table
    new String:file[256]
    BuildPath(Path_SM, file, 255, "configs/modeldownloads.ini")
    new Handle:fileh = OpenFile(file, "r")
    new String:buffer[256]
    
    while (ReadFileLine(fileh, buffer, sizeof(buffer)))
    {
        new len = strlen(buffer)
        if (buffer[len-1] == '\n')
            buffer[--len] = '\0'

        if (FileExists(buffer))
        {
            AddFileToDownloadsTable(buffer)
        }

        if (IsEndOfFile(fileh))
            break
    }
}

public OnMapEnd()
{
    CloseHandle(kv)
    CloseHandle(mainmenu)
}

public OnClientPutInServer(client)
{
    GetClientAuthString(client, authid[client], sizeof(authid[]))
	
    mainmenu = BuildMainMenu()
	
        // Make the announcement in 30 seconds unless announcements are turned off
    if(GetConVarBool(cvarAnnounce))
        CreateTimer(60.0, TimerAnnounce, client);
}

Handle:BuildMainMenu()
{
    /* Create the menu Handle */
    new Handle:menu = CreateMenu(Menu_Group)

    kv = CreateKeyValues("Commands")
    new String:file[256]
    BuildPath(Path_SM, file, 255, "configs/models.ini")
    FileToKeyValues(kv, file)

    if (!KvGotoFirstSubKey(kv))
    {
        return INVALID_HANDLE
    }

    decl String:buffer[30]
    decl String:path[100]
    
    do
    {
        KvGetSectionName(kv, buffer, sizeof(buffer))
        AddMenuItem(menu,buffer,buffer)
        KvJumpToKey(kv, "Team1")
        KvGotoFirstSubKey(kv)

        do
        {
            KvGetString(kv, "path", path, sizeof(path),"")
            
            if (FileExists(path))
            {
                PrecacheModel(path,true)
                AddFileToDownloadsTable(path)
            }

        } while (KvGotoNextKey(kv))

        KvGoBack(kv)
        KvGoBack(kv)
        KvJumpToKey(kv, "Team2")
        KvGotoFirstSubKey(kv)
        do
        {
            KvGetString(kv, "path", path, sizeof(path),"")
            if (FileExists(path))
            {
                PrecacheModel(path,true)
                AddFileToDownloadsTable(path)
            }
        } while (KvGotoNextKey(kv))

        KvGoBack(kv)
        KvGoBack(kv)

    } while (KvGotoNextKey(kv))

    KvRewind(kv)
    SetMenuTitle(menu, "Choose a Model")
    return menu
}

public Action:Command_Model(client,args)
{
    if (mainmenu == INVALID_HANDLE)
    {
        PrintToConsole(client, "There was an error generating the menu. Check your models.ini file")
        return Plugin_Handled
    }

    DisplayMenu(mainmenu, client, MENU_TIME_FOREVER)
    return Plugin_Handled
}

public Menu_Group(Handle:menu, MenuAction:action, param1, param2)
{
    // user has selected a model group

    if (action == MenuAction_Select)
    {
        new String:info[30]

        /* Get item info */
        new bool:found = GetMenuItem(menu, param2, info, sizeof(info))

        if (!found)
            return

        // user selected a group
        // advance kv to this group
        KvJumpToKey(kv, info)

        // check if they have access
        new String:group[30]
        
        // check users team
        if (GetClientTeam(param1) == 2)
        {
            KvJumpToKey(kv, "Team1")
        }
        else if (GetClientTeam(param1) == 3)
        {
            KvJumpToKey(kv, "Team2")
        }
        else
            return

        // build menu
        // name - path
        KvGotoFirstSubKey(kv)
        new Handle:tempmenu = CreateMenu(Menu_Model)

        decl String:buffer[30]
        decl String:path[256]
        do
        {
            KvGetSectionName(kv, buffer, sizeof(buffer))
            KvGetString(kv, "path", path, sizeof(path),"")
            AddMenuItem(tempmenu,path,buffer)

        } while (KvGotoNextKey(kv))

        SetMenuTitle(tempmenu, group)
        KvRewind(kv)
        DisplayMenu(tempmenu, param1, MENU_TIME_FOREVER)
    }
}

public Menu_Model(Handle:menu, MenuAction:action, param1, param2)
{
    //user choose a model

    if (action == MenuAction_Select)
    {
        new String:info[256]
        new String:group[30]

        /* Get item info */
        new bool:found = GetMenuItem(menu, param2, info, sizeof(info))
        GetMenuTitle(menu, group, sizeof(group))

        if (!found)
            return

        // set users model
        //insert magic here.
        if (!StrEqual(info,"") && IsModelPrecached(info) && IsClientConnected(param1))
        {
            LogMessage("Setting Model for client %i: %s",param1,info)
            SetEntityModel(param1, info)
            //SDKCall(hSetModel, param1, info)
        }

        KvJumpToKey(playermodelskv,authid[param1],true)

        if (GetClientTeam(param1) == 2)
        {
            KvSetString(playermodelskv, "Team1", info)
            KvSetString(playermodelskv, "Team1Group", group)
        }
        else if (GetClientTeam(param1) == 3)
        {
            KvSetString(playermodelskv, "Team2", info)
            KvSetString(playermodelskv, "Team1Group", group)
        }
        KvRewind(playermodelskv)
    }

    if (action == MenuAction_End)
    {
        CloseHandle(menu)
    }
}

public Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new client = GetClientOfUserId(GetEventInt(event, "userid"))

    KvJumpToKey(playermodelskv,authid[client],true)

    new String:model[256]
    new String:group[30]

    if (GetClientTeam(client) == 2)
    {
        KvGetString(playermodelskv, "Team1", model, sizeof(model))
        KvGetString(playermodelskv, "Team1Group", group, sizeof(group))
    }
    else if (GetClientTeam(client) == 3)
    {
        KvGetString(playermodelskv, "Team2", model, sizeof(model))
        KvGetString(playermodelskv, "Team2Group", group, sizeof(group))
    }

    if (!StrEqual(model,"") && IsModelPrecached(model))
    {
        SetEntityModel(client, model)
        //SDKCall(hSetModel, client, model)
    }

    KvRewind(playermodelskv)
}
__________________

Last edited by ph; 02-04-2009 at 22:24.
ph is offline
klink
Junior Member
Join Date: Feb 2009
Old 02-05-2009 , 13:09   Re: Model Menu
Reply With Quote #289

Code:
[SM] Native "ReadFileLine" reported: Invalid file handle 0 (error 4)
[SM] Displaying call stack trace for plugin "ModelMenu.smx":
[SM]   [0]  Line 70, /home/groups/alliedmodders/forums/files/2/3/7/6/2/19007.attach::OnMapStart()
i get this error.
klink is offline
Michael_a90
Junior Member
Join Date: Dec 2007
Old 02-08-2009 , 14:39   Re: Model Menu
Reply With Quote #290

Hi. Can anyone tell me step-by-step how to do this?
No matter what i try, i can't get i working.
Thanks
Michael_a90 is offline
Reply



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 17:54.


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