Raised This Month: $ Target: $400
 0% 

Need Help Coding BCM


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
mL_
Junior Member
Join Date: Jul 2007
Old 07-04-2007 , 01:23   Re: Need Help Coding BCM
Reply With Quote #3

Bunnyhop Course Maker.

Fatalis deleted his so pretty much i copied everything from fatalis's sma but i changed everything but i dont know how to add new boxes. i deleted one of the boxes in the menu already that i didnt use but i would like to add a box that gives you gravity and a box that heals so many health points per second. I gave FatalisDK TOTAL credit for his work on my new version of the sma. This is what i have so far.
Code:
ORIGINALLY MADE BY FatalisDK. Remade and recoded by mL_ <3
/*
    Coded by mL_<3 (http://www.myspace.com/partymanjapan)
    
    CVARS:
    amx_noslowdown (0|1) - Stop slowdown once you touch a bhop box? (For people new to bhopping)
    
    Chat Commands:
    /bcm - Open the main menu of the plugin - Admins with flag 'u' only.
    
    Console Commands:
    amx_bcm - Open the main menu of the plugin - Admins with flag 'u' only.
*/

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#pragma semicolon 1;

/* Strings */
new const gPLUGIN[] =  "BCM";
new const gVERSION[] =  "0.1-beta";
new const gAUTHOR[] =  "mL_ <3";
new const gMODEL[] = "models/bhopbox.mdl";
new gFile[97];

/* Integers */
new gBhopMenu;
new gNoSlowdown;
new gInfoTarget;
new gTimes[33];

public plugin_init()
{
    register_plugin(gPLUGIN, gVERSION, gAUTHOR);
    
    /* CVARS */
    register_cvar("BCM", gVERSION, FCVAR_SERVER, 0.0);
    gNoSlowdown = register_cvar("amx_noslowdown", "0", 0, 0.0);
    
    /* CLCMDS */
    register_clcmd("say /bcm", "cmdBhopMenu", ADMIN_MENU, "");
    register_clcmd("amx_bcm", "cmdBhopMenu", ADMIN_MENU, "");
    
    /* Forwards */
    register_forward(FM_Touch, "fwdTouch", 0);
    
    /* Events */
    register_event("DeathMsg","evntDeathMsg","a", "");
    
    gBhopMenu = menu_create("BCM by mL_ <3", "mnuBhop");
    menu_additem(gBhopMenu, "Make Start", "1", 0, -1);
    menu_additem(gBhopMenu, "Make Box", "2", 0, -1);
    menu_additem(gBhopMenu, "Move Up", "3", 0, -1);
    menu_additem(gBhopMenu, "Move Down", "4", 0, -1);
    menu_additem(gBhopMenu, "Destroy Object", "5", 0, -1);
    menu_additem(gBhopMenu, "Write to file", "6", 0, -1);
    
    gInfoTarget = engfunc(EngFunc_AllocString, "info_target");
    
    new szDir[65];
    get_configsdir(szDir, 64);
    add(szDir, 64, "/bcm", 0);
    if( !dir_exists(szDir) )
        mkdir(szDir);
        
    new szMap[33];
    get_mapname(szMap, 32);
    formatex(gFile, 96, "%s/%s.cfg", szDir, szMap);
}

public plugin_precache()
{
    precache_model(gMODEL);
}

public plugin_cfg()
{
    readFile();
}

readFile()
{
    if( !file_exists(gFile) )
    {
        return;
    }
    
    new szData[41]; /*S -9999.999999 -9999.999999 -9999.999999*/
    new szType[2], szX[13], szY[13], szZ[13];
    new Float:vOrigin[3];
    new f = fopen(gFile, "rt");
    while( !feof(f) )
    {
        fgets(f, szData, 40);
        parse(szData, szType, 1, szX, 12, szY, 12, szZ, 12);
        
        vOrigin[0] = str_to_float(szX);
        vOrigin[1] = str_to_float(szY);
        vOrigin[2] = str_to_float(szZ);
        
        if( szType[0] == 'S' )
        {
            makeBox(0, "bcm_start", 1, vOrigin);
        }
        else if( szType[0] == 'B' )
        {
            makeBox(0, "bcm_box", 2, vOrigin);
        }
        else if( szType[0] == 'E' )
        {
            makeBox(0, "bcm_end", 3, vOrigin);
        }
        else
        {
            log_amx("[ml_ <3's bcm] Invalid box type: %c in: %s", szType[0], gFile);
        }
    }
    fclose(f);
}

