SCTF Door's Bug

Сообщения
109
Реакции
79
Помог
1 раз(а)
Hi, I am writing new SCTF version. But there is a bug I couldn't. if you die near the door when you have enemy flag, flag is going. It isn't coming back. Just it is coming back when restarting map. How can fix it?



Форматирование (BB-код):
/* Yek'-ta

    https://github.com/yek-ta/AMXX-PLUGINS/tree/master/Simple%20Capture%20the%20Flag

*/

#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <engine>

#define MENU_COMMAND "amx_menu_sctf"
#define MENU_FLAG ADMIN_RCON

// started Simple Capture the Flag plugin.
#define PLUGIN  "Simple Capture the Flag"
#define VERSION "1.8.0B"
#define AUTHOR  "Yek'-ta"

#define FLAG_CLASS "SimpleCTFlag"
#define NEWFLAG_CLASS "NewSimpleCTFlag"

#define TEAM_TE 1
#define TEAM_CT 2
#define In_Base_Time 1.0

#define TASK_TEFLAG 100
//There should be 100 values difference between the two fields. For no bugs.
#define TASK_CTFLAG 200

#define is_valid_player(%1) (1 <= %1 <= 32)

new BKMODEL[64]

enum _:COORDINATE_NAMES
{
    COOR_CT,
    COOR_TE,
    NEW_COOR_CTBASE,
    NEW_COOR_TEBASE
}
enum _:INT_VALUES_NAMES
{
    holdingflag_CT,
    ent_CTFlag,
    ent_CTFlagBase,
    ent_NEW_CTFlag,
    holdingflag_TE,
    ent_TEFlag,
    ent_TEFlagBase,
    ent_NEW_TEFlag,
    modeldosyasi
}

enum _:FORW_VALUES_NAMES
{
    for_forw,
    flag_dropped,
    flag_take,
    flag_backtobase,
    scored,
    forw_inTEFlagBase,
    forw_inCTFlagBase
}
enum _:INDIVIDUAL_BOOLS
{
    in_TEFlagBase,
    in_CTFlagBase,
}

new Float:coordinates[COORDINATE_NAMES][3]
new int_values[INT_VALUES_NAMES]
new forw[FORW_VALUES_NAMES]
new bool:individual[INDIVIDUAL_BOOLS][33]


