AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Rotate Blocks in BaseBuilder 6.5 (https://forums.alliedmods.net/showthread.php?t=331382)

Ykaru 03-18-2021 08:21

Rotate Blocks in BaseBuilder 6.5
 
Hi, I have this plugin that when you move the blocks by pressing Z, X and C rotates the blocks.
It's just that when you press to spin them, it teleports them very far and they should be in front of the crosshair.
Can someone make them to stay put, not to teleport?

PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <fakemeta>
#include <basebuilder>

#define PLUGIN "[BB] Block Rotation"
#define VERSION "1.0"
#define AUTHOR "Natsheh"

#define ROTATION_SOUND    "sound/fvox/beep.wav"

#define ROTATION_DELAY 0.75

new Float:rotation_delay[33];

public 
plugin_precache() precache_generic(ROTATION_SOUND);

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new const 
rotation_cmds[][] = { "radio1","radio2","radio3" };
    for(new 
isizeof rotation_cmdsi++) register_clcmd(rotation_cmds[i], "clcmd_radio"_"Rotate block!");
}

public 
clcmd_radio(id)
{
    new 
block;
    if(!(
block bb_get_user_block(id))) return 0;
    
    new 
Float:gtime get_gametime();
    
    if( 
rotation_delay[id] > gtime ) return 1;
    
    new 
sCmd[8], Float:fAngles[3];
    
read_argv(0sCmdcharsmax(sCmd))
    
    
pev(blockpev_anglesfAngles)
    
    switch( 
sCmd[5] )
    {
        case 
'1': { client_print(idprint_center"Rotating the Block UPWARD!"); fAngles[0] += 90.0; }
        case 
'2': { client_print(idprint_center"Rotating the Block RIGHTWARD!"); fAngles[1] += 90.0; }
        case 
'3': { client_print(idprint_center"Rotating the Block FORWARD!"); fAngles[2] += 90.0; }
        default: return 
0;
    }
    
    
SetEntityAngles(blockfAngles)
    
    
client_cmd(id"spk ^"%s^""ROTATION_SOUND)
    
rotation_delay[id] = gtime ROTATION_DELAY;
    return 
1;
}
SetEntityAngles(ent, const Float:angles[3]) {
    new 
Float:origin[3];
    
origin GetEntityOrigin(ent);
    
    
set_pev(entpev_anglesangles);
    
set_pev(entpev_originFloat:{0.00.00.0});
    
    new 
Float:newOrigin[3];
    
newOrigin GetEntityOrigin(ent);
    
    
origin[0] -= newOrigin[0];
    
origin[1] -= newOrigin[1];
    
origin[2] -= newOrigin[2];
    
    
engfunc(EngFunc_SetOriginentorigin);
}

Float:GetEntityOrigin(ent) {
    new 
Float:origin[3];
    
pev(entpev_originorigin);
    
    new 
Float:center[3];
    {
        new 
Float:mins[3], Float:maxs[3];
        
pev(entpev_minsmins);
        
pev(entpev_maxsmaxs);
        
center[0] = (mins[0] + maxs[0])/2;
        
center[1] = (mins[1] + maxs[1])/2;
        
center[2] = (mins[2] + maxs[2])/2;
    }
    
    new 
Float:rotatedCenter[3];
    {
        new 
Float:angles[3];
        
pev(entpev_anglesangles);
        
        
engfunc(EngFunc_MakeVectorsangles);
        new 
Float:fwd[3], Float:left[3], Float:up[3];
        
global_get(glb_v_forwardfwd);
        {
            new 
Float:right[3];
            
global_get(glb_v_rightright);
            
left[0] = -right[0];
            
left[1] = -right[1];
            
left[2] = -right[2];
        }
        
global_get(glb_v_upup);
        
        
// rotatedCenter = fwd*center.x + left*center.y + up*center.z
        
rotatedCenter[0] = fwd[0]*center[0] + left[0]*center[1] + up[0]*center[2];
        
rotatedCenter[1] = fwd[1]*center[0] + left[1]*center[1] + up[1]*center[2];
        
rotatedCenter[2] = fwd[2]*center[0] + left[2]*center[1] + up[2]*center[2];
    }
    
    
origin[0] += rotatedCenter[0];
    
origin[1] += rotatedCenter[1];
    
origin[2] += rotatedCenter[2];
    
    return 
origin;



Natsheh 03-19-2021 02:49

Re: Rotate Blocks in BaseBuilder 6.5
 
try this...

PHP Code:


#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <basebuilder>

#define PLUGIN "[BB] Block Rotation"
#define VERSION "1.0"
#define AUTHOR "Natsheh"

#define ROTATION_SOUND    "sound/fvox/beep.wav"

#define ROTATION_DELAY 0.75

new Float:rotation_delay[33];

public 
plugin_precache() precache_generic(ROTATION_SOUND);

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new const 
rotation_cmds[][] = { "radio1","radio2","radio3" };
    for(new 
isizeof rotation_cmdsi++) register_clcmd(rotation_cmds[i], "clcmd_radio"_"Rotate block!");
    
    
register_impulse(100"hook_flashlight");
}

