Официалният форум на iPlay.bg 

В този раздел можете да подадете заявка за преработка на даден плъгин. Имайте предвид, че задължително трябва да преодставите кода на въпросния плъгин.
 #388737  от br3akche :]
 ср апр 27, 2016 9:30 pm
Здравейте, някой може ли да ми редактира cso costume plugin-а, тоест аз съм го направил нещо като вида на hats така че, да показва коя шапка/костюм използваш в момента? Ето го и кода (малко редактиран от мен):
Код: Избери всички
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "[CSO] Costume"
#define VERSION "1.0"
#define AUTHOR "Dias"

#define MAX_COSTUME 11
#define MAX_COSTUMEPART 4

#define COSTUME_THINKDELAY 5.0

#define COSTUME_CLASSNAME "costume"
#define COSTUME_URL "models/costumes"

new const CostumeName[MAX_COSTUME][] =
{
    "Angel",
    "Cat",
    "Clock",
    "Devil",
    "Gold",
    "Panda",
    "Pig",
    "Polar Bear",
    "Pumpkin",
    "Snow",
    "Squirrel"
}

new const CostumePart[MAX_COSTUME] =
{
    2,
    4,
    1,
    3,
    2,
    4,
    4,
    2,
    2,
    2,
    4
}

new const CostumeBack[MAX_COSTUME][] =
{
    "angel_back.mdl",
    "cat_back.mdl",
    "clock_back.mdl",
    "devil_back.mdl",
    "gold_back.mdl",
    "panda_back.mdl",
    "pig_back.mdl",
    "polarbear_back.mdl",
    "pumpkin_back.mdl",
    "snow_back.mdl",
    "squirrel_back.mdl"
}

new const CostumeFace[MAX_COSTUME][] = 
{
    "angel_head.mdl",
    "cat_face.mdl",
    "",
    "",
    "",
    "panda_face.mdl",
    "pig_face.mdl",
    "",
    "",
    "",
    "squirrel_face.mdl"
}

new const CostumeHead[MAX_COSTUME][] =
{
    "",
    "cat_head.mdl",
    "",
    "devil_head.mdl",
    "gold_head.mdl",
    "panda_head.mdl",
    "pig_head.mdl",
    "polarbear_head.mdl",
    "pumpkin_head.mdl",
    "snow_head.mdl",
    "squirrel_head.mdl"
}

new const CostumePelvis[MAX_COSTUME][] =
{
    "",
    "cat_pelvis.mdl",
    "",
    "devil_pelvis.mdl",
    "",
    "panda_pelvis.mdl",
    "pig_pelvis.mdl",
    "",
    "",
    "",
    "squirrel_pelvis.mdl"
}

enum
{
    COSTUME_BACK = 0,
    COSTUME_FACE,
    COSTUME_HEAD,
    COSTUME_PELVIS
}

new g_MyCostumeID[33], g_MyCostumeEnt[33][MAX_COSTUME]
new g_MaxPlayers, g_MsgSayText

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    g_MaxPlayers = get_maxplayers()
    g_MsgSayText = get_user_msgid("SayText")

    RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
    register_clcmd("say /hats", "Open_CostumeMenu")
}

public client_putinserver(id)
{
    Reset_AllCostume(id)
    g_MyCostumeID[id] = -1
}

public client_disconnect(id)
{
    Reset_AllCostume(id)
    g_MyCostumeID[id] = -1
}