public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_cvar("SCTF",VERSION,FCVAR_SERVER)
    register_clcmd(MENU_COMMAND, "SCTF_MENU" , MENU_FLAG)

    //Events
    register_touch(FLAG_CLASS, "player",  "touch_entity");
    RegisterHookChain(RG_CSGameRules_RestartRound, "RG_RestartRound", true)
    RegisterHookChain(RG_CSGameRules_PlayerKilled, "RG_PlayerKilled", true)

    //Forward
    forw[flag_dropped] = CreateMultiForward("sctf_flag_dropped", ET_IGNORE, FP_CELL,FP_CELL, FP_CELL)
    forw[flag_take] = CreateMultiForward("sctf_flag_is_takenoff", ET_IGNORE, FP_CELL,FP_CELL)
    forw[flag_backtobase] = CreateMultiForward("sctf_flag_backtobase", ET_IGNORE, FP_CELL,FP_CELL)
    forw[scored] = CreateMultiForward("sctf_flag_scored", ET_IGNORE, FP_CELL,FP_CELL)
    forw[forw_inTEFlagBase] = CreateMultiForward("sctf_player_entered_TEFlagBase", ET_IGNORE, FP_CELL,FP_CELL)
    forw[forw_inCTFlagBase] = CreateMultiForward("sctf_player_entered_CTFlagBase", ET_IGNORE, FP_CELL,FP_CELL)

}
public plugin_precache()
{
    formatex(BKMODEL,charsmax(BKMODEL),"models/sctf/flag2019.mdl");

    SCTF_Files()

    int_values[modeldosyasi] = precache_model(BKMODEL)
}
public plugin_cfg(){
    if(coordinates[COOR_TE][0] == 0.0 && coordinates[COOR_TE][1] == 0.0 && coordinates[COOR_TE][2] == 0.0 && coordinates[COOR_CT][0] == 0.0 && coordinates[COOR_CT][1] == 0.0 && coordinates[COOR_CT][2] == 0.0){
        new iFindSpawn = find_ent_by_class(get_member_game(m_nMaxPlayers), "info_player_deathmatch")
        if(iFindSpawn){
            get_entvar(iFindSpawn, var_origin, coordinates[NEW_COOR_TEBASE]);
            while(point_contents(coordinates[NEW_COOR_TEBASE]) == CONTENTS_EMPTY)
                coordinates[NEW_COOR_TEBASE][2] -= 1.0
        }
        else{
            server_print("[ SCTF ] There is a problem about TESpawnPoints")
            return;
        }
        iFindSpawn = find_ent_by_class(get_member_game(m_nMaxPlayers), "info_player_start")
        if(iFindSpawn){
            get_entvar(iFindSpawn, var_origin, coordinates[NEW_COOR_CTBASE]);
            while(point_contents(coordinates[NEW_COOR_CTBASE]) == CONTENTS_EMPTY)
                coordinates[NEW_COOR_CTBASE][2] -= 1.0
        }
        else{
            server_print("[ SCTF ] There is a problem about CTSpawnPoints")
            return;
        }
        Write_new_Coordinates();
        server_print("[ SCTF ] Wrote new coordinates for map.")
        SCTF_Files()
    }
    CREATE_ENTITY()
}
/*================================================================================
 [read flag coord]
=================================================================================*/
public SCTF_Files(){
    new cfgdir[32], mapname[32], filepath[100], linedata[128]
    get_configsdir(cfgdir, charsmax(cfgdir))
    new file
    new key[40], value[64]

    formatex(filepath, charsmax(filepath), "%s/sctf_config.ini", cfgdir)

    if (file_exists(filepath))
    {
        file = fopen(filepath, "rt")

        while (file && !feof(file))
        {
            fgets(file, linedata, charsmax(linedata))

            replace(linedata, charsmax(linedata), "^n", "")

            if( linedata[ 0 ] == ';' || linedata[ 0 ] == '/' || !strlen( linedata ) )
                continue;

            if (linedata[0] == '-' && linedata[1] == '-' && linedata[2] == '>'){

                strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
                trim(key)
                trim(value)

                if (equal(key[3], "FLAG MODEL"))
                {
                    formatex(BKMODEL,charsmax(BKMODEL),value);
                    server_print("[ SCTF ] Flag model changed to %s ", value)
                }
                else {
                    server_cmd("%s",key[3])
                }
                continue;
            }
        }
        if (file) fclose(file)
    }

    //Flags

    get_mapname(mapname, charsmax(mapname))
    formatex(filepath, charsmax(filepath), "maps/%s.sctf.cfg", mapname)

    if (!file_exists(filepath))
    {
        server_print("[ SCTF ] There is no flag values in %s ", filepath)
        return;
    }

    file = fopen(filepath, "rt")

    while (file && !feof(file))
    {
        fgets(file, linedata, charsmax(linedata))

        replace(linedata, charsmax(linedata), "^n", "")

        if( linedata[ 0 ] == ';' || linedata[ 0 ] == '/' || !strlen( linedata ) )
            continue;

        if (linedata[0] == '-' && linedata[1] == '-' && linedata[2] == '>'){

            strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
            trim(key)
            trim(value)

            if (equal(key[3], "TEX"))
            {
                coordinates[COOR_TE][0] = floatstr(value)
            }
            else if (equal(key[3], "TEY"))
            {
                coordinates[COOR_TE][1] = floatstr(value)
            }
            else if (equal(key[3], "TEZ"))
            {
                coordinates[COOR_TE][2] = floatstr(value)
            }

            else if (equal(key[3], "CTX"))
            {
                coordinates[COOR_CT][0] = floatstr(value)
            }
            else if (equal(key[3], "CTY"))
            {
                coordinates[COOR_CT][1] = floatstr(value)
            }
            else if (equal(key[3], "CTZ"))
            {
                coordinates[COOR_CT][2] = floatstr(value)
            }
            continue;
        }
    }
    if (file) fclose(file)
    server_print("[ SCTF ] read in %s .", filepath)

    coordinates[NEW_COOR_TEBASE][0] = coordinates[COOR_TE][0]
    coordinates[NEW_COOR_TEBASE][1] = coordinates[COOR_TE][1]
    coordinates[NEW_COOR_TEBASE][2] = coordinates[COOR_TE][2]

    coordinates[NEW_COOR_CTBASE][0] = coordinates[COOR_CT][0]
    coordinates[NEW_COOR_CTBASE][1] = coordinates[COOR_CT][1]
    coordinates[NEW_COOR_CTBASE][2] = coordinates[COOR_CT][2]
}
/*================================================================================
 [Native]
=================================================================================*/
public plugin_natives()
{
    register_native("sctf_who_TEflagger", "native_who_TEflagger", 1)
    register_native("sctf_who_CTflagger", "native_who_CTflagger", 1)
    register_native("sctf_ent_TEFlagBase", "native_ent_TEFlagBase", 1)
    register_native("sctf_ent_CTFlagBase", "native_ent_CTFlagBase", 1)
    register_native("sctf_ent_TEFlag", "native_ent_TEFlag", 1)
    register_native("sctf_ent_CTFlag", "native_ent_CTFlag", 1)
    register_native("is_user_inCTFlagBase", "native_is_user_inCTFlagBase", 1)
    register_native("is_user_inTEFlagBase", "native_is_user_inTEFlagBase", 1)

    register_native("sctf_move_to_flag_back", "MOVEBACK_FLAG", 1)
}
public native_who_TEflagger()
{
    return int_values[holdingflag_TE];
}
public native_who_CTflagger()
{
    return int_values[holdingflag_CT];
}
public native_ent_TEFlagBase()
{
    return int_values[ent_TEFlagBase];
}
public native_ent_CTFlagBase()
{
    return int_values[ent_CTFlagBase];
}
public native_ent_TEFlag()
{
    return int_values[ent_TEFlag];
}
public native_ent_CTFlag()
{
    return int_values[ent_CTFlag];
}
public native_is_user_inCTFlagBase(id)
{
    return individual[in_CTFlagBase][id];
}
public native_is_user_inTEFlagBase(id)
{
    return individual[in_TEFlagBase][id];
}
/*================================================================================
 [Events]
=================================================================================*/
public client_disconnected(id){
    if(int_values[holdingflag_TE] == id){
        MOVEBACK_FLAG(int_values[ent_CTFlag])
    }
    else if(int_values[holdingflag_CT] == id){
        MOVEBACK_FLAG(int_values[ent_TEFlag])
    }
}
public RG_PlayerKilled(const victim, const killer){
    if(int_values[holdingflag_CT] == victim){
        set_entvar(int_values[ent_TEFlag],var_aiment,-1)
        entity_set_int(int_values[ent_TEFlag],EV_INT_movetype,MOVETYPE_TOSS)
        set_entvar(int_values[ent_TEFlag], var_body, 2)
        Set_Entity_Anim(int_values[ent_TEFlag], 1,0);
        get_entvar(victim, var_origin, coordinates[COOR_TE]);
        while(point_contents(coordinates[COOR_TE]) == CONTENTS_EMPTY)
            coordinates[COOR_TE][2] -= 1.0
        set_entvar(int_values[ent_TEFlag], var_origin, coordinates[COOR_TE]);
        int_values[holdingflag_CT] = -1;
        ExecuteForward(forw[flag_dropped], forw[for_forw], victim,int_values[ent_TEFlag], killer);
    }
    else if(int_values[holdingflag_TE] == victim){
        set_entvar(int_values[ent_CTFlag],var_aiment,-1)
        entity_set_int(int_values[ent_CTFlag],EV_INT_movetype,MOVETYPE_TOSS)
        set_entvar(int_values[ent_CTFlag], var_body, 1)
        Set_Entity_Anim(int_values[ent_CTFlag], 1,0);
        get_entvar(victim, var_origin, coordinates[COOR_CT]);
        while(point_contents(coordinates[COOR_CT]) == CONTENTS_EMPTY)
            coordinates[COOR_CT][2] -= 1.0
        set_entvar(int_values[ent_CTFlag], var_origin, coordinates[COOR_CT]);
        int_values[holdingflag_TE] = -1;
        ExecuteForward(forw[flag_dropped], forw[for_forw], victim,int_values[ent_CTFlag], killer);
    }
}
public RG_RestartRound(){
    MOVEBACK_FLAG(int_values[ent_CTFlag])
    MOVEBACK_FLAG(int_values[ent_TEFlag])
}
public MOVEBACK_FLAG(enti){
    set_entvar(enti,var_aiment,-1)
    set_entvar(enti,var_movetype,MOVETYPE_NONE)
    new Float:originf[3]
    Set_Entity_Anim(enti, 0,0);
    if(enti==int_values[ent_TEFlag]){
        get_entvar(int_values[ent_TEFlagBase], var_origin, originf);
        int_values[holdingflag_CT] = 0
        set_entvar(enti, var_body, 2)
    }
    else {
        get_entvar(int_values[ent_CTFlagBase], var_origin, originf);
        int_values[holdingflag_TE] = 0
        set_entvar(enti, var_body, 1)
    }
    entity_set_origin(enti, originf)
    get_entvar(enti, var_angles, originf);
    originf[0] = 360.0
    originf[2] = 0.0
    set_entvar(enti, var_angles, originf);
}
public touch_entity(enti, id){
    if(!is_entity(enti))
        return

    if(!is_valid_player(id))
        return
    if(!is_user_connected(id))
        return
    if(!is_user_alive(id) || is_user_bot(id))
        return

    if(int_values[ent_TEFlagBase] == enti || int_values[ent_CTFlagBase] == enti){
        if(int_values[ent_TEFlagBase] == enti && int_values[holdingflag_CT] == 0 && get_user_team(id) == TEAM_TE && int_values[holdingflag_TE] == id){
            MOVEBACK_FLAG(int_values[ent_CTFlag])
            ExecuteForward(forw[scored], forw[for_forw], id,enti);
            rg_update_teamscores(0,1,true);
            set_entvar(int_values[ent_TEFlagBase], var_body, 4)
            Set_Entity_Anim(int_values[ent_TEFlagBase], 2,0);
            remove_task(int_values[ent_TEFlagBase]);
            set_task(10.0,"Set_RemoveScored",int_values[ent_TEFlagBase]);
        }
        else if(int_values[ent_CTFlagBase] == enti && int_values[holdingflag_TE] == 0 && get_user_team(id) == TEAM_CT && int_values[holdingflag_CT] == id){
            MOVEBACK_FLAG(int_values[ent_TEFlag])
            ExecuteForward(forw[scored], forw[for_forw], id,enti);
            rg_update_teamscores(1,0,true);
            set_entvar(int_values[ent_CTFlagBase], var_body, 4)
            Set_Entity_Anim(int_values[ent_CTFlagBase], 2,0);
            remove_task(int_values[ent_CTFlagBase]);
            set_task(10.0,"Set_RemoveScored",int_values[ent_CTFlagBase]);
        }
        else if(int_values[ent_TEFlagBase] == enti){
            if(!task_exists(id+TASK_TEFLAG)){
                individual[in_TEFlagBase][id] = true
                ExecuteForward(forw[forw_inTEFlagBase], forw[for_forw], id, enti);
            }
            remove_task(id+TASK_TEFLAG);
            set_task(In_Base_Time,"set_reset_value",id+TASK_TEFLAG)
        }
        else if(int_values[ent_CTFlagBase] == enti){
            if(!task_exists(id+TASK_CTFLAG)){
                individual[in_CTFlagBase][id] = true
                ExecuteForward(forw[forw_inCTFlagBase], forw[for_forw], id, enti);
            }
            remove_task(id+TASK_CTFLAG);
            set_task(In_Base_Time,"set_reset_value",id+TASK_CTFLAG)
        }
    }
    if(int_values[ent_TEFlag] == enti || int_values[ent_CTFlag] == enti){
        if(int_values[ent_TEFlag] == enti && is_valid_player(int_values[holdingflag_CT]))
            return
        if(int_values[ent_CTFlag] == enti && is_valid_player(int_values[holdingflag_TE]))
            return


        new casual_ent[3]
        if(int_values[ent_TEFlag] == enti){
            casual_ent[0] = int_values[ent_TEFlag]
            casual_ent[2] = TEAM_TE
            casual_ent[1] = 0
            //client_print_color(id, id, "^3TE Bayragina dokundun.") // You did touch the TE flag
        }
        else{
            casual_ent[0] = int_values[ent_CTFlag]
            casual_ent[2] = TEAM_CT
            casual_ent[1] = 1
            //client_print_color(id, id, "^3CT Bayragina dokundun.") // You did touch the CT flag
        }


        if(get_user_team(id) == casual_ent[2]){
            if((casual_ent[1] ? int_values[holdingflag_TE] : int_values[holdingflag_CT])  == -1){
                MOVEBACK_FLAG(casual_ent[0])
                ExecuteForward(forw[flag_backtobase], forw[for_forw], id,casual_ent[0]);
                return
            }
        }
        else{
            entity_set_int(casual_ent[0], EV_INT_movetype, MOVETYPE_FOLLOW);
            entity_set_edict(casual_ent[0], EV_ENT_aiment, id);
            Set_Entity_Anim(casual_ent[0], 3,0);
            if(get_user_team(id) == TEAM_TE){
                int_values[holdingflag_TE] = id
            }
            else {
                int_values[holdingflag_CT] = id
            }
            ExecuteForward(forw[flag_take], forw[for_forw], id,casual_ent[0]);

        }
    }
}
/*================================================================================
 [Creating Entity]
=================================================================================*/
public CREATE_ENTITY(){

    int_values[ent_CTFlagBase] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_CTFlagBase],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_CTFlagBase], var_model, BKMODEL);
    set_entvar(int_values[ent_CTFlagBase], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_CTFlagBase], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_CTFlagBase], coordinates[COOR_CT])
    entity_set_int(int_values[ent_CTFlagBase],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_CTFlagBase],EV_INT_solid,1)
    set_entvar(int_values[ent_CTFlagBase], var_gravity, 1.5)
    entity_set_size(int_values[ent_CTFlagBase],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
    set_entvar(int_values[ent_CTFlagBase], var_body, 3)

    Set_Entity_Anim(int_values[ent_CTFlagBase], 0,0);
    set_entvar(int_values[ent_CTFlagBase], var_globalname, "CT Flag Base")
//---------------------------------------------------------------
    int_values[ent_TEFlagBase] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_TEFlagBase],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_TEFlagBase], var_model, BKMODEL);
    set_entvar(int_values[ent_TEFlagBase], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_TEFlagBase], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_TEFlagBase], coordinates[COOR_TE])
    entity_set_int(int_values[ent_TEFlagBase],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_TEFlagBase],EV_INT_solid,1)
    set_entvar(int_values[ent_TEFlagBase], var_gravity, 1.5)
    entity_set_size(int_values[ent_TEFlagBase],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
    set_entvar(int_values[ent_TEFlagBase], var_body, 3)
    Set_Entity_Anim(int_values[ent_TEFlagBase], 0,0);
    set_entvar(int_values[ent_TEFlagBase], var_globalname, "TE Flag Base")
//---------------------------------------------------------------
    int_values[ent_CTFlag] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_CTFlag],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_CTFlag], var_model, BKMODEL);
    set_entvar(int_values[ent_CTFlag], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_CTFlag], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_CTFlag], coordinates[COOR_CT])
    entity_set_int(int_values[ent_CTFlag],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_CTFlag],EV_INT_solid,1)
    set_entvar(int_values[ent_CTFlag], var_gravity, 1.5)
    set_entvar(int_values[ent_CTFlag], var_velocity, {0.0,0.0,-50.0});
    entity_set_size(int_values[ent_CTFlag],Float:{-22.62, -26.75, -101.7},Float:{22.64, 24.11, 18.76})
    set_entvar(int_values[ent_CTFlag], var_body, 1)
    Set_Entity_Anim(int_values[ent_CTFlag], 0,0);
    set_entvar(int_values[ent_CTFlag], var_globalname, "CT Flag")
    set_entvar(int_values[ent_CTFlag], var_team, 2)