public fwdTouch(ptr, ptd)
{
    if( !ptd || ptd > 32 )
    {
        return FMRES_IGNORED;
    }
    
    static szClassname[33];
    pev(ptr, pev_classname, szClassname, 32);
    
    if( equal(szClassname, "worldspawn", 0) || equal(szClassname, "func_wall", 0) )
    {
        if( task_exists(ptd+100110, 0) )
        {
            remove_task(ptd+100110, 0);
            gTimes[ptd] = 0;
        }
    }
    else if( equal(szClassname, "bcm_box", 0) )
    {
        if( get_pcvar_num(gNoSlowdown) )
        {
            set_pev(ptd, pev_fuser2, 0.0);
        }
        if( !task_exists(ptr+5656) && !task_exists(ptr+6767) )
        {
            set_task(0.1, "tskUnsolid", ptr+5656, "", 0, "", 0);
        }
    }
    else if( equal(szClassname, "bcm_start", 0) )
    {
        if( task_exists(ptd+100110, 0) )
        {
            remove_task(ptd+100110, 0);
        }
        gTimes[ptd] = 0;
        set_task(1.0, "tskTimer", ptd+100110, "", 0, "b", 0);
    }
    else if( equal(szClassname, "bcm_end", 0) )
    {
        if( get_pcvar_num(gNoSlowdown) )
        {
            set_pev(ptd, pev_fuser2, 0.0);
        }
        if( task_exists(ptd+100110, 0) )
        {
            new szName[33];
            get_user_name(ptd, szName, 32);
            client_print(0, print_chat, "[ml_ <3's bcm] %s finished course %i in %i seconds!", szName, ptr, gTimes[ptd]);
            
            remove_task(ptd+100110, 0);
            gTimes[ptd] = 0;
        }
    }
    
    return FMRES_IGNORED;
}

public tskTimer(taskid)
{
    taskid-=100110;
    gTimes[taskid]+=1;
    
    set_hudmessage(255, 255, 255, 0.1, 0.75, 0, 0.0, 1.0, 0.0, 0.0, 2);
    show_hudmessage(taskid, "%i", gTimes[taskid]);
}

public tskUnsolid(taskid)
{
    taskid-=5656;
    set_pev(taskid, pev_solid, SOLID_NOT);
    fm_set_rendering(taskid, kRenderFxNone, 0, 0, 0, kRenderTransAdd, 100);
    set_task(1.0, "tskSolid", taskid+6767);
}

public tskSolid(taskid)
{
    taskid-=6767;
    set_pev(taskid, pev_solid, SOLID_BBOX);
    fm_set_rendering(taskid, kRenderFxNone, 0, 0, 0, kRenderNormal, 16);
}

public cmdBhopMenu(id, level, cid)
{
    if( !cmd_access(id, level, cid, 1) )
    {
        return PLUGIN_HANDLED;
    }
    
    menu_display(id, gBhopMenu, 0);
    
    return PLUGIN_HANDLED;
}

public mnuBhop(id, menu, item)
{
    new szCmd[2],  _access, callback;
    menu_item_getinfo(menu, item, _access, szCmd, 1, "", 0, callback);
    
    if( item == MENU_EXIT )
    {
        return PLUGIN_HANDLED;
    }
    
    switch( szCmd[0] )
    {
        case '-':
        {
            return PLUGIN_HANDLED;
        }
        case '1': 
        {
            makeBox(id, "bcm_start", 1, Float:{0.0, 0.0, 0.0});
        }
        case '2': 
        {
            makeBox(id, "bcm_box", 2, Float:{0.0, 0.0, 0.0});
        }
        case '3':
        {
            moveBox(id, 1); /* Up */
        }
        case '4':
        {    
            moveBox(id, 2); /* Down */
        }
        case '5':
        {
            new ent, body;
            get_user_aiming(id, ent, body, 9999);
            
            if( !pev_valid(ent) )
            {
                client_print(id, print_chat, "[ml_ <3's bcm] Aim at object to destroy it.");
            }
            else
            {
                new szClassname[33];
                pev(ent, pev_classname, szClassname, 32);
                
                if( !equal(szClassname, "bcm_box", 0)
                && !equal(szClassname, "bcm_start", 0)
                && !equal(szClassname, "bcm_end", 0)
                && !equali(szClassname, "func_button", 0)
                && !equali(szClassname, "func_door", 0) )
                {
                    client_print(0, print_chat, "[ml_ <3's bcm] Aim at object to destroy it.");
                }
                else
                {
                    set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME);
                    client_print(id, print_chat, "[ml_ <3's bcm] Object sucessfully destroyed!");
                }
            }
        }
        case '6':
        {
            if( file_exists(gFile) )
            {
                delete_file(gFile);
            }
            
            new ent, Float:vOrigin[3], szData[42]; /*S -9999.999999 -9999.999999 -9999.999999^n*/
            new f = fopen(gFile, "at");
            while( (ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "bcm_start")) )
            {
                pev(ent, pev_origin, vOrigin);
                formatex(szData, 41, "S %f %f %f^n", vOrigin[0], vOrigin[1], vOrigin[2]);
                fputs(f, szData);
            }
            ent = 0;
            while( (ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "bcm_box")) )
            {
                pev(ent, pev_origin, vOrigin);
                formatex(szData, 41, "B %f %f %f^n", vOrigin[0], vOrigin[1], vOrigin[2]);
                fputs(f, szData);
            }
            ent = 0;
            while( (ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "bcm_end")) )
            {
                pev(ent, pev_origin, vOrigin);
                formatex(szData, 41, "E %f %f %f^n", vOrigin[0], vOrigin[1], vOrigin[2]);
                fputs(f, szData);
            }
            fclose(f);
            
            client_print(id, print_chat, "[ml_ <3's bcm] Sucessfully saved to server!");
        }
    }
    
    menu_display(id, gBhopMenu, 0);
    
    return PLUGIN_HANDLED;
}