public 
hook_flashlight(id)
{
    new 
block;
    if(!(
block bb_get_user_block(id))) return ;
    
    
bb_drop_user_block(id)
    
engfunc(EngFunc_SetOriginblockFloat:{0.0,0.0,0.0});
}

public 
clcmd_radio(id)
{
    new 
block;
    if(!(
block bb_get_user_block(id))) return 0;
    
    new 
Float:gtime get_gametime();
    
    if( 
rotation_delay[id] > gtime ) return 1;
    
    new 
sCmd[8], Float:fAngles[3], Float:fOrigin[3];
    
read_argv(0sCmdcharsmax(sCmd))
    
    
pev(blockpev_anglesfAngles)
    
    
//pev(block, pev_origin, fOrigin);
    //client_print(id, print_chat, "PRE (X) %.2f (Y) %.2f (Z) %.2f", fOrigin[0], fOrigin[1], fOrigin[2]);
    
    
switch( sCmd[5] )
    {
        case 
'1': { client_print(idprint_center"Rotating the Block around the X Axis!"); fAngles[0] += 90.0; }
        case 
'2': { client_print(idprint_center"Rotating the Block around the Y Axis!"); fAngles[1] += 90.0; }
        case 
'3': { client_print(idprint_center"Rotating the Block around the Z Axis!"); fAngles[2] += 90.0; }
        default: return 
0;
    }
    
    
SetEntityAngles(blockfAnglesid)
    
    
//pev(block, pev_origin, fOrigin);
    //client_print(id, print_chat, "POST (X) %.2f (Y) %.2f (Z) %.2f", fOrigin[0], fOrigin[1], fOrigin[2]);
    
    
client_cmd(id"spk ^"%s^""ROTATION_SOUND)
    
rotation_delay[id] = gtime ROTATION_DELAY;
    return 
1;
}

SetEntityAngles(entFloat:angles[3], id) {
    new 
Float:origin[3];
    
origin GetEntityOrigin(ent);
    
    for(new 
i3i++)
    {
    if (
angles[i] >= 180.0) {
        
angles[i] -= 360.0;
    }
    }
    
    
bb_drop_user_block(id)
    
    
set_pev(entpev_anglesangles);
    
set_pev(entpev_originFloat:{0.00.00.0});
    
    new 
Float:newOrigin[3];
    
newOrigin GetEntityOrigin(ent);
    
    
origin[0] -= newOrigin[0];
    
origin[1] -= newOrigin[1];
    
origin[2] -= newOrigin[2];
    
    
engfunc(EngFunc_SetOriginentorigin);
    
    
bb_set_user_block(ident);
}

Float:GetEntityOrigin(ent) {
    new 
Float:origin[3];
    
pev(entpev_originorigin);
    
    new 
Float:center[3];
    {
        new 
Float:mins[3], Float:maxs[3];
        
pev(entpev_minsmins);
        
pev(entpev_maxsmaxs);
        
center[0] = (mins[0] + maxs[0])/2;
        
center[1] = (mins[1] + maxs[1])/2;
        
center[2] = (mins[2] + maxs[2])/2;
    }
    
    new 
Float:rotatedCenter[3];
    {
        new 
Float:angles[3];
        
pev(entpev_anglesangles);
        
        
engfunc(EngFunc_MakeVectorsangles);
        new 
Float:fwd[3], Float:left[3], Float:up[3];
        
global_get(glb_v_forwardfwd);
        {
            new 
Float:right[3];
            
global_get(glb_v_rightright);
            
left[0] = -right[0];
            
left[1] = -right[1];
            
left[2] = -right[2];
        }
        
global_get(glb_v_upup);
        
        
// rotatedCenter = fwd*center.x + left*center.y + up*center.z
        
rotatedCenter[0] = -fwd[0]*center[0] + left[0]*center[1] + -up[0]*center[2];
        
rotatedCenter[1] = -fwd[1]*center[0] + left[1]*center[1] + -up[1]*center[2];
        
rotatedCenter[2] = -fwd[2]*center[0] + left[2]*center[1] + -up[2]*center[2];
    }
    
    
origin[0] += rotatedCenter[0];
    
origin[1] += rotatedCenter[1];
    
origin[2] += rotatedCenter[2];
    
    return 
origin;



Ykaru 03-19-2021 09:49

Re: Rotate Blocks in BaseBuilder 6.5
 
Quote:

Originally Posted by Natsheh (Post 2740901)
try this...

PHP Code:


#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <basebuilder>

#define PLUGIN "[BB] Block Rotation"
#define VERSION "1.0"
#define AUTHOR "Natsheh"

#define ROTATION_SOUND    "sound/fvox/beep.wav"

#define ROTATION_DELAY 0.75

new Float:rotation_delay[33];

public 
plugin_precache() precache_generic(ROTATION_SOUND);

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    new const 
rotation_cmds[][] = { "radio1","radio2","radio3" };
    for(new 
isizeof rotation_cmdsi++) register_clcmd(rotation_cmds[i], "clcmd_radio"_"Rotate block!");
    
    
register_impulse(100"hook_flashlight");
}