//---------------------------------------------------------------
    int_values[ent_TEFlag] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_TEFlag],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_TEFlag], var_model, BKMODEL);
    set_entvar(int_values[ent_TEFlag], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_TEFlag], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_TEFlag], coordinates[COOR_TE])
    entity_set_int(int_values[ent_TEFlag],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_TEFlag],EV_INT_solid,1)
    set_entvar(int_values[ent_TEFlag], var_gravity, 1.5)
    set_entvar(int_values[ent_TEFlag], var_velocity, {0.0,0.0,-50.0});
    entity_set_size(int_values[ent_TEFlag],Float:{-22.62, -26.75, -101.7},Float:{22.64, 24.11, 18.76})
    set_entvar(int_values[ent_TEFlag], var_body, 2)
    Set_Entity_Anim(int_values[ent_TEFlag], 0,0);
    set_entvar(int_values[ent_TEFlag], var_globalname, "TE Flag")
    set_entvar(int_values[ent_TEFlag], var_team, 1)

    return PLUGIN_HANDLED
}

public CREATE_NEW_FLAG(TEAM){
    if(TEAM == TEAM_CT){
        if(get_entvar(int_values[ent_NEW_CTFlag], var_body) == 1){
            entity_set_origin(int_values[ent_NEW_CTFlag], coordinates[NEW_COOR_CTBASE])
        }
        else{
            int_values[ent_NEW_CTFlag] = rg_create_entity("info_target")

            entity_set_string(int_values[ent_NEW_CTFlag],EV_SZ_classname, NEWFLAG_CLASS)
            set_entvar(int_values[ent_NEW_CTFlag], var_model, BKMODEL);
            set_entvar(int_values[ent_NEW_CTFlag], var_modelindex, int_values[modeldosyasi]);
            set_entvar(int_values[ent_NEW_CTFlag], var_angles, Float:{360.0, 0.0, 0.0});
            entity_set_origin(int_values[ent_NEW_CTFlag], coordinates[NEW_COOR_CTBASE])
            set_entvar(int_values[ent_NEW_CTFlag], var_gravity, 0.5)
            entity_set_size(int_values[ent_NEW_CTFlag],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
            set_entvar(int_values[ent_NEW_CTFlag], var_body, 1)
            Set_Entity_Anim(int_values[ent_NEW_CTFlag], 2,0);
        }
    }
    else {
        if(get_entvar(int_values[ent_NEW_TEFlag], var_body) == 2){
            entity_set_origin(int_values[ent_NEW_TEFlag], coordinates[NEW_COOR_TEBASE])
        }
        else{
            int_values[ent_NEW_TEFlag] = rg_create_entity("info_target")

            entity_set_string(int_values[ent_NEW_TEFlag],EV_SZ_classname, NEWFLAG_CLASS)
            set_entvar(int_values[ent_NEW_TEFlag], var_model, BKMODEL);
            set_entvar(int_values[ent_NEW_TEFlag], var_modelindex, int_values[modeldosyasi]);
            set_entvar(int_values[ent_NEW_TEFlag], var_angles, Float:{360.0, 0.0, 0.0});
            entity_set_origin(int_values[ent_NEW_TEFlag], coordinates[NEW_COOR_TEBASE])
            set_entvar(int_values[ent_NEW_TEFlag], var_gravity, 0.5)
            entity_set_size(int_values[ent_NEW_TEFlag],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
            set_entvar(int_values[ent_NEW_TEFlag], var_body, 2)
            Set_Entity_Anim(int_values[ent_NEW_TEFlag], 2,0);
        }
    }
}
/*================================================================================
 [SCTF Menu]
=================================================================================*/
public SCTF_MENU(id, level, cid){
    if( !cmd_access( id, level, cid, 1 ) )
        return PLUGIN_HANDLED;

    new menu, Menuz[512]

    formatex(Menuz, charsmax(Menuz), "\y [ Simple Capture the Flag \dv\r%s \y]^n\wBy:\r %s", VERSION, AUTHOR );

    menu = menu_create(Menuz, "c_SCTF_MENU")

    formatex(Menuz, charsmax(Menuz), "\wNew CT Flag Coordinates^n\w-------------->\y[\r%.0f\y] [\r%.0f\y] [\r%.0f\y]" ,coordinates[NEW_COOR_CTBASE][0],coordinates[NEW_COOR_CTBASE][1],coordinates[NEW_COOR_CTBASE][2]);
    menu_additem(menu, Menuz, "1")
    formatex(Menuz, charsmax(Menuz), "\wNew TE Flag Coordinates^n\w-------------->\y[\r%.0f\y] [\r%.0f\y] [\r%.0f\y]^n^n" ,coordinates[NEW_COOR_TEBASE][0],coordinates[NEW_COOR_TEBASE][1],coordinates[NEW_COOR_TEBASE][2]);
    menu_additem(menu, Menuz, "2")

    formatex(Menuz, charsmax(Menuz), "\wSave" );
    menu_additem(menu, Menuz, "3")

    menu_display(id, menu, 0)

    return PLUGIN_HANDLED
}
public c_SCTF_MENU(iId, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)

        return PLUGIN_HANDLED;
    }
    new data[6], iName[64]
    new access, callback
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)

    new key = str_to_num(data)

    switch(key)
    {
        case 1:
        {
            get_entvar(iId, var_origin, coordinates[NEW_COOR_CTBASE]);

            while(point_contents(coordinates[NEW_COOR_CTBASE]) == CONTENTS_EMPTY)
                coordinates[NEW_COOR_CTBASE][2] -= 1.0

            CREATE_NEW_FLAG(TEAM_CT)

            client_cmd(iId,MENU_COMMAND)
        }
        case 2:
        {
            get_entvar(iId, var_origin, coordinates[NEW_COOR_TEBASE]);

            while(point_contents(coordinates[NEW_COOR_TEBASE]) == CONTENTS_EMPTY)
                coordinates[NEW_COOR_TEBASE][2] -= 1.0
            CREATE_NEW_FLAG(TEAM_TE)

            client_cmd(iId,MENU_COMMAND)
        }

        case 3:
        {
            Write_new_Coordinates();
            client_print_color(iId, iId, "Saved...")
        }
    }
    return PLUGIN_HANDLED;

}
/*================================================================================
 [Fast commands]
=================================================================================*/
public set_reset_value(id){
    if(id < TASK_TEFLAG+50){
        individual[in_TEFlagBase][id-TASK_TEFLAG] = false
    }
    else{
        individual[in_CTFlagBase][id-TASK_CTFLAG] = false
    }
}
public Set_RemoveScored(enti){
    set_entvar(enti, var_body, 3)
    Set_Entity_Anim(enti, 0,0);
}
stock Set_Entity_Anim(ent, Anim, ResetFrame)
{
    if(!is_entity(ent))
        return

    set_entvar(ent, var_animtime, get_gametime())
    set_entvar(ent, var_framerate, 1.0)
    set_entvar(ent, var_sequence, Anim)
    if(ResetFrame) set_entvar(ent, var_frame, 0.0)
}