makeBox(id, const szClassname[], color, Float:pOrigin[3])
{
    new ent= engfunc(EngFunc_CreateNamedEntity, gInfoTarget);
    
    if( !pev_valid(ent) )
    {
        return PLUGIN_HANDLED;
    }
        
    set_pev(ent, pev_classname, szClassname);
    set_pev(ent, pev_solid, SOLID_BBOX);
    set_pev(ent, pev_movetype, MOVETYPE_NONE);
    engfunc(EngFunc_SetModel, ent, gMODEL);
    engfunc(EngFunc_SetSize, ent, Float:{-32.0, -32.0, -4.0}, Float:{32.0, 32.0, 4.0});
    
    if( pOrigin[0] == 0.0
    && pOrigin[1] == 0.0
    && pOrigin[2] == 0.0 )
    {
        new origin[3], Float:vOrigin[3];
        get_user_origin(id, origin, 3);
        IVecFVec(origin, vOrigin);
        vOrigin[2] += 16.0;
        engfunc(EngFunc_SetOrigin, ent, vOrigin);
        
    }
    else
    {    
        engfunc(EngFunc_SetOrigin, ent, pOrigin);
    }
    
    if( color == 1 )
    {
        fm_set_rendering(ent, kRenderFxGlowShell, 2, 14, 255, kRenderNormal, 16);
    }
    else if( color == 3 )
    {
        fm_set_rendering(ent, kRenderFxGlowShell, 255, 0, 0, kRenderNormal, 16);
    }
    
    if( isNearSpawn(ent) )
    {
        client_print(id, print_chat, "[ml_ <3's bcm] You are not able to place near spawns.");
        set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME);
    }
        
    return PLUGIN_HANDLED;
}

moveBox(id, mode)
{
    new ent, body, szClassname[33];
    get_user_aiming(id, ent, body, 9999);
    
    if( !pev_valid(ent) )
    {
        return PLUGIN_HANDLED;
    }
        
    pev(ent, pev_classname, szClassname, 32);
    
    if( !equal(szClassname, "bcm_box", 0)
    && !equal(szClassname, "bcm_start", 0)
    && !equal(szClassname, "bcm_end", 0) )
    {
        client_print(id, print_chat, "[ml_ <3's bcm] You must aim at an object.");
    }
    else
    {
        new Float:vOrigin[3];
        pev(ent, pev_origin, vOrigin);
    
        if( mode == 1 )
        {
            vOrigin[2]+=1.0;
        }
        else if( mode == 2 )
        {
            vOrigin[2]-=1.0;
        }
        
        engfunc(EngFunc_SetOrigin, ent, vOrigin);
    }
    
    return PLUGIN_HANDLED;
}

bool:isNearSpawn(id)
{
    new Float:vOrigin[3], ent, szClassname[33];
    pev(id, pev_origin, vOrigin);
    
    while( (ent = engfunc(EngFunc_FindEntityInSphere, ent, vOrigin, 128.0)) )
    {
        pev(ent, pev_classname, szClassname, 32);
        if( equal(szClassname, "info_player_start", 0)
        || equal(szClassname,"info_player_deathmatch", 0) )
        {
            return true;
        }
    }
    
    return false;
}

fm_set_rendering(ent, fx=kRenderFxNone, r=255, g=255, b=255, rend=kRenderNormal, amt=16)
{
    set_pev(ent, pev_renderfx, fx);
    
    new Float:rendColor[3];
    rendColor[0] = float(r);
    rendColor[1] = float(g);
    rendColor[2] = float(b);
    set_pev(ent, pev_rendercolor, rendColor);
    
    set_pev(ent, pev_rendermode, rend);
    set_pev(ent, pev_renderamt, float(amt));
}

public evntDeathMsg()
{
    new id = read_data(2);
    
    if( task_exists(id+100110, 0) )
    {
        remove_task(id+100110, 0);
        gTimes[id] = 0;
    }
}
mL_ is offline
 



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 21:29.


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