public 
hook_flashlight(id)
{
    new 
block;
    if(!(
block bb_get_user_block(id))) return ;
    
    
bb_drop_user_block(id)
    
engfunc(EngFunc_SetOriginblockFloat:{0.0,0.0,0.0});
}

public 
clcmd_radio(id)
{
    new 
block;
    if(!(
block bb_get_user_block(id))) return 0;
    
    new 
Float:gtime get_gametime();
    
    if( 
rotation_delay[id] > gtime ) return 1;
    
    new 
sCmd[8], Float:fAngles[3], Float:fOrigin[3];
    
read_argv(0sCmdcharsmax(sCmd))
    
    
pev(blockpev_anglesfAngles)
    
    
//pev(block, pev_origin, fOrigin);
    //client_print(id, print_chat, "PRE (X) %.2f (Y) %.2f (Z) %.2f", fOrigin[0], fOrigin[1], fOrigin[2]);
    
    
switch( sCmd[5] )
    {
        case 
'1': { client_print(idprint_center"Rotating the Block around the X Axis!"); fAngles[0] += 90.0; }
        case 
'2': { client_print(idprint_center"Rotating the Block around the Y Axis!"); fAngles[1] += 90.0; }
        case 
'3': { client_print(idprint_center"Rotating the Block around the Z Axis!"); fAngles[2] += 90.0; }
        default: return 
0;
    }
    
    
SetEntityAngles(blockfAnglesid)
    
    
//pev(block, pev_origin, fOrigin);
    //client_print(id, print_chat, "POST (X) %.2f (Y) %.2f (Z) %.2f", fOrigin[0], fOrigin[1], fOrigin[2]);
    
    
client_cmd(id"spk ^"%s^""ROTATION_SOUND)
    
rotation_delay[id] = gtime ROTATION_DELAY;
    return 
1;
}

SetEntityAngles(entFloat:angles[3], id) {
    new 
Float:origin[3];
    
origin GetEntityOrigin(ent);
    
    for(new 
i3i++)
    {
    if (
angles[i] >= 180.0) {
        
angles[i] -= 360.0;
    }
    }
    
    
bb_drop_user_block(id)
    
    
set_pev(entpev_anglesangles);
    
set_pev(entpev_originFloat:{0.00.00.0});
    
    new 
Float:newOrigin[3];
    
newOrigin GetEntityOrigin(ent);
    
    
origin[0] -= newOrigin[0];
    
origin[1] -= newOrigin[1];
    
origin[2] -= newOrigin[2];
    
    
engfunc(EngFunc_SetOriginentorigin);
    
    
bb_set_user_block(ident);
}

Float:GetEntityOrigin(ent) {
    new 
Float:origin[3];
    
pev(entpev_originorigin);
    
    new 
Float:center[3];
    {
        new 
Float:mins[3], Float:maxs[3];
        
pev(entpev_minsmins);
        
pev(entpev_maxsmaxs);
        
center[0] = (mins[0] + maxs[0])/2;
        
center[1] = (mins[1] + maxs[1])/2;
        
center[2] = (mins[2] + maxs[2])/2;
    }
    
    new 
Float:rotatedCenter[3];
    {
        new 
Float:angles[3];
        
pev(entpev_anglesangles);
        
        
engfunc(EngFunc_MakeVectorsangles);
        new 
Float:fwd[3], Float:left[3], Float:up[3];
        
global_get(glb_v_forwardfwd);
        {
            new 
Float:right[3];
            
global_get(glb_v_rightright);
            
left[0] = -right[0];
            
left[1] = -right[1];
            
left[2] = -right[2];
        }
        
global_get(glb_v_upup);
        
        
// rotatedCenter = fwd*center.x + left*center.y + up*center.z
        
rotatedCenter[0] = -fwd[0]*center[0] + left[0]*center[1] + -up[0]*center[2];
        
rotatedCenter[1] = -fwd[1]*center[0] + left[1]*center[1] + -up[1]*center[2];
        
rotatedCenter[2] = -fwd[2]*center[0] + left[2]*center[1] + -up[2]*center[2];
    }
    
    
origin[0] += rotatedCenter[0];
    
origin[1] += rotatedCenter[1];
    
origin[2] += rotatedCenter[2];
    
    return 
origin;



WHen I try to compile I get this : (70) warning 204: symbol is assigned a value that is never used: "fOrigin"

Natsheh 03-19-2021 10:05

Re: Rotate Blocks in BaseBuilder 6.5
 
Its just a warning nothing will happen.

Ykaru 03-19-2021 14:31

Re: Rotate Blocks in BaseBuilder 6.5
 
Quote:

Originally Posted by Natsheh (Post 2740935)
Its just a warning nothing will happen.

Still teleporting far away the blocks.

amirwolf 02-07-2024 16:53

Re: Rotate Blocks in BaseBuilder 6.5
 
Hello
Is there a solution for that?


All times are GMT -4. The time now is 00:38.

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