public Write_new_Coordinates(){
    new mapname[32], filepath[100]
    get_mapname(mapname, charsmax(mapname))
    formatex(filepath, charsmax(filepath), "maps/%s.sctf.cfg", mapname)

    if (file_exists(filepath))
        delete_file(filepath)

    new szBuffer[150]

    formatex(szBuffer, charsmax(szBuffer), "-->TEX = %.0f^n-->TEY = %.0f^n-->TEZ = %.0f^n-->CTX = %.0f^n-->CTY = %.0f^n-->CTZ = %.0f^n",coordinates[NEW_COOR_TEBASE][0],coordinates[NEW_COOR_TEBASE][1],coordinates[NEW_COOR_TEBASE][2],coordinates[NEW_COOR_CTBASE][0],coordinates[NEW_COOR_CTBASE][1],coordinates[NEW_COOR_CTBASE][2])
    write_file(filepath,szBuffer)
}
 
Сообщения
109
Реакции
79
Помог
1 раз(а)

When I change MOVETYPE_TOSS to MOVETYPE_NONE, bug is correcting. But flag isn't fall to ground.
 

Garey

ninjaCow
Сообщения
439
Реакции
1,092
Помог
11 раз(а)
Сообщения
1,701
Реакции
1,512
Помог
26 раз(а)
Мы в майкрософте что ли?
3 Июл 2019
Код:
public CREATE_ENTITY(){

    int_values[ent_CTFlagBase] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_CTFlagBase],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_CTFlagBase], var_model, BKMODEL);
    set_entvar(int_values[ent_CTFlagBase], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_CTFlagBase], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_CTFlagBase], coordinates[COOR_CT])
    entity_set_int(int_values[ent_CTFlagBase],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_CTFlagBase],EV_INT_solid,1)
    set_entvar(int_values[ent_CTFlagBase], var_gravity, 1.5)
    entity_set_size(int_values[ent_CTFlagBase],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
    set_entvar(int_values[ent_CTFlagBase], var_body, 3)

    Set_Entity_Anim(int_values[ent_CTFlagBase], 0,0);
    set_entvar(int_values[ent_CTFlagBase], var_globalname, "CT Flag Base")
//---------------------------------------------------------------
    int_values[ent_TEFlagBase] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_TEFlagBase],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_TEFlagBase], var_model, BKMODEL);
    set_entvar(int_values[ent_TEFlagBase], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_TEFlagBase], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_TEFlagBase], coordinates[COOR_TE])
    entity_set_int(int_values[ent_TEFlagBase],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_TEFlagBase],EV_INT_solid,1)
    set_entvar(int_values[ent_TEFlagBase], var_gravity, 1.5)
    entity_set_size(int_values[ent_TEFlagBase],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
    set_entvar(int_values[ent_TEFlagBase], var_body, 3)
    Set_Entity_Anim(int_values[ent_TEFlagBase], 0,0);
    set_entvar(int_values[ent_TEFlagBase], var_globalname, "TE Flag Base")
//---------------------------------------------------------------
    int_values[ent_CTFlag] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_CTFlag],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_CTFlag], var_model, BKMODEL);
    set_entvar(int_values[ent_CTFlag], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_CTFlag], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_CTFlag], coordinates[COOR_CT])
    entity_set_int(int_values[ent_CTFlag],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_CTFlag],EV_INT_solid,1)
    set_entvar(int_values[ent_CTFlag], var_gravity, 1.5)
    set_entvar(int_values[ent_CTFlag], var_velocity, {0.0,0.0,-50.0});
    entity_set_size(int_values[ent_CTFlag],Float:{-22.62, -26.75, -101.7},Float:{22.64, 24.11, 18.76})
    set_entvar(int_values[ent_CTFlag], var_body, 1)
    Set_Entity_Anim(int_values[ent_CTFlag], 0,0);
    set_entvar(int_values[ent_CTFlag], var_globalname, "CT Flag")
    set_entvar(int_values[ent_CTFlag], var_team, 2)
