Thread: Fake Lampa
View Single Post
Exta5y
New Member
Join Date: Jan 2010
Old 01-04-2010 , 23:39   Re: Fake Lampa
Reply With Quote #24

Hi all, I did it. Menu is work.

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <xs>

/* 
Fake Lampa 
  Improven the Light on the dark map
*/

#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)

new const FK8888_model[][] = {    "models/FK8888.mdl" }            // model
new const FK8888_classname[]     = "FK8888"

new g_FKlen;
new 
fsaytext;
new 
g_FKet[33] = 0;

new 
AccessFlag ADMIN_CVAR

public plugin_init() 
{
    
register_plugin("Fake LAMPA""2.0""Katakuna")
    
    
register_clcmd("FKADD""CFK8888", -1)
    
register_clcmd("FKDEL""RFK8888", -1)
    
register_clcmd("FKSAVE""SFK8888n", -1)
    
/* Meniu More Great Ideea*/
    
register_clcmd("say /FKMENU","FKOPEN_MENU",0)
    
register_clcmd("say_team /FKMENU","FKOPEN_MENU",0)
    
register_clcmd("FKMENU","FKOPEN_MENU",0)
    
fsaytext get_user_msgid("fsaytext")


}

public 
plugin_precache()
{
    
precache_model("models/FK8888.mdl")
}

//public plugin_menu() {
public FKOPEN_MENU(id) {
    
g_FKlen menu_create("\rFake Lampa Menu","FKMENU_HANDLER");
    
    
menu_additem(g_FKlen,"\wFake Lampa \rAdd !","1",0);
    
menu_additem(g_FKlen,"\wFake Lampa \rRemove !","2",0);
    
menu_additem(g_FKlen,"\wFake Lampa \rSave !","3",0);
    
    
menu_setprop(g_FKlen,MPROP_EXIT,MEXIT_ALL)
    
    
menu_display(id,g_FKlen,0)
}

/*
public FKOPEN_MENU(id) {
    if(!is_user_connected(id)) return;
    menu_display(id,g_FKlen,0);
}
*/

