Hi can someone fix this code for me? i have tried but it doesnt rotate anything it's suposed to rotate by cvar with angles so i can rotate a block 360 degrees but it doesnt rotate when i write for example bm_rotate "0 0 -30" i hope you understand what i mean its like the regular rotate in bm that rotates 90 degrees but with this cvar it could be rotated like 35 degrees or 91 etc sry for bad english
PHP Code:
new pcv_rotate;
PHP Code:
pcv_rotate = register_cvar("bm_rotate","0 0 0");
PHP Code:
bool:rotateBlock(ent)
{
//if entity is valid
if (is_valid_ent(ent))
{
//get block type
new blockType = entity_get_int(ent, EV_INT_body);
//if block is a type that can be rotated (a block without a sprite, makes it easier!)
if (isBlockTypeRotatable(blockType))
{
new Float:rgb[3];
new Float:vAngles[3];
new Float:vSizeMin[3];
new Float:vSizeMax[3];
static rotate[12];
//get block information
entity_get_vector(ent, EV_VEC_angles, vAngles);
//create new block using current block information with new angles and sizes
if (vAngles[0] == 0.0 && vAngles[2] == 0.0)
{
vAngles[0] = 90.0;
vSizeMin = gfBlockSizeMinForX;
vSizeMax = gfBlockSizeMaxForX;
}
else if (vAngles[0] == 90.0 && vAngles[2] == 0.0)
{
vAngles[0] = 90.0;
vAngles[2] = 90.0;
vSizeMin = gfBlockSizeMinForY;
vSizeMax = gfBlockSizeMaxForY;
}
else
{
vAngles = gfDefaultBlockAngles;
vSizeMin = gfBlockSizeMinForZ;
vSizeMax = gfBlockSizeMaxForZ;
}
if (get_pcvar_string(pcv_rotate,rotate,11))
{
parse(rotate,vAngles[0],3,vAngles[1],3,vAngles[2],3);
rgb[0] = floatstr(vAngles[0]);
rgb[1] = floatstr(vAngles[1]);
rgb[2] = floatstr(vAngles[2]);
}
entity_set_vector(ent, EV_VEC_angles, vAngles);
entity_set_size(ent, vSizeMin, vSizeMax);
return true;
}
}
return false;
}