//---------------------------------------------------------------
    int_values[ent_TEFlag] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_TEFlag],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_TEFlag], var_model, BKMODEL);
    set_entvar(int_values[ent_TEFlag], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_TEFlag], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_TEFlag], coordinates[COOR_TE])
    entity_set_int(int_values[ent_TEFlag],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_TEFlag],EV_INT_solid,1)
    set_entvar(int_values[ent_TEFlag], var_gravity, 1.5)
    set_entvar(int_values[ent_TEFlag], var_velocity, {0.0,0.0,-50.0});
    entity_set_size(int_values[ent_TEFlag],Float:{-22.62, -26.75, -101.7},Float:{22.64, 24.11, 18.76})
    set_entvar(int_values[ent_TEFlag], var_body, 2)
    Set_Entity_Anim(int_values[ent_TEFlag], 0,0);
    set_entvar(int_values[ent_TEFlag], var_globalname, "TE Flag")
    set_entvar(int_values[ent_TEFlag], var_team, 1)

    return PLUGIN_HANDLED
}
Это что, копипаста с возвращением значения в невозвращаемой функции?
 
Сообщения
109
Реакции
79
Помог
1 раз(а)
Garey, It didn't happen.
fl0wer, is there command about touch in reapi? I didn't see. And I think no, can you write in English?

I did it with BMOD module, https://forums.alliedmods.net/showthread.php?t=178066
Форматирование (BB-код):
/* Yek'-ta

    https://github.com/yek-ta/AMXX-PLUGINS/tree/master/Simple%20Capture%20the%20Flag

*/

#include <amxmodx>
#include <amxmisc>
#include <reapi>
#include <engine>
#include <bmod>

#define MENU_COMMAND "amx_menu_sctf"
#define MENU_FLAG ADMIN_RCON

// started Simple Capture the Flag plugin.
#define PLUGIN  "Simple Capture the Flag"
#define VERSION "1.8.0B"
#define AUTHOR  "Yek'-ta"

#define FLAG_CLASS "SimpleCTFlag"
#define NEWFLAG_CLASS "NewSimpleCTFlag"

#define TEAM_TE 1
#define TEAM_CT 2
#define In_Base_Time 1.0

#define TASK_TEFLAG 100
//There should be 100 values difference between the two fields. For no bugs.
#define TASK_CTFLAG 200

#define is_valid_player(%1) (1 <= %1 <= 32)

new BKMODEL[64]

enum _:COORDINATE_NAMES
{
    COOR_CT,
    COOR_TE,
    NEW_COOR_CTBASE,
    NEW_COOR_TEBASE
}
enum _:INT_VALUES_NAMES
{
    holdingflag_CT,
    ent_CTFlag,
    ent_CTFlagBase,
    ent_NEW_CTFlag,
    holdingflag_TE,
    ent_TEFlag,
    ent_TEFlagBase,
    ent_NEW_TEFlag,
    modeldosyasi
}

enum _:FORW_VALUES_NAMES
{
    for_forw,
    flag_dropped,
    flag_take,
    flag_backtobase,
    scored,
    forw_inTEFlagBase,
    forw_inCTFlagBase
}
enum _:INDIVIDUAL_BOOLS
{
    in_TEFlagBase,
    in_CTFlagBase,
}

new Float:coordinates[COORDINATE_NAMES][3]
new int_values[INT_VALUES_NAMES]
new forw[FORW_VALUES_NAMES]
new bool:individual[INDIVIDUAL_BOOLS][33]
new worldObj
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_cvar("SCTF",VERSION,FCVAR_SERVER)
    register_clcmd(MENU_COMMAND, "SCTF_MENU" , MENU_FLAG)

    //Events
    register_touch(FLAG_CLASS, "player",  "touch_entity");
    RegisterHookChain(RG_CSGameRules_RestartRound, "RG_RestartRound", true)
    RegisterHookChain(RG_CSGameRules_PlayerKilled, "RG_PlayerKilled", true)

    //Forward
    forw[flag_dropped] = CreateMultiForward("sctf_flag_dropped", ET_IGNORE, FP_CELL,FP_CELL, FP_CELL)
    forw[flag_take] = CreateMultiForward("sctf_flag_is_takenoff", ET_IGNORE, FP_CELL,FP_CELL)
    forw[flag_backtobase] = CreateMultiForward("sctf_flag_backtobase", ET_IGNORE, FP_CELL,FP_CELL)
    forw[scored] = CreateMultiForward("sctf_flag_scored", ET_IGNORE, FP_CELL,FP_CELL)
    forw[forw_inTEFlagBase] = CreateMultiForward("sctf_player_entered_TEFlagBase", ET_IGNORE, FP_CELL,FP_CELL)
    forw[forw_inCTFlagBase] = CreateMultiForward("sctf_player_entered_CTFlagBase", ET_IGNORE, FP_CELL,FP_CELL)

    worldObj = bmod_obj_from_ent(0)
    //set world friction and restitution
    bmod_obj_call(worldObj, "setFriction", 1.0)
    bmod_obj_call(worldObj, "setRestitution", 1.0)
}