public FKMENU_HANDLER(id,menu,item){
    
    if(
item == MENU_EXIT)
    {
        return 
PLUGIN_HANDLED;
    }

    static 
data[10],iName[64],iAccess,callback;
    
menu_item_getinfo(menu,item,iAccess,data,9,iName,63,callback);
    new 
key str_to_num(data);
    new 
Buffer[128];
    
    switch(
key){
        
        case 
1: {
            
console_cmd(id"FKADD"/* Add Fake Lampa */            
            
formatex(Buffer,127,"^x03Fake Lampa Menu^x01 Fake Lampa Added !")
            
g_FKet[id] = 1;
            
menu_display(id,g_FKlen,0)
        }
        case 
2: {
            
console_cmd(id"FKDEL"/* Remov Fake Lampa */
            
formatex(Buffer,127,"^x03Fake Lampa Menu^x01 Fake Lampa Remove !")
            
g_FKet[id] = 2;
            
menu_display(id,g_FKlen,0)
        }
        case 
3: {
            
console_cmd(id"FKSAVE"/* Save Fake Lampa */            
            
formatex(Buffer,127,"^x03Fake Lampa Menu^x01 Fake Lampa Saved !")
            
g_FKet[id] = 3;
            
menu_display(id,g_FKlen,0)
        }
    }
    
/*
    message_begin(MSG_ONE,fsaytext,_,id)
    write_byte(id);
    write_string(Buffer);
    message_end();
    */
    
return PLUGIN_HANDLED;
}


public 
plugin_cfg()
{
    static 
ConfigsDir[64], File[64], MapName[32]
    
    
get_configsdir(ConfigsDirsizeof ConfigsDir 1)
    
get_mapname(MapNamesizeof MapName 1)
    
    
formatex(Filesizeof File 1"%s/%s_FK8888.cfg"ConfigsDirMapName)

    if(!
file_exists(File))
        return 
1
    
    
static FileOrigin[3][32], FileAngles[3][32], LineLengthBuffer[256]
    static 
Temp1[128], Temp2[128]
    static 
Float:fOrigin[3], Float:fAngles[3]
    
    while(
read_file(FileLine++, Buffersizeof Buffer 1Length))
    {
        if((
Buffer[0]==';') || !Length)
            continue
        
        
strtok(BufferTemp1sizeof Temp1 1Temp2sizeof Temp2 1'|'0)
        
        
parse(Temp1FileOrigin[0], sizeof FileOrigin[] - 1FileOrigin[1], sizeof FileOrigin[] - 1FileOrigin[2], sizeof FileOrigin[] - 1)
        
        
fOrigin[0] = str_to_float(FileOrigin[0])
        
fOrigin[1] = str_to_float(FileOrigin[1])
        
fOrigin[2] = str_to_float(FileOrigin[2])
        
        
parse(Temp2FileAngles[0], sizeof FileAngles[] - 1FileAngles[1], sizeof FileAngles[] - 1FileAngles[2], sizeof FileAngles[] - 1)
        
        
fAngles[0] = str_to_float(FileAngles[0])
        
fAngles[1] = str_to_float(FileAngles[1])
        
fAngles[2] = str_to_float(FileAngles[2])
        
        static 
ent
        ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
        
        if(!
ent)
            return 
0
        
        engfunc
(EngFunc_SetOriginentfOrigin)
        
set_pev(entpev_anglesfAngles)
        
        
engfunc(EngFunc_SetModelentFK8888_model[random_num(0,sizeof FK8888_model 1)])
        
set_pev(entpev_classnameFK8888_classname)
        
        
dllfunc(DLLFunc_Spawnent)
        
set_pev(entpev_solidSOLID_BBOX)
        
set_pev(entpev_takedamage,DAMAGE_NO)
        
set_pev(entpev_movetypeMOVETYPE_NONE)
        
set_pev(entpev_effects, (EF_BRIGHTLIGHT))
        
engfunc(EngFunc_AllocStringent ,"func_wall")
        
engfunc(EngFunc_SetSizeentFloat:{ -4.0, -4.0, -4.0 }, Float:{ 4.04.04.0 } );
    }
    return 
1
}

public 
CFK8888(id)
{
    if(!
access(idAccessFlag))
        return 
1
    
    
static Float:fAimOrigin[3]
    
fm_get_aimorigin(idfAimOrigin)
    
    
// create a new entity 
    // set a name to the entity
    
if((engfunc(EngFunc_PointContentsfAimOrigin) != CONTENTS_SKY) && (engfunc(EngFunc_PointContentsfAimOrigin) != CONTENTS_SOLID))
    {
        static 
ent
        ent 
engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString"info_target"))
        
        if(!
ent)
            return 
0
        
        engfunc
(EngFunc_SetOriginentfAimOrigin)
        
engfunc(EngFunc_SetModelentFK8888_model[random_num(0,sizeof FK8888_model 1)])
    
        
set_pev(entpev_classnameFK8888_classname)
    
        
dllfunc(DLLFunc_Spawnent)
        
set_pev(entpev_solidSOLID_BBOX)
        
set_pev(entpev_takedamage,DAMAGE_NO)
        
set_pev(entpev_movetypeMOVETYPE_NONE)
        
set_pev(entpev_effects, (EF_BRIGHTLIGHT))
        
engfunc(EngFunc_AllocStringent ,"func_wall")
        
engfunc(EngFunc_SetSizeentFloat:{ -4.0, -4.0, -4.0 }, Float:{ 4.04.04.0 } );
        
engfunc(EngFunc_DropToFloorent)
    }
    else
        
client_print(idprint_chat"This location is forbite")
    return 
0
}

public 
RFK8888(id)
{
    if(!
access(idAccessFlag))
        return 
1
    
    
static entiBody
    get_user_aiming
(identiBody)
    
    if(
pev_valid(ent))
    {
        static 
sClassname[32]
        
pev(entpev_classnamesClassnamesizeof sClassname 1)
        
        if(!
strcmp(sClassnameFK8888_classname1))
        {
            
engfunc(EngFunc_RemoveEntityent)
            
            
client_print(idprint_chat"FK8888 DELETE")
        }
        else
            
client_print(idprint_chat"FK8888 NOT FOUND")
    }
    return 
0
}    

public 
SFK8888n(id)
{
    if(!
access(idAccessFlag))
        return 
1

    
    
static ConfigsDir[64], File[64], Buffer[256], MapName[32]
    
    
get_configsdir(ConfigsDirsizeof ConfigsDir 1)
    
get_mapname(MapNamesizeof MapName 1)
    
    
formatex(Filesizeof File 1"%s/%s_FK8888.cfg"ConfigsDirMapName)
    
    if(
file_exists(File))
        
delete_file(File)
    
    new 
ent = -1Float:fEntOrigin[3], Float:fEntAngles[3]
    
    while((
ent engfunc(EngFunc_FindEntityByStringent"classname"FK8888_classname)))
    {
        
pev(entpev_originfEntOrigin)
        
pev(entpev_anglesfEntAngles)
        
        
formatex(Buffersizeof Buffer 1"%f %f %f | %f %f %f"fEntOrigin[0], fEntOrigin[1], fEntOrigin[2], fEntAngles[0], fEntAngles[1], fEntAngles[2])
        
        
write_file(FileBuffer, -1)
    }
    
client_print(idprint_chat"FK8888 SAVED %s"MapName)
    
    return 
0
}


/* credited to VEN - fakemeta_util.inc */
stock fm_get_aimorigin(indexFloat:origin[3])
{
    new 
Float:start[3], Float:view_ofs[3];
    
pev(indexpev_originstart);
    
pev(indexpev_view_ofsview_ofs);
    
xs_vec_add(startview_ofsstart);
    
    new 
Float:dest[3];
    
pev(indexpev_v_angledest);
    
engfunc(EngFunc_MakeVectorsdest);
    
global_get(glb_v_forwarddest);
    
xs_vec_mul_scalar(dest9999.0dest);
    
xs_vec_add(startdestdest);
    
    
engfunc(EngFunc_TraceLinestartdest0index0);
    
get_tr2(0TR_vecEndPosorigin);
    
    return 
1;

p.s.
sorry for my bad english
Exta5y is offline