public plugin_precache()
{
    static Buffer[128]
    
    for(new i = 0; i < MAX_COSTUME; i++)
    {
        // Precache Costume's Back
        if(!equal(CostumeBack[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeBack[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
            
        // Precache Costume's Face
        if(!equal(CostumeFace[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeFace[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
        
        // Precache Costume's Head
        if(!equal(CostumeHead[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeHead[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
        
        // Precache Costume's Pelvis
        if(!equal(CostumePelvis[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumePelvis[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
    }
}

public fw_PlayerSpawn_Post(id) set_task(random_float(0.1, 0.25), "Delay_SpawnPost", id)
public Delay_SpawnPost(id)
{
    Reset_AllCostume(id)
    if(g_MyCostumeID[id] != -1) Set_PlayerCostume(id, g_MyCostumeID[id])
}

public Open_CostumeMenu(id)
{
    if(!is_user_connected(id))
        return
        
    static Menu; Menu = menu_create("\rMenu s shapki^n\yV momenta izpolzvash:\r %s^n\yStranica:\d", "MenuHandle_CostumeSelect")
    static CostumeNameIn[64], CostumeID[4]
    
    menu_additem(Menu, "Premahnete shapkata si", "nouse")
    for(new i = 0; i < MAX_COSTUME; i++)
    {
        formatex(CostumeNameIn, sizeof(CostumeNameIn), "%s \y(%i)\w", CostumeName[i], CostumePart[i])
        num_to_str(i, CostumeID, sizeof(CostumeID))
    
        menu_additem(Menu, CostumeNameIn, CostumeID)
    }
    
    menu_setprop(Menu, MPROP_BACKNAME, "\yPredishna stranica")
    menu_setprop(Menu, MPROP_NEXTNAME, "\ySledvashta stranica")
    menu_setprop(Menu, MPROP_EXITNAME, "\rIzhod ot menuto")
    
    menu_display(id, Menu, 0)
}

public MenuHandle_CostumeSelect(id, Menu, Item)
{
    if(!is_user_connected(id) || Item == MENU_EXIT)
    {
        menu_destroy(Menu)
        return
    }

    static Name[32], Data[8], ItemAccess, ItemCallback
    menu_item_getinfo(Menu, Item, ItemAccess, Data, charsmax(Data), Name, charsmax(Name), ItemCallback)

    if(Data[0] == 'n' && Data[2] == 'u')
    {
        Reset_AllCostume(id)
        g_MyCostumeID[id] = -1
        
        client_printc(id, "!g[!tHats!g]!n Premahnate shapkata si!")
        
        return
    }
    static CostumeID; CostumeID = str_to_num(Data)
    if(CostumeID >= MAX_COSTUME)
    {
        menu_destroy(Menu)
        return
    }
    
    g_MyCostumeID[id] = CostumeID
    client_printc(id, "!g[!tHats!g]!n Izbra shapkata !t%s!n.", CostumeName[CostumeID])
    
    if(is_user_alive(id)) 
    {
        Reset_AllCostume(id)
        Set_PlayerCostume(id, CostumeID)
    }
}

public Set_PlayerCostume(id, CostumeID)
{
    static CostumeModel[128]
    
    // Costume: Back
    if(!equal(CostumeBack[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeBack[CostumeID])
        g_MyCostumeEnt[id][COSTUME_BACK] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_BACK)
    }
    
    // Costume: Face
    if(!equal(CostumeFace[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeFace[CostumeID])
        g_MyCostumeEnt[id][COSTUME_FACE] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_FACE)
    }
    
    // Costume: Head
    if(!equal(CostumeHead[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeHead[CostumeID])
        g_MyCostumeEnt[id][COSTUME_HEAD] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_HEAD)
    }
    
    // Costume: Pelvis
    if(!equal(CostumePelvis[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumePelvis[CostumeID])
        g_MyCostumeEnt[id][COSTUME_PELVIS] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_PELVIS)
    }
}

public Create_CostumeModel(id, Model[], CostumeID, Part)
{
    static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    if(!pev_valid(Ent)) return 0
    
    static Float:Origin[3]; pev(id, pev_origin, Origin)
    set_pev(Ent, pev_origin, Origin)
    
    set_pev(Ent, pev_dmg_take, DAMAGE_NO)
    set_pev(Ent, pev_health, 100.0)
    
    set_pev(Ent, pev_classname, COSTUME_CLASSNAME)
    engfunc(EngFunc_SetModel, Ent, Model)
    set_pev(Ent, pev_solid, SOLID_NOT)
    set_pev(Ent, pev_movetype, MOVETYPE_FOLLOW)
    
    set_pev(Ent, pev_aiment, id)
    set_pev(Ent, pev_owner, id)
    set_pev(Ent, pev_nextthink, get_gametime())
    
    set_pev(Ent, pev_animtime, get_gametime())
    set_pev(Ent, pev_framerate, 1.0)
    set_pev(Ent, pev_sequence, 0)
    
    return Ent
}

/*
public fw_Costume_Think(Ent)
{
    if(!pev_valid(Ent))
        return
        
    static Id; Id = pev(Ent, pev_owner)
    if(!is_user_connected(Id))
        return
        
    static IntVar, Float:FloatVar, Color[3]
    
    pev(Id, pev_renderamt, FloatVar); set_pev(Ent, pev_renderamt, FloatVar)
    pev(Id, pev_rendercolor, Color); set_pev(Ent, pev_rendercolor, Color)
    IntVar = pev(Id, pev_renderfx); set_pev(Ent, pev_renderfx, IntVar)
    IntVar = pev(Id, pev_rendermode); set_pev(Ent, pev_rendermode, IntVar)
        
    client_print(Id, print_chat, "Amt: %f | FX: %i | Mode: %i", FloatVar, pev(Id, pev_renderfx), pev(Id, pev_rendermode))
        
    // Set Next Think
    set_pev(Ent, pev_nextthink, get_gametime() + COSTUME_THINKDELAY)
}*/

public Reset_AllCostume(id)
{
    Reset_CostumePart(id, COSTUME_BACK)
    Reset_CostumePart(id, COSTUME_FACE)
    Reset_CostumePart(id, COSTUME_HEAD)
    Reset_CostumePart(id, COSTUME_PELVIS)
}

public Reset_CostumePart(id, Part)
{
    if(IsValid_CostumeEnt(id, Part)) engfunc(EngFunc_RemoveEntity, Get_CostumeEnt(id, Part))
}

public IsValid_CostumeEnt(id, Part)
{
    return pev_valid(g_MyCostumeEnt[id][Part])
}

public Get_CostumeEnt(id, Part)
{
    return g_MyCostumeEnt[id][Part]
}

stock client_printc(index, const text[], any:...)
{
    static szMsg[128]; vformat(szMsg, sizeof(szMsg) - 1, text, 3)

    replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04")
    replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01")
    replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03")

    if(!index)
    {
        for(new i = 0; i < g_MaxPlayers; i++)
        {
            if(!is_user_connected(i))
                continue
                
            message_begin(MSG_ONE_UNRELIABLE, g_MsgSayText, _, i);
            write_byte(i);
            write_string(szMsg);
            message_end();    
        }        
    } else {
        message_begin(MSG_ONE_UNRELIABLE, g_MsgSayText, _, index);
        write_byte(index);
        write_string(szMsg);
        message_end();
    }
} 
 #388738  от OciXCrom™
 ср апр 27, 2016 9:31 pm
Код: Избери всички
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "[CSO] Costume"
#define VERSION "1.0"
#define AUTHOR "Dias"

#define MAX_COSTUME 11
#define MAX_COSTUMEPART 4

#define COSTUME_THINKDELAY 5.0

#define COSTUME_CLASSNAME "costume"
#define COSTUME_URL "models/hats"

new const CostumeName[MAX_COSTUME][] =
{
    "Angel",
    "Cat",
    "Clock",
    "Devil",
    "Gold",
    "Panda",
    "Pig",
    "Polar Bear",
    "Pumpkin",
    "Snow",
    "Squirrel"
}

new const CostumePart[MAX_COSTUME] =
{
    2,
    4,
    1,
    3,
    2,
    4,
    4,
    2,
    2,
    2,
    4
}

new const CostumeBack[MAX_COSTUME][] =
{
    "angel_back.mdl",
    "cat_back.mdl",
    "clock_back.mdl",
    "devil_back.mdl",
    "gold_back.mdl",
    "panda_back.mdl",
    "pig_back.mdl",
    "polarbear_back.mdl",
    "pumpkin_back.mdl",
    "snow_back.mdl",
    "squirrel_back.mdl"
}

new const CostumeFace[MAX_COSTUME][] = 
{
    "angel_head.mdl",
    "cat_face.mdl",
    "",
    "",
    "",
    "panda_face.mdl",
    "pig_face.mdl",
    "",
    "",
    "",
    "squirrel_face.mdl"
}

new const CostumeHead[MAX_COSTUME][] =
{
    "",
    "cat_head.mdl",
    "",
    "devil_head.mdl",
    "gold_head.mdl",
    "panda_head.mdl",
    "pig_head.mdl",
    "polarbear_head.mdl",
    "pumpkin_head.mdl",
    "snow_head.mdl",
    "squirrel_head.mdl"
}

new const CostumePelvis[MAX_COSTUME][] =
{
    "",
    "cat_pelvis.mdl",
    "",
    "devil_pelvis.mdl",
    "",
    "panda_pelvis.mdl",
    "pig_pelvis.mdl",
    "",
    "",
    "",
    "squirrel_pelvis.mdl"
}

enum
{
    COSTUME_BACK = 0,
    COSTUME_FACE,
    COSTUME_HEAD,
    COSTUME_PELVIS
}

new g_MyCostumeID[33], g_MyCostumeEnt[33][MAX_COSTUME]
new g_MaxPlayers, g_MsgSayText

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    g_MaxPlayers = get_maxplayers()
    g_MsgSayText = get_user_msgid("SayText")

    RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
    register_clcmd("say /hats", "Open_CostumeMenu")
}

public client_putinserver(id)
{
    Reset_AllCostume(id)
    g_MyCostumeID[id] = -1
}

public client_disconnect(id)
{
    Reset_AllCostume(id)
    g_MyCostumeID[id] = -1
}

public plugin_precache()
{
    static Buffer[128]
    
    for(new i = 0; i < MAX_COSTUME; i++)
    {
        // Precache Costume's Back
        if(!equal(CostumeBack[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeBack[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
            
        // Precache Costume's Face
        if(!equal(CostumeFace[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeFace[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
        
        // Precache Costume's Head
        if(!equal(CostumeHead[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeHead[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
        
        // Precache Costume's Pelvis
        if(!equal(CostumePelvis[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumePelvis[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
    }
}

public fw_PlayerSpawn_Post(id) set_task(random_float(0.1, 0.25), "Delay_SpawnPost", id)
public Delay_SpawnPost(id)
{
    Reset_AllCostume(id)
    if(g_MyCostumeID[id] != -1) Set_PlayerCostume(id, g_MyCostumeID[id])
}

public Open_CostumeMenu(id)
{
    if(!is_user_connected(id))
        return
        
    new szTitle[256], iHat = g_MyCostumeID[id]
    formatex(szTitle, charsmax(szTitle), "\rMenu s shapki^n\yV momenta izpolzvash:\r %s^n\yStranica:\d", (iHat != -1) ? CostumeName[iHat] : "none")
    static Menu; Menu = menu_create(szTitle, "MenuHandle_CostumeSelect")
    static CostumeNameIn[64], CostumeID[4]
    
    menu_additem(Menu, "\rPremahnete shapkata si", "nouse")
    for(new i = 0; i < MAX_COSTUME; i++)
    {
        formatex(CostumeNameIn, sizeof(CostumeNameIn), "%s \y(%i)\w", CostumeName[i], CostumePart[i])
        num_to_str(i, CostumeID, sizeof(CostumeID))
    
        menu_additem(Menu, CostumeNameIn, CostumeID)
    }
    
    menu_setprop(Menu, MPROP_BACKNAME, "\yPredishna stranica")
    menu_setprop(Menu, MPROP_NEXTNAME, "\ySledvashta stranica")
    menu_setprop(Menu, MPROP_EXITNAME, "\rIzhod ot menuto")
    
    menu_display(id, Menu, 0)
}

public MenuHandle_CostumeSelect(id, Menu, Item)
{
    if(!is_user_connected(id) || Item == MENU_EXIT)
    {
        menu_destroy(Menu)
        return
    }

    static Name[32], Data[8], ItemAccess, ItemCallback
    menu_item_getinfo(Menu, Item, ItemAccess, Data, charsmax(Data), Name, charsmax(Name), ItemCallback)

    if(Data[0] == 'n' && Data[2] == 'u')
    {
        Reset_AllCostume(id)
        g_MyCostumeID[id] = -1
        
        client_printc(id, "!g[!tHats!g]!n Premahna shapkata si!")
        
        return
    }
    static CostumeID; CostumeID = str_to_num(Data)
    if(CostumeID >= MAX_COSTUME)
    {
        menu_destroy(Menu)
        return
    }
    
    g_MyCostumeID[id] = CostumeID
    client_printc(id, "!g[!tHats!g]!n Izbra shapkata !t%s!n.", CostumeName[CostumeID])
    
    if(is_user_alive(id)) 
    {
        Reset_AllCostume(id)
        Set_PlayerCostume(id, CostumeID)
    }
}

public Set_PlayerCostume(id, CostumeID)
{
    static CostumeModel[128]
    
    // Costume: Back
    if(!equal(CostumeBack[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeBack[CostumeID])
        g_MyCostumeEnt[id][COSTUME_BACK] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_BACK)
    }
    
    // Costume: Face
    if(!equal(CostumeFace[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeFace[CostumeID])
        g_MyCostumeEnt[id][COSTUME_FACE] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_FACE)
    }
    
    // Costume: Head
    if(!equal(CostumeHead[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeHead[CostumeID])
        g_MyCostumeEnt[id][COSTUME_HEAD] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_HEAD)
    }
    
    // Costume: Pelvis
    if(!equal(CostumePelvis[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumePelvis[CostumeID])
        g_MyCostumeEnt[id][COSTUME_PELVIS] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_PELVIS)
    }
}

public Create_CostumeModel(id, Model[], CostumeID, Part)
{
    static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    if(!pev_valid(Ent)) return 0
    
    static Float:Origin[3]; pev(id, pev_origin, Origin)
    set_pev(Ent, pev_origin, Origin)
    
    set_pev(Ent, pev_dmg_take, DAMAGE_NO)
    set_pev(Ent, pev_health, 100.0)
    
    set_pev(Ent, pev_classname, COSTUME_CLASSNAME)
    engfunc(EngFunc_SetModel, Ent, Model)
    set_pev(Ent, pev_solid, SOLID_NOT)
    set_pev(Ent, pev_movetype, MOVETYPE_FOLLOW)
    
    set_pev(Ent, pev_aiment, id)
    set_pev(Ent, pev_owner, id)
    set_pev(Ent, pev_nextthink, get_gametime())
    
    set_pev(Ent, pev_animtime, get_gametime())
    set_pev(Ent, pev_framerate, 1.0)
    set_pev(Ent, pev_sequence, 0)
    
    return Ent
}

/*
public fw_Costume_Think(Ent)
{
    if(!pev_valid(Ent))
        return
        
    static Id; Id = pev(Ent, pev_owner)
    if(!is_user_connected(Id))
        return
        
    static IntVar, Float:FloatVar, Color[3]
    
    pev(Id, pev_renderamt, FloatVar); set_pev(Ent, pev_renderamt, FloatVar)
    pev(Id, pev_rendercolor, Color); set_pev(Ent, pev_rendercolor, Color)
    IntVar = pev(Id, pev_renderfx); set_pev(Ent, pev_renderfx, IntVar)
    IntVar = pev(Id, pev_rendermode); set_pev(Ent, pev_rendermode, IntVar)
        
    client_print(Id, print_chat, "Amt: %f | FX: %i | Mode: %i", FloatVar, pev(Id, pev_renderfx), pev(Id, pev_rendermode))
        
    // Set Next Think
    set_pev(Ent, pev_nextthink, get_gametime() + COSTUME_THINKDELAY)
}*/

public Reset_AllCostume(id)
{
    Reset_CostumePart(id, COSTUME_BACK)
    Reset_CostumePart(id, COSTUME_FACE)
    Reset_CostumePart(id, COSTUME_HEAD)
    Reset_CostumePart(id, COSTUME_PELVIS)
}

public Reset_CostumePart(id, Part)
{
    if(IsValid_CostumeEnt(id, Part)) engfunc(EngFunc_RemoveEntity, Get_CostumeEnt(id, Part))
}

public IsValid_CostumeEnt(id, Part)
{
    return pev_valid(g_MyCostumeEnt[id][Part])
}

public Get_CostumeEnt(id, Part)
{
    return g_MyCostumeEnt[id][Part]
}

stock client_printc(index, const text[], any:...)
{
    static szMsg[128]; vformat(szMsg, sizeof(szMsg) - 1, text, 3)

    replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04")
    replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01")
    replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03")

    if(!index)
    {
        for(new i = 0; i < g_MaxPlayers; i++)
        {
            if(!is_user_connected(i))
                continue
                
            message_begin(MSG_ONE_UNRELIABLE, g_MsgSayText, _, i);
            write_byte(i);
            write_string(szMsg);
            message_end();    
        }        
    } else {
        message_begin(MSG_ONE_UNRELIABLE, g_MsgSayText, _, index);
        write_byte(index);
        write_string(szMsg);
        message_end();
    }
} 
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
 
 #388739  от br3akche :]
 ср апр 27, 2016 9:33 pm
Доста бързо и лесно. :D
Ако на някой му се занимава и да го направи така че, да се използва само 1 вид шапка (като оригиналния плъгин) ще е хубаво...
П.С Мерси и не заключвай темата! :)
 #389189  от OciXCrom™
 пон май 02, 2016 10:28 pm
Код: Избери всички
#include <amxmodx>
#include <engine>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

#define PLUGIN "[CSO] Costume"
#define VERSION "1.0"
#define AUTHOR "Dias"

#define MAX_COSTUME 11
#define MAX_COSTUMEPART 4

#define COSTUME_THINKDELAY 5.0

#define COSTUME_CLASSNAME "costume"
#define COSTUME_URL "models/hats"

new const CostumeName[MAX_COSTUME][] =
{
    "Angel",
    "Cat",
    "Clock",
    "Devil",
    "Gold",
    "Panda",
    "Pig",
    "Polar Bear",
    "Pumpkin",
    "Snow",
    "Squirrel"
}

new const CostumePart[MAX_COSTUME] =
{
    2,
    4,
    1,
    3,
    2,
    4,
    4,
    2,
    2,
    2,
    4
}

new const CostumeBack[MAX_COSTUME][] =
{
    "angel_back.mdl",
    "cat_back.mdl",
    "clock_back.mdl",
    "devil_back.mdl",
    "gold_back.mdl",
    "panda_back.mdl",
    "pig_back.mdl",
    "polarbear_back.mdl",
    "pumpkin_back.mdl",
    "snow_back.mdl",
    "squirrel_back.mdl"
}

new const CostumeFace[MAX_COSTUME][] = 
{
    "angel_head.mdl",
    "cat_face.mdl",
    "",
    "",
    "",
    "panda_face.mdl",
    "pig_face.mdl",
    "",
    "",
    "",
    "squirrel_face.mdl"
}

new const CostumeHead[MAX_COSTUME][] =
{
    "",
    "cat_head.mdl",
    "",
    "devil_head.mdl",
    "gold_head.mdl",
    "panda_head.mdl",
    "pig_head.mdl",
    "polarbear_head.mdl",
    "pumpkin_head.mdl",
    "snow_head.mdl",
    "squirrel_head.mdl"
}

new const CostumePelvis[MAX_COSTUME][] =
{
    "",
    "cat_pelvis.mdl",
    "",
    "devil_pelvis.mdl",
    "",
    "panda_pelvis.mdl",
    "pig_pelvis.mdl",
    "",
    "",
    "",
    "squirrel_pelvis.mdl"
}

enum
{
    COSTUME_BACK = 0,
    COSTUME_FACE,
    COSTUME_HEAD,
    COSTUME_PELVIS
}

new g_MyCostumeID[33], g_MyCostumeEnt[33][MAX_COSTUME]
new g_MaxPlayers, g_MsgSayText

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    
    g_MaxPlayers = get_maxplayers()
    g_MsgSayText = get_user_msgid("SayText")

    RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
    register_clcmd("say /hats", "Open_CostumeMenu")
}

public client_putinserver(id)
{
    Reset_AllCostume(id)
    g_MyCostumeID[id] = -1
}

public client_disconnect(id)
{
    Reset_AllCostume(id)
    g_MyCostumeID[id] = -1
}

public plugin_precache()
{
    static Buffer[128]
    
    for(new i = 0; i < MAX_COSTUME; i++)
    {
        // Precache Costume's Back
        if(!equal(CostumeBack[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeBack[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
            
        // Precache Costume's Face
        if(!equal(CostumeFace[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeFace[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
        
        // Precache Costume's Head
        if(!equal(CostumeHead[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumeHead[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
        
        // Precache Costume's Pelvis
        if(!equal(CostumePelvis[i], ""))
        {
            formatex(Buffer, sizeof(Buffer), "%s/%s", COSTUME_URL, CostumePelvis[i])
            engfunc(EngFunc_PrecacheModel, Buffer)
        }
    }
}

public fw_PlayerSpawn_Post(id) set_task(random_float(0.1, 0.25), "Delay_SpawnPost", id)
public Delay_SpawnPost(id)
{
    Reset_AllCostume(id)
    if(g_MyCostumeID[id] != -1) Set_PlayerCostume(id, g_MyCostumeID[id])
}

public Open_CostumeMenu(id)
{
    if(!is_user_connected(id))
        return
        
    new szTitle[256], iHat = g_MyCostumeID[id]
    formatex(szTitle, charsmax(szTitle), "\rMenu s shapki^n\yV momenta izpolzvash:\r %s^n\yStranica:\d", (iHat != -1) ? CostumeName[iHat] : "none")
    static Menu; Menu = menu_create(szTitle, "MenuHandle_CostumeSelect")
    static CostumeNameIn[64], CostumeID[4]
    
    menu_additem(Menu, "\rPremahnete shapkata si", "nouse")
    for(new i = 0; i < MAX_COSTUME; i++)
    {
        formatex(CostumeNameIn, sizeof(CostumeNameIn), "%s \y(%i) %s", CostumeName[i], CostumePart[i], iHat == i ? "\r[IZBRANO]" : "")
        num_to_str(i, CostumeID, sizeof(CostumeID))
    
        menu_additem(Menu, CostumeNameIn, CostumeID)
    }
    
    menu_setprop(Menu, MPROP_BACKNAME, "\yPredishna stranica")
    menu_setprop(Menu, MPROP_NEXTNAME, "\ySledvashta stranica")
    menu_setprop(Menu, MPROP_EXITNAME, "\rIzhod ot menuto")
    
    menu_display(id, Menu, 0)
}

public MenuHandle_CostumeSelect(id, Menu, Item)
{
    if(!is_user_connected(id) || Item == MENU_EXIT)
    {
        menu_destroy(Menu)
        return
    }

    static Name[32], Data[8], ItemAccess, ItemCallback
    menu_item_getinfo(Menu, Item, ItemAccess, Data, charsmax(Data), Name, charsmax(Name), ItemCallback)

    if(Data[0] == 'n' && Data[2] == 'u')
    {
        Reset_AllCostume(id)
        g_MyCostumeID[id] = -1
        
        client_printc(id, "!g[!tHats!g]!n Premahna shapkata si!")
        
        return
    }
    static CostumeID; CostumeID = str_to_num(Data)
    if(CostumeID >= MAX_COSTUME)
    {
        menu_destroy(Menu)
        return
    }
    
    g_MyCostumeID[id] = CostumeID
    client_printc(id, "!g[!tHats!g]!n Izbra shapkata !t%s!n.", CostumeName[CostumeID])
    
    if(is_user_alive(id)) 
    {
        Reset_AllCostume(id)
        Set_PlayerCostume(id, CostumeID)
    }
}

public Set_PlayerCostume(id, CostumeID)
{
    static CostumeModel[128]
    
    // Costume: Back
    if(!equal(CostumeBack[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeBack[CostumeID])
        g_MyCostumeEnt[id][COSTUME_BACK] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_BACK)
    }
    
    // Costume: Face
    if(!equal(CostumeFace[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeFace[CostumeID])
        g_MyCostumeEnt[id][COSTUME_FACE] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_FACE)
    }
    
    // Costume: Head
    if(!equal(CostumeHead[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumeHead[CostumeID])
        g_MyCostumeEnt[id][COSTUME_HEAD] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_HEAD)
    }
    
    // Costume: Pelvis
    if(!equal(CostumePelvis[CostumeID], ""))
    {
        formatex(CostumeModel, sizeof(CostumeModel), "%s/%s", COSTUME_URL, CostumePelvis[CostumeID])
        g_MyCostumeEnt[id][COSTUME_PELVIS] = Create_CostumeModel(id, CostumeModel, CostumeID, COSTUME_PELVIS)
    }
}

public Create_CostumeModel(id, Model[], CostumeID, Part)
{
    static Ent; Ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
    if(!pev_valid(Ent)) return 0
    
    static Float:Origin[3]; pev(id, pev_origin, Origin)
    set_pev(Ent, pev_origin, Origin)
    
    set_pev(Ent, pev_dmg_take, DAMAGE_NO)
    set_pev(Ent, pev_health, 100.0)
    
    set_pev(Ent, pev_classname, COSTUME_CLASSNAME)
    engfunc(EngFunc_SetModel, Ent, Model)
    set_pev(Ent, pev_solid, SOLID_NOT)
    set_pev(Ent, pev_movetype, MOVETYPE_FOLLOW)
    
    set_pev(Ent, pev_aiment, id)
    set_pev(Ent, pev_owner, id)
    set_pev(Ent, pev_nextthink, get_gametime())
    
    set_pev(Ent, pev_animtime, get_gametime())
    set_pev(Ent, pev_framerate, 1.0)
    set_pev(Ent, pev_sequence, 0)
    
    return Ent
}

/*
public fw_Costume_Think(Ent)
{
    if(!pev_valid(Ent))
        return
        
    static Id; Id = pev(Ent, pev_owner)
    if(!is_user_connected(Id))
        return
        
    static IntVar, Float:FloatVar, Color[3]
    
    pev(Id, pev_renderamt, FloatVar); set_pev(Ent, pev_renderamt, FloatVar)
    pev(Id, pev_rendercolor, Color); set_pev(Ent, pev_rendercolor, Color)
    IntVar = pev(Id, pev_renderfx); set_pev(Ent, pev_renderfx, IntVar)
    IntVar = pev(Id, pev_rendermode); set_pev(Ent, pev_rendermode, IntVar)
        
    client_print(Id, print_chat, "Amt: %f | FX: %i | Mode: %i", FloatVar, pev(Id, pev_renderfx), pev(Id, pev_rendermode))
        
    // Set Next Think
    set_pev(Ent, pev_nextthink, get_gametime() + COSTUME_THINKDELAY)
}*/

public Reset_AllCostume(id)
{
    Reset_CostumePart(id, COSTUME_BACK)
    Reset_CostumePart(id, COSTUME_FACE)
    Reset_CostumePart(id, COSTUME_HEAD)
    Reset_CostumePart(id, COSTUME_PELVIS)
}

public Reset_CostumePart(id, Part)
{
    if(IsValid_CostumeEnt(id, Part)) engfunc(EngFunc_RemoveEntity, Get_CostumeEnt(id, Part))
}

public IsValid_CostumeEnt(id, Part)
{
    return pev_valid(g_MyCostumeEnt[id][Part])
}

public Get_CostumeEnt(id, Part)
{
    return g_MyCostumeEnt[id][Part]
}

stock client_printc(index, const text[], any:...)
{
    static szMsg[128]; vformat(szMsg, sizeof(szMsg) - 1, text, 3)

    replace_all(szMsg, sizeof(szMsg) - 1, "!g", "^x04")
    replace_all(szMsg, sizeof(szMsg) - 1, "!n", "^x01")
    replace_all(szMsg, sizeof(szMsg) - 1, "!t", "^x03")

    if(!index)
    {
        for(new i = 0; i < g_MaxPlayers; i++)
        {
            if(!is_user_connected(i))
                continue
                
            message_begin(MSG_ONE_UNRELIABLE, g_MsgSayText, _, i);
            write_byte(i);
            write_string(szMsg);
            message_end();    
        }        
    } else {
        message_begin(MSG_ONE_UNRELIABLE, g_MsgSayText, _, index);
        write_byte(index);
        write_string(szMsg);
        message_end();
    }
} 
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/