public plugin_precache()
{
    formatex(BKMODEL,charsmax(BKMODEL),"models/sctf/flag2019.mdl");

    SCTF_Files()

    int_values[modeldosyasi] = precache_model(BKMODEL)
}
public plugin_cfg(){
    if(coordinates[COOR_TE][0] == 0.0 && coordinates[COOR_TE][1] == 0.0 && coordinates[COOR_TE][2] == 0.0 && coordinates[COOR_CT][0] == 0.0 && coordinates[COOR_CT][1] == 0.0 && coordinates[COOR_CT][2] == 0.0){
        new iFindSpawn = find_ent_by_class(get_member_game(m_nMaxPlayers), "info_player_deathmatch")
        if(iFindSpawn){
            get_entvar(iFindSpawn, var_origin, coordinates[NEW_COOR_TEBASE]);
            while(point_contents(coordinates[NEW_COOR_TEBASE]) == CONTENTS_EMPTY)
                coordinates[NEW_COOR_TEBASE][2] -= 1.0
        }
        else{
            server_print("[ SCTF ] There is a problem about TESpawnPoints")
            return;
        }
        iFindSpawn = find_ent_by_class(get_member_game(m_nMaxPlayers), "info_player_start")
        if(iFindSpawn){
            get_entvar(iFindSpawn, var_origin, coordinates[NEW_COOR_CTBASE]);
            while(point_contents(coordinates[NEW_COOR_CTBASE]) == CONTENTS_EMPTY)
                coordinates[NEW_COOR_CTBASE][2] -= 1.0
        }
        else{
            server_print("[ SCTF ] There is a problem about CTSpawnPoints")
            return;
        }
        Write_new_Coordinates();
        server_print("[ SCTF ] Wrote new coordinates for map.")
        SCTF_Files()
    }
    CREATE_ENTITY()
}
/*================================================================================
 [read flag coord]
=================================================================================*/
public SCTF_Files(){
    new cfgdir[32], mapname[32], filepath[100], linedata[128]
    get_configsdir(cfgdir, charsmax(cfgdir))
    new file
    new key[40], value[64]

    formatex(filepath, charsmax(filepath), "%s/sctf_config.ini", cfgdir)

    if (file_exists(filepath))
    {
        file = fopen(filepath, "rt")

        while (file && !feof(file))
        {
            fgets(file, linedata, charsmax(linedata))

            replace(linedata, charsmax(linedata), "^n", "")

            if( linedata[ 0 ] == ';' || linedata[ 0 ] == '/' || !strlen( linedata ) )
                continue;

            if (linedata[0] == '-' && linedata[1] == '-' && linedata[2] == '>'){

                strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
                trim(key)
                trim(value)

                if (equal(key[3], "FLAG MODEL"))
                {
                    formatex(BKMODEL,charsmax(BKMODEL),value);
                    server_print("[ SCTF ] Flag model changed to %s ", value)
                }
                else {
                    server_cmd("%s",key[3])
                }
                continue;
            }
        }
        if (file) fclose(file)
    }

    //Flags

    get_mapname(mapname, charsmax(mapname))
    formatex(filepath, charsmax(filepath), "maps/%s.sctf.cfg", mapname)

    if (!file_exists(filepath))
    {
        server_print("[ SCTF ] There is no flag values in %s ", filepath)
        return;
    }

    file = fopen(filepath, "rt")

    while (file && !feof(file))
    {
        fgets(file, linedata, charsmax(linedata))

        replace(linedata, charsmax(linedata), "^n", "")

        if( linedata[ 0 ] == ';' || linedata[ 0 ] == '/' || !strlen( linedata ) )
            continue;

        if (linedata[0] == '-' && linedata[1] == '-' && linedata[2] == '>'){

            strtok(linedata, key, charsmax(key), value, charsmax(value), '=')
            trim(key)
            trim(value)

            if (equal(key[3], "TEX"))
            {
                coordinates[COOR_TE][0] = floatstr(value)
            }
            else if (equal(key[3], "TEY"))
            {
                coordinates[COOR_TE][1] = floatstr(value)
            }
            else if (equal(key[3], "TEZ"))
            {
                coordinates[COOR_TE][2] = floatstr(value)
            }

            else if (equal(key[3], "CTX"))
            {
                coordinates[COOR_CT][0] = floatstr(value)
            }
            else if (equal(key[3], "CTY"))
            {
                coordinates[COOR_CT][1] = floatstr(value)
            }
            else if (equal(key[3], "CTZ"))
            {
                coordinates[COOR_CT][2] = floatstr(value)
            }
            continue;
        }
    }
    if (file) fclose(file)
    server_print("[ SCTF ] read in %s .", filepath)

    coordinates[NEW_COOR_TEBASE][0] = coordinates[COOR_TE][0]
    coordinates[NEW_COOR_TEBASE][1] = coordinates[COOR_TE][1]
    coordinates[NEW_COOR_TEBASE][2] = coordinates[COOR_TE][2]

    coordinates[NEW_COOR_CTBASE][0] = coordinates[COOR_CT][0]
    coordinates[NEW_COOR_CTBASE][1] = coordinates[COOR_CT][1]
    coordinates[NEW_COOR_CTBASE][2] = coordinates[COOR_CT][2]
}
/*================================================================================
 [Native]
=================================================================================*/
public plugin_natives()
{
    register_native("sctf_who_TEflagger", "native_who_TEflagger", 1)
    register_native("sctf_who_CTflagger", "native_who_CTflagger", 1)
    register_native("sctf_ent_TEFlagBase", "native_ent_TEFlagBase", 1)
    register_native("sctf_ent_CTFlagBase", "native_ent_CTFlagBase", 1)
    register_native("sctf_ent_TEFlag", "native_ent_TEFlag", 1)
    register_native("sctf_ent_CTFlag", "native_ent_CTFlag", 1)
    register_native("is_user_inCTFlagBase", "native_is_user_inCTFlagBase", 1)
    register_native("is_user_inTEFlagBase", "native_is_user_inTEFlagBase", 1)

    register_native("sctf_move_to_flag_back", "MOVEBACK_FLAG", 1)
}
public native_who_TEflagger()
{
    return int_values[holdingflag_TE];
}
public native_who_CTflagger()
{
    return int_values[holdingflag_CT];
}
public native_ent_TEFlagBase()
{
    return int_values[ent_TEFlagBase];
}
public native_ent_CTFlagBase()
{
    return int_values[ent_CTFlagBase];
}
public native_ent_TEFlag()
{
    return int_values[ent_TEFlag];
}
public native_ent_CTFlag()
{
    return int_values[ent_CTFlag];
}
public native_is_user_inCTFlagBase(id)
{
    return individual[in_CTFlagBase][id];
}
public native_is_user_inTEFlagBase(id)
{
    return individual[in_TEFlagBase][id];
}
/*================================================================================
 [Events]
=================================================================================*/
public client_disconnected(id){
    if(int_values[holdingflag_TE] == id){
        MOVEBACK_FLAG(int_values[ent_CTFlag])
    }
    else if(int_values[holdingflag_CT] == id){
        MOVEBACK_FLAG(int_values[ent_TEFlag])
    }
}
public RG_PlayerKilled(const victim, const killer){
    if(int_values[holdingflag_CT] == victim){
        set_entvar(int_values[ent_TEFlag],var_aiment,-1)
        entity_set_int(int_values[ent_TEFlag],EV_INT_movetype,MOVETYPE_NOCLIP)
        set_entvar(int_values[ent_TEFlag], var_body, 2)
        Set_Entity_Anim(int_values[ent_TEFlag], 1,0);
        int_values[holdingflag_CT] = -1;
        get_entvar(victim, var_origin, coordinates[COOR_TE]);
        while(point_contents(coordinates[COOR_TE]) == CONTENTS_EMPTY)
            coordinates[COOR_TE][2] -= 1.0
        set_entvar(int_values[ent_TEFlag], var_origin, coordinates[COOR_TE]);
        ExecuteForward(forw[flag_dropped], forw[for_forw], victim,int_values[ent_TEFlag], killer);
    }
    else if(int_values[holdingflag_TE] == victim){
        set_entvar(int_values[ent_CTFlag],var_aiment,-1)
        entity_set_int(int_values[ent_CTFlag],EV_INT_movetype,MOVETYPE_NOCLIP)
        set_entvar(int_values[ent_CTFlag], var_body, 1)
        Set_Entity_Anim(int_values[ent_CTFlag], 1,0);
        int_values[holdingflag_TE] = -1;
        get_entvar(victim, var_origin, coordinates[COOR_CT]);
        while(point_contents(coordinates[COOR_CT]) == CONTENTS_EMPTY)
            coordinates[COOR_CT][2] -= 1.0
        set_entvar(int_values[ent_CTFlag], var_origin, coordinates[COOR_CT]);
        ExecuteForward(forw[flag_dropped], forw[for_forw], victim,int_values[ent_CTFlag], killer);
    }
}
public RG_RestartRound(){
    MOVEBACK_FLAG(int_values[ent_CTFlag])
    MOVEBACK_FLAG(int_values[ent_TEFlag])
}
public MOVEBACK_FLAG(enti){
    set_entvar(enti,var_aiment,-1)
    set_entvar(enti,var_movetype,MOVETYPE_NONE)
    new Float:originf[3]
    Set_Entity_Anim(enti, 0,0);
    if(enti==int_values[ent_TEFlag]){
        get_entvar(int_values[ent_TEFlagBase], var_origin, originf);
        int_values[holdingflag_CT] = 0
        set_entvar(enti, var_body, 2)
    }
    else {
        get_entvar(int_values[ent_CTFlagBase], var_origin, originf);
        int_values[holdingflag_TE] = 0
        set_entvar(enti, var_body, 1)
    }
    entity_set_origin(enti, originf)
    get_entvar(enti, var_angles, originf);
    originf[0] = 360.0
    originf[2] = 0.0
    set_entvar(enti, var_angles, originf);
}
public touch_entity(enti, id){
    if(!is_entity(enti))
        return

    if(!is_valid_player(id))
        return
    if(!is_user_connected(id))
        return
    if(!is_user_alive(id) || is_user_bot(id))
        return

    if(int_values[ent_TEFlagBase] == enti || int_values[ent_CTFlagBase] == enti){
        if(int_values[ent_TEFlagBase] == enti && int_values[holdingflag_CT] == 0 && get_user_team(id) == TEAM_TE && int_values[holdingflag_TE] == id){
            MOVEBACK_FLAG(int_values[ent_CTFlag])
            ExecuteForward(forw[scored], forw[for_forw], id,enti);
            rg_update_teamscores(0,1,true);
            set_entvar(int_values[ent_TEFlagBase], var_body, 4)
            Set_Entity_Anim(int_values[ent_TEFlagBase], 2,0);
            remove_task(int_values[ent_TEFlagBase]);
            set_task(10.0,"Set_RemoveScored",int_values[ent_TEFlagBase]);
        }
        else if(int_values[ent_CTFlagBase] == enti && int_values[holdingflag_TE] == 0 && get_user_team(id) == TEAM_CT && int_values[holdingflag_CT] == id){
            MOVEBACK_FLAG(int_values[ent_TEFlag])
            ExecuteForward(forw[scored], forw[for_forw], id,enti);
            rg_update_teamscores(1,0,true);
            set_entvar(int_values[ent_CTFlagBase], var_body, 4)
            Set_Entity_Anim(int_values[ent_CTFlagBase], 2,0);
            remove_task(int_values[ent_CTFlagBase]);
            set_task(10.0,"Set_RemoveScored",int_values[ent_CTFlagBase]);
        }
        else if(int_values[ent_TEFlagBase] == enti){
            if(!task_exists(id+TASK_TEFLAG)){
                individual[in_TEFlagBase][id] = true
                ExecuteForward(forw[forw_inTEFlagBase], forw[for_forw], id, enti);
            }
            remove_task(id+TASK_TEFLAG);
            set_task(In_Base_Time,"set_reset_value",id+TASK_TEFLAG)
        }
        else if(int_values[ent_CTFlagBase] == enti){
            if(!task_exists(id+TASK_CTFLAG)){
                individual[in_CTFlagBase][id] = true
                ExecuteForward(forw[forw_inCTFlagBase], forw[for_forw], id, enti);
            }
            remove_task(id+TASK_CTFLAG);
            set_task(In_Base_Time,"set_reset_value",id+TASK_CTFLAG)
        }
    }
    if(int_values[ent_TEFlag] == enti || int_values[ent_CTFlag] == enti){
        if(int_values[ent_TEFlag] == enti && is_valid_player(int_values[holdingflag_CT]))
            return
        if(int_values[ent_CTFlag] == enti && is_valid_player(int_values[holdingflag_TE]))
            return


        new casual_ent[3]
        if(int_values[ent_TEFlag] == enti){
            casual_ent[0] = int_values[ent_TEFlag]
            casual_ent[2] = TEAM_TE
            casual_ent[1] = 0
            //client_print_color(id, id, "^3TE Bayragina dokundun.") // You did touch the TE flag
        }
        else{
            casual_ent[0] = int_values[ent_CTFlag]
            casual_ent[2] = TEAM_CT
            casual_ent[1] = 1
            //client_print_color(id, id, "^3CT Bayragina dokundun.") // You did touch the CT flag
        }


        if(get_user_team(id) == casual_ent[2]){
            if((casual_ent[1] ? int_values[holdingflag_TE] : int_values[holdingflag_CT])  == -1){
                MOVEBACK_FLAG(casual_ent[0])
                ExecuteForward(forw[flag_backtobase], forw[for_forw], id,casual_ent[0]);
                return
            }
        }
        else{
            entity_set_int(casual_ent[0], EV_INT_movetype, MOVETYPE_FOLLOW);
            entity_set_edict(casual_ent[0], EV_ENT_aiment, id);
            Set_Entity_Anim(casual_ent[0], 3,0);
            if(get_user_team(id) == TEAM_TE){
                int_values[holdingflag_TE] = id
            }
            else {
                int_values[holdingflag_CT] = id
            }
            ExecuteForward(forw[flag_take], forw[for_forw], id,casual_ent[0]);

        }
    }
}
/*================================================================================
 [Creating Entity]
=================================================================================*/
public CREATE_ENTITY(){



    int_values[ent_CTFlagBase] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_CTFlagBase],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_CTFlagBase], var_model, BKMODEL);
    set_entvar(int_values[ent_CTFlagBase], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_CTFlagBase], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_CTFlagBase], coordinates[COOR_CT])
    entity_set_int(int_values[ent_CTFlagBase],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_CTFlagBase],EV_INT_solid,1)
    set_entvar(int_values[ent_CTFlagBase], var_gravity, 1.5)
    entity_set_size(int_values[ent_CTFlagBase],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
    set_entvar(int_values[ent_CTFlagBase], var_body, 3)

    Set_Entity_Anim(int_values[ent_CTFlagBase], 0,0);
    set_entvar(int_values[ent_CTFlagBase], var_globalname, "CT Flag Base")
//---------------------------------------------------------------
    int_values[ent_TEFlagBase] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_TEFlagBase],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_TEFlagBase], var_model, BKMODEL);
    set_entvar(int_values[ent_TEFlagBase], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_TEFlagBase], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_TEFlagBase], coordinates[COOR_TE])
    entity_set_int(int_values[ent_TEFlagBase],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_TEFlagBase],EV_INT_solid,1)
    set_entvar(int_values[ent_TEFlagBase], var_gravity, 1.5)
    entity_set_size(int_values[ent_TEFlagBase],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
    set_entvar(int_values[ent_TEFlagBase], var_body, 3)
    Set_Entity_Anim(int_values[ent_TEFlagBase], 0,0);
    set_entvar(int_values[ent_TEFlagBase], var_globalname, "TE Flag Base")
//---------------------------------------------------------------
    int_values[ent_CTFlag] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_CTFlag],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_CTFlag], var_model, BKMODEL);
    set_entvar(int_values[ent_CTFlag], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_CTFlag], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_CTFlag], coordinates[COOR_CT])
    entity_set_int(int_values[ent_CTFlag],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_CTFlag],EV_INT_solid,1)
    set_entvar(int_values[ent_CTFlag], var_gravity, 1.5)
    set_entvar(int_values[ent_CTFlag], var_velocity, {0.0,0.0,-50.0});
    entity_set_size(int_values[ent_CTFlag],Float:{-22.62, -26.75, -101.7},Float:{22.64, 24.11, 18.76})
    set_entvar(int_values[ent_CTFlag], var_body, 1)
    Set_Entity_Anim(int_values[ent_CTFlag], 0,0);
    set_entvar(int_values[ent_CTFlag], var_globalname, "CT Flag")
    set_entvar(int_values[ent_CTFlag], var_team, 2)
    //create new bmod object
    new object = bmod_obj_new("BMOD/box/24/24/8", 1.0)
    //hook entity with bmod object
    bmod_obj_assign_ent(object, int_values[ent_CTFlag])
    bmod_obj_update_pos(object)

    bmod_obj_call(object, "setFriction", 2.0)
    bmod_obj_call(object, "setRestitution", 0.88)

