AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Blockmaker + Movetype (https://forums.alliedmods.net/showthread.php?t=163822)

weplausss 08-03-2011 17:32

Blockmaker + Movetype
 
Hi
I have a problem I try to do jumping death Block.
everything is ok, but after loading maps,block does not move
I hope that you will help

Sorry for English: D

This is my code

//Create Blocks
PHP Code:

CreateBlock(const id, const block_typeFloat:origin[3], const axis, const size, const property1[], const property2[], const property3[], const property4[])
{
    new 
ent create_entity("info_target");
    if ( !
is_valid_ent(ent) ) return 0;
    
    
entity_set_string(entEV_SZ_classnameg_block_classname);
    
entity_set_int(entEV_INT_solidSOLID_BBOX);
    
entity_set_int(entEV_INT_movetypeMOVETYPE_NONE);
    

    new 
Float:flProperty1;
    
    
peventpev_fuser1flProperty1);
    
    if( 
flProperty1 == 0.0 )
    
Death[id][2] = 500.0;
    else
    
Death[id][2] = flProperty1;
    
    
Death[id][1] = 0.0;
    
Death[id][0] = 0.0;
    
    if( 
block_type == DEATH)
    {
    
entity_set_int(entEV_INT_movetypeMOVETYPE_BOUNCE);
    
set_pev(entpev_velocityDeath[id][0], Death[id][1], Death[id][2]);

}

    new 
block_model[256];
    new 
Float:size_min[3];
    new 
Float:size_max[3];
    new 
Float:angles[3];
    new 
Float:scale;
    
    switch ( 
axis )
    {
        case 
X:
        {
            
size_min[0] = -4.0;
            
size_min[1] = -32.0;
            
size_min[2] = -32.0;
            
            
size_max[0] = 4.0;
            
size_max[1] = 32.0;
            
size_max[2] = 32.0;
            
            if(
size == POLE)
            {
                
size_min[0] = -32.0;
                
size_min[1] = -4.0;
                
size_min[2] = -4.0;
            
                
size_max[0] = 32.0;
                
size_max[1] = 4.0;
                
size_max[2] = 4.0;
            }
                
            
            
angles[0] = 90.0;
        }
        case 
Y:
        {
            
size_min[0] = -32.0;
            
size_min[1] = -4.0;
            
size_min[2] = -32.0;
            
            
size_max[0] = 32.0;
            
size_max[1] = 4.0;
            
size_max[2] = 32.0;
            
            if(
size == POLE)
            {
                
size_min[0] = -4.0;
                
size_min[1] = -32.0;
                
size_min[2] = -4.0;
            
                
size_max[0] = 4.0;
                
size_max[1] = 32.0;
                
size_max[2] = 4.0;
            }
            
            
angles[0] = 90.0;
            
angles[2] = 90.0;
        }
        case 
Z:
        {
            
size_min[0] = -32.0;
            
size_min[1] = -32.0;
            
size_min[2] = -4.0;
            
            
size_max[0] = 32.0;
            
size_max[1] = 32.0;
            
size_max[2] = 4.0;
            
            if(
size == POLE)
            {
                
size_min[0] = -4.0;
                
size_min[1] = -4.0;
                
size_min[2] = -32.0;
            
                
size_max[0] = 4.0;
                
size_max[1] = 4.0;
                
size_max[2] = 32.0;
            }
            
            
angles[0] = 0.0;
            
angles[1] = 0.0;
            
angles[2] = 0.0;
        }
    }
    
    switch ( 
size )
    {
        case 
TINY:
        {
            
SetBlockModelName(block_modelg_block_models[block_type], "Small");
            
scale 0.25;
        }
        case 
NORMAL:
        {
            
block_model g_block_models[block_type];
            
scale 1.0;
        }
        case 
LARGE:
        {
            
SetBlockModelName(block_modelg_block_models[block_type], "Large");
            
scale 2.0;
        }
        case 
POLE:
        {
            
SetBlockModelName(block_modelg_block_models[block_type], "Pole");
            
scale 1.0;
        }
    }
    
    for ( new 
03; ++)
    {
        if ( 
size_min[i] != 4.0 && size_min[i] != -4.0 )
        {
            
size_min[i] *= scale;
        }
        
        if ( 
size_max[i] != 4.0 && size_max[i] != -4.0 )
        {
            
size_max[i] *= scale;
        }
    }
    
    
entity_set_model(entblock_model);
    
    
SetBlockRendering(entg_render[block_type], g_red[block_type], g_green[block_type], g_blue[block_type], g_alpha[block_type]);
    
    
entity_set_vector(entEV_VEC_anglesangles);
    
entity_set_size(entsize_minsize_max);
    
entity_set_int(entEV_INT_bodyblock_type);
    
    if ( 
<= id <= g_max_players )
    {
        
DoSnapping(identorigin);
    }
    
    
entity_set_origin(entorigin);
    
    
SetProperty(ent1property1);
    
SetProperty(ent2property2);
    
SetProperty(ent3property3);
    
SetProperty(ent4property4);
    
    return 
ent;


//Save Blocks
PHP Code:

SaveBlocks(id)
{
    if ( !
g_admin[id] )
    {
        
console_print(id"Nie masz dostepu do tej komendy");
        return 
PLUGIN_HANDLED;
    }
    
    new 
ent;
    new 
file;
    new 
data[128];
    new 
block_count;
    new 
tele_count;
    new 
light_count;
    new 
block_type;
    new 
size;
    new 
property1[5], property2[5], property3[5], property4[5];
    new 
tele;
    new 
Float:origin[3];
    new 
Float:angles[3];
    new 
Float:tele_start[3];
    new 
Float:tele_end[3];
    new 
Float:max_size;
    new 
Float:size_max[3];
    
    
file fopen(g_file"wt");
    
    
block_count 0;
    
tele_count 0;
    
    
ent = -1;
    while ( ( 
ent find_ent_by_class(entg_block_classname) ) )
    {
        
block_type entity_get_int(entEV_INT_body);
        
entity_get_vector(entEV_VEC_originorigin);
        
entity_get_vector(entEV_VEC_anglesangles);
        
entity_get_vector(entEV_VEC_maxssize_max);
        
        
GetProperty(ent1property1);
        
GetProperty(ent2property2);
        
GetProperty(ent3property3);
        
GetProperty(ent4property4);
        
        if ( !
property1[0] ) copy(property1charsmax(property1), "/");
        if ( !
property2[0] ) copy(property2charsmax(property2), "/");
        if ( !
property3[0] ) copy(property3charsmax(property3), "/");
        if ( !
property4[0] ) copy(property4charsmax(property4), "/");
        
        
max_size size_max[0] + size_max[1] + size_max[2];
        
        if ( 
max_size 128.0 )        size LARGE;
        else if ( 
max_size 64.0 )    size NORMAL;
        else if ( 
max_size 32.0 )    size POLE;
        else                
size TINY;
        
        
formatex(datacharsmax(data), "%c %f %f %f %f %f %f %d %s %s %s %s^n",\
            
g_block_save_ids[block_type],\
            
origin[0],\
            
origin[1],\
            
origin[2],\
            
angles[0],\
            
angles[1],\
            
angles[2],\
            
size,\
            
property1,\
            
property2,\
            
property3,\
            
property4
            
);
        
fputs(filedata);
        
        ++
block_count;
    }
    
    
ent = -1;
    while ( ( 
ent find_ent_by_class(entg_destination_classname) ) )
    {
        
tele entity_get_int(entEV_INT_iuser1);
        if ( 
tele )
        {
            
entity_get_vector(teleEV_VEC_origintele_start);
            
entity_get_vector(entEV_VEC_origintele_end);
            
            
formatex(datacharsmax(data), "* %f %f %f %f %f %f^n",\
                
tele_start[0],\
                
tele_start[1],\
                
tele_start[2],\
                
tele_end[0],\
                
tele_end[1],\
                
tele_end[2]
                );
            
fputs(filedata);
            
            ++
tele_count;
        }
    }
    
    
ent = -1;
    while ( ( 
ent find_ent_by_class(entg_light_classname) ) )
    {
        
entity_get_vector(entEV_VEC_originorigin);
        
        
GetProperty(ent1property1);
        
GetProperty(ent2property2);
        
GetProperty(ent3property3);
        
GetProperty(ent4property4);
        
        
formatex(datacharsmax(data), "! %f %f %f / / / / %s %s %s %s^n",\
            
origin[0],\
            
origin[1],\
            
origin[2],\
            
property1,\
            
property2,\
            
property3,\
            
property4
            
);
        
fputs(filedata);
        
        ++
light_count;
    }
    
    static 
name[32];
    
get_user_name(idnamecharsmax(name));
    
    for ( new 
1<= g_max_players; ++)
    {
        if ( 
g_connected[i]
        && ( 
g_admin[i] || g_gived_access[i] ) )
        {
            
BCM_Print(i"^1%s^3 zapisal^1 %d blokow^3,^1 %d teleportow ^3 i^1 %d swiatel^3! Bytow na mapie:^1 %d"nameblock_counttele_countlight_countentity_count());
        }
    }
    
    
fclose(file);
    return 
PLUGIN_HANDLED;


//Load blocks
PHP Code:

LoadBlocks(id)
{
    if ( 
id != && !g_admin[id] )
    {
        
console_print(id"Nie masz dostepu do tej komendy");
        return 
PLUGIN_HANDLED;
    }
    else if ( !
file_exists(g_file)
    && 
<= id <= g_max_players )
    {
        
BCM_Print(id"Nie mozna znalezc pliku:^1 %s"g_file);
        return 
PLUGIN_HANDLED;
    }
    
    if ( 
<= id <= g_max_players )
    {
        
DeleteAll(idfalse);
    }
    
    new 
file;
    new 
data[128];
    new 
block_count;
    new 
tele_count;
    new 
light_count;
    new 
type[2];
    new 
block_size[17];
    new 
origin_x[17];
    new 
origin_y[17];
    new 
origin_z[17];
    new 
angel_x[17];
    new 
angel_y[17];
    new 
angel_z[17];
    new 
block_type;
    new 
axis;
    new 
size;
    new 
property1[5], property2[5], property3[5], property4[5];
    new 
Float:origin[3];
    new 
Float:angles[3];
    
    
file fopen(g_file"rt");
    
    
block_count 0;
    
tele_count 0;
    
    while ( !
feof(file) )
    {
        
type g_blank;
        
        
fgets(filedatacharsmax(data));
        
parse(data,\
            
typecharsmax(type),\
            
origin_xcharsmax(origin_x),\
            
origin_ycharsmax(origin_y),\
            
origin_zcharsmax(origin_z),\
            
angel_xcharsmax(angel_x),\
            
angel_ycharsmax(angel_y),\
            
angel_zcharsmax(angel_z),\
            
block_sizecharsmax(block_size),\
            
property1charsmax(property1),\
            
property2charsmax(property2),\
            
property3charsmax(property3),\
            
property4charsmax(property4)
            );
        
        
origin[0] =    str_to_float(origin_x);
        
origin[1] =    str_to_float(origin_y);
        
origin[2] =    str_to_float(origin_z);
        
angles[0] =    str_to_float(angel_x);
        
angles[1] =    str_to_float(angel_y);
        
angles[2] =    str_to_float(angel_z);
        
size =        str_to_num(block_size);
        
        if ( 
strlen(type) > )
        {
            if ( 
type[0] != '*' )
            {
                if ( 
angles[0] == 90.0 && angles[1] == 0.0 && angles[2] == 0.0 )
                {
                    
axis X;
                }
                else if ( 
angles[0] == 90.0 && angles[1] == 0.0 && angles[2] == 90.0 )
                {
                    
axis Y;
                }
                else
                {
                    
axis Z;
                }
            }
            
            switch ( 
type[0] )
            {
                case 
'A'block_type BUNNYHOP;
                case 
'B'block_type NO_SLOW_DOWN_BUNNYHOP;
                case 
'C'block_type DELAYED_BUNNYHOP;
                case 
'D'block_type DAMAGE;
                case 
'E'block_type HEALER;
                case 
'F'block_type NO_FALL_DAMAGE;
                case 
'G'block_type ICE;
                case 
'H'block_type TRAMPOLINE;
                case 
'I'block_type SPEED_BOOST;
                case 
'J'block_type DEATH;
                case 
'K'block_type LOW_GRAVITY;
                case 
'L'block_type HONEY;
                case 
'M'block_type CT_BARRIER;
                case 
'N'block_type T_BARRIER;
                case 
'O'block_type GLASS;
                case 
'P'block_type PLATFORM;
                case 
'Q'block_type TRAWA;
                case 
'R'block_type DREWNO;
                case 
'S'block_type INVINCIBILITY;
                case 
'T'block_type STEALTH;
                case 
'U'block_type BOOTS_OF_SPEED;
                case 
'V'block_type MONEYBLOCK;
                case 
'W'block_type KAMUFLAZ;
                case 
'X'block_type MELANZ;
                case 
'Y'block_type SG;
                case 
'Z'block_type HE;
                case 
'@'block_type GRANATY;
                case 
'#'block_type BRON;
                case 
'$'block_type VIP;
                case 
'%'block_type DUCK;
                case 
'1'block_type KOKS;
                case 
'2'block_type SKY;
                

                case 
'*':
                {
                    
CreateTeleport(0TELEPORT_STARTorigin);
                    
CreateTeleport(0TELEPORT_DESTINATIONangles);
                    
                    ++
tele_count;
                }
                case 
'!':
                {
                    
CreateLight(originproperty1property2property3property4);
                    
                    ++
light_count;
                }
            }
            
            if ( 
type[0] != '*' && type[0] != '!' )
            {
                
CreateBlock(0block_typeoriginaxissizeproperty1property2property3property4);
                
                ++
block_count;
            }
        }
    }
    
    
fclose(file);
    
    if ( 
<= id <= g_max_players )
    {
        static 
name[32];
        
get_user_name(idnamecharsmax(name));
        
        for ( new 
1<= g_max_players; ++)
        {
            if ( !
g_connected[i]
            || !
g_admin[i] && !g_gived_access[i] ) continue;
            
            
BCM_Print(i"^1%s^3 loaded^1 %d block%s^3,^1 %d teleport%s^3 and^1 %d light%s^3! Total entites in map:^1 %d"nameblock_countblock_count == g_blank "s"tele_counttele_count == g_blank "s"light_countlight_count == g_blank "s"entity_count());
        }
    }
    
    return 
PLUGIN_HANDLED;




All times are GMT -4. The time now is 03:27.

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