//---------------------------------------------------------------
    int_values[ent_TEFlag] = rg_create_entity("info_target")

    entity_set_string(int_values[ent_TEFlag],EV_SZ_classname, FLAG_CLASS)
    set_entvar(int_values[ent_TEFlag], var_model, BKMODEL);
    set_entvar(int_values[ent_TEFlag], var_modelindex, int_values[modeldosyasi]);
    set_entvar(int_values[ent_TEFlag], var_angles, Float:{360.0, 0.0, 0.0});
    entity_set_origin(int_values[ent_TEFlag], coordinates[COOR_TE])
    entity_set_int(int_values[ent_TEFlag],EV_INT_movetype,MOVETYPE_NONE)
    entity_set_int(int_values[ent_TEFlag],EV_INT_solid,1)
    set_entvar(int_values[ent_TEFlag], var_gravity, 1.5)
    set_entvar(int_values[ent_TEFlag], var_velocity, {0.0,0.0,-50.0});
    entity_set_size(int_values[ent_TEFlag],Float:{-22.62, -26.75, -101.7},Float:{22.64, 24.11, 18.76})
    set_entvar(int_values[ent_TEFlag], var_body, 2)
    Set_Entity_Anim(int_values[ent_TEFlag], 0,0);
    set_entvar(int_values[ent_TEFlag], var_globalname, "TE Flag")
    set_entvar(int_values[ent_TEFlag], var_team, 1)
    object = bmod_obj_new("BMOD/box/24/24/8", 1.0)
    //hook entity with bmod object
    bmod_obj_assign_ent(object, int_values[ent_TEFlag])
    bmod_obj_update_pos(object)

    bmod_obj_call(object, "setFriction", 2.0)
    bmod_obj_call(object, "setRestitution", 0.88)

}

public CREATE_NEW_FLAG(TEAM){
    if(TEAM == TEAM_CT){
        if(get_entvar(int_values[ent_NEW_CTFlag], var_body) == 1){
            entity_set_origin(int_values[ent_NEW_CTFlag], coordinates[NEW_COOR_CTBASE])
        }
        else{
            int_values[ent_NEW_CTFlag] = rg_create_entity("info_target")

            entity_set_string(int_values[ent_NEW_CTFlag],EV_SZ_classname, NEWFLAG_CLASS)
            set_entvar(int_values[ent_NEW_CTFlag], var_model, BKMODEL);
            set_entvar(int_values[ent_NEW_CTFlag], var_modelindex, int_values[modeldosyasi]);
            set_entvar(int_values[ent_NEW_CTFlag], var_angles, Float:{360.0, 0.0, 0.0});
            entity_set_origin(int_values[ent_NEW_CTFlag], coordinates[NEW_COOR_CTBASE])
            set_entvar(int_values[ent_NEW_CTFlag], var_gravity, 0.5)
            entity_set_size(int_values[ent_NEW_CTFlag],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
            set_entvar(int_values[ent_NEW_CTFlag], var_body, 1)
            Set_Entity_Anim(int_values[ent_NEW_CTFlag], 2,0);
        }
    }
    else {
        if(get_entvar(int_values[ent_NEW_TEFlag], var_body) == 2){
            entity_set_origin(int_values[ent_NEW_TEFlag], coordinates[NEW_COOR_TEBASE])
        }
        else{
            int_values[ent_NEW_TEFlag] = rg_create_entity("info_target")

            entity_set_string(int_values[ent_NEW_TEFlag],EV_SZ_classname, NEWFLAG_CLASS)
            set_entvar(int_values[ent_NEW_TEFlag], var_model, BKMODEL);
            set_entvar(int_values[ent_NEW_TEFlag], var_modelindex, int_values[modeldosyasi]);
            set_entvar(int_values[ent_NEW_TEFlag], var_angles, Float:{360.0, 0.0, 0.0});
            entity_set_origin(int_values[ent_NEW_TEFlag], coordinates[NEW_COOR_TEBASE])
            set_entvar(int_values[ent_NEW_TEFlag], var_gravity, 0.5)
            entity_set_size(int_values[ent_NEW_TEFlag],Float:{-25.0,-25.0,-5.0},Float:{25.0,25.0,25.0})
            set_entvar(int_values[ent_NEW_TEFlag], var_body, 2)
            Set_Entity_Anim(int_values[ent_NEW_TEFlag], 2,0);
        }
    }
}
/*================================================================================
 [SCTF Menu]
=================================================================================*/
public SCTF_MENU(id, level, cid){
    if( !cmd_access( id, level, cid, 1 ) )
        return PLUGIN_HANDLED;

    new menu, Menuz[512]

    formatex(Menuz, charsmax(Menuz), "\y [ Simple Capture the Flag \dv\r%s \y]^n\wBy:\r %s", VERSION, AUTHOR );

    menu = menu_create(Menuz, "c_SCTF_MENU")

    formatex(Menuz, charsmax(Menuz), "\wNew CT Flag Coordinates^n\w-------------->\y[\r%.0f\y] [\r%.0f\y] [\r%.0f\y]" ,coordinates[NEW_COOR_CTBASE][0],coordinates[NEW_COOR_CTBASE][1],coordinates[NEW_COOR_CTBASE][2]);
    menu_additem(menu, Menuz, "1")
    formatex(Menuz, charsmax(Menuz), "\wNew TE Flag Coordinates^n\w-------------->\y[\r%.0f\y] [\r%.0f\y] [\r%.0f\y]^n^n" ,coordinates[NEW_COOR_TEBASE][0],coordinates[NEW_COOR_TEBASE][1],coordinates[NEW_COOR_TEBASE][2]);
    menu_additem(menu, Menuz, "2")

    formatex(Menuz, charsmax(Menuz), "\wSave" );
    menu_additem(menu, Menuz, "3")

    menu_display(id, menu, 0)

    return PLUGIN_HANDLED
}
public c_SCTF_MENU(iId, menu, item)
{
    if (item == MENU_EXIT)
    {
        menu_destroy(menu)

        return PLUGIN_HANDLED;
    }
    new data[6], iName[64]
    new access, callback
    menu_item_getinfo(menu, item, access, data,5, iName, 63, callback)

    new key = str_to_num(data)

    switch(key)
    {
        case 1:
        {
            get_entvar(iId, var_origin, coordinates[NEW_COOR_CTBASE]);

            while(point_contents(coordinates[NEW_COOR_CTBASE]) == CONTENTS_EMPTY)
                coordinates[NEW_COOR_CTBASE][2] -= 1.0
            coordinates[NEW_COOR_CTBASE][2] += 3.0
            CREATE_NEW_FLAG(TEAM_CT)

            client_cmd(iId,MENU_COMMAND)
        }
        case 2:
        {
            get_entvar(iId, var_origin, coordinates[NEW_COOR_TEBASE]);

            while(point_contents(coordinates[NEW_COOR_TEBASE]) == CONTENTS_EMPTY)
                coordinates[NEW_COOR_TEBASE][2] -= 1.0
            coordinates[NEW_COOR_TEBASE][2] += 3.0
            CREATE_NEW_FLAG(TEAM_TE)

            client_cmd(iId,MENU_COMMAND)
        }

        case 3:
        {
            Write_new_Coordinates();
            client_print_color(iId, iId, "Saved...")
        }
    }
    return PLUGIN_HANDLED;

}
/*================================================================================
 [Fast commands]
=================================================================================*/
public set_reset_value(id){
    if(id < TASK_TEFLAG+50){
        individual[in_TEFlagBase][id-TASK_TEFLAG] = false
    }
    else{
        individual[in_CTFlagBase][id-TASK_CTFLAG] = false
    }
}
public Set_RemoveScored(enti){
    set_entvar(enti, var_body, 3)
    Set_Entity_Anim(enti, 0,0);
}
stock Set_Entity_Anim(ent, Anim, ResetFrame)
{
    if(!is_entity(ent))
        return

    set_entvar(ent, var_animtime, get_gametime())
    set_entvar(ent, var_framerate, 1.0)
    set_entvar(ent, var_sequence, Anim)
    if(ResetFrame) set_entvar(ent, var_frame, 0.0)
}

public Write_new_Coordinates(){
    new mapname[32], filepath[100]
    get_mapname(mapname, charsmax(mapname))
    formatex(filepath, charsmax(filepath), "maps/%s.sctf.cfg", mapname)

    if (file_exists(filepath))
        delete_file(filepath)

    new szBuffer[150]

    formatex(szBuffer, charsmax(szBuffer), "-->TEX = %.0f^n-->TEY = %.0f^n-->TEZ = %.0f^n-->CTX = %.0f^n-->CTY = %.0f^n-->CTZ = %.0f^n",coordinates[NEW_COOR_TEBASE][0],coordinates[NEW_COOR_TEBASE][1],coordinates[NEW_COOR_TEBASE][2],coordinates[NEW_COOR_CTBASE][0],coordinates[NEW_COOR_CTBASE][1],coordinates[NEW_COOR_CTBASE][2])
    write_file(filepath,szBuffer)
}
But I don't want to use this module.
 
Сообщения
109
Реакции
79
Помог
1 раз(а)
Sonyx, I wasn't knowing. Thank you, I added.
 
Сообщения
109
Реакции
79
Помог
1 раз(а)
I did it. If thoucher is 0, Entity's movetype changes to MOVETYPE_NONE.
Форматирование (BB-код):
public touch_entity(enti, id){
    if(id == 0)
        entity_set_int(enti,EV_INT_movetype,MOVETYPE_NONE)
        
    if(!is_entity(enti))
        return
Thanks everyone.
 

Пользователи, просматривающие эту тему

Сейчас на форуме нет ни одного пользователя.
Сверху Снизу