Entity MOVETYPE_NOCLIP lin/win

Сообщения
109
Реакции
79
Помог
1 раз(а)
There is a problem about MOVETYPE_NOCLIP between linux and windows. When I test with windows, Entity falls from ground. But when I test with linux, entity stops on ground. Entity's gravity 0.0. I took a video about this.


Windows;
Форматирование (BB-код):
version
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.6.0.672-dev
Build date: 17:31:06 Jun  5 2019 (1880)
Build from: https://github.com/dreamstalker/rehlds/commit/0c8d3d7
game version
ReGameDLL version: 5.9.0.345-dev
Build date: 21:35:47 Jun  5 2019
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/f731fbf
meta list
Currently loaded plugins:
      description   stat pend  file                  vers            src  load  unload
 [ 1] AMX Mod X     RUN   -    amxmodx_mm.dll        v1.9.0.5234     ini  Start ANY
 [ 2] Reunion       RUN   -    reunion_mm.dll        v0.1.0.92       ini  Start Never
 [ 3] FakeMeta      RUN   -    fakemeta_amxx.dll     v1.9.0.5234     pl1  ANY   ANY
 [ 4] Ham Sandwich  RUN   -    hamsandwich_amxx.dll  v1.9.0.5234     pl1  ANY   ANY
 [ 5] CSX           RUN   -    csx_amxx.dll          v1.9.0.5234     pl1  ANY   ANY
 [ 6] ReAPI         RUN   -    reapi_amxx.dll        v5.9.0.167-dev  pl1  ANY   Never
 [ 7] Engine        RUN   -    engine_amxx.dll       v1.9.0.5234     pl1  ANY   ANY
7 plugins, 7 running
Linux;
Форматирование (BB-код):
] rcon version
Protocol version 48
Exe version 1.1.2.7/Stdio (cstrike)
ReHLDS version: 3.6.0.672-dev
Build date: 17:31:06 Jun  5 2019 (1880)
Build from: https://github.com/dreamstalker/rehlds/commit/0c8d3d7

] rcon game version
ReGameDLL version: 5.9.0.349-dev
Build date: 18:29:53 Jun  7 2019
Build from: https://github.com/s1lentq/ReGameDLL_CS/commit/62cb200

] rcon meta list
Currently loaded plugins:
      description      stat pend  file              vers      src   load  unlod
 [ 1] Reunion          RUN   -    reunion_mm_i386.  v0.1.0.1  ini   Start Never
 [ 2] ReAuthCheck      RUN   -    reauthcheck_mm_i  v0.1.6    ini   Start Never
 [ 3] CSDuragiRe AMX   RUN   -    amxmodx_mm_i386.  v1.8.3-d  ini   Start ANY  
 [ 4] Rechecker        RUN   -    rechecker_mm_i38  v2.5      ini   Chlvl ANY  
 [ 5] Revoice          RUN   -    revoice_mm_i386.  v0.1.0.3  ini   Start Never
 [ 6] WHBlocker        RUN   -    whblocker_mm_i38  v1.5.690  ini   Chlvl ANY  
 [ 7] ReSemiclip       RUN   -    resemiclip_mm_i3  v2.3.9    ini   Chlvl ANY  
 [ 8] ReSRDetector     RUN   -    srdetector_mm_i3  v0.1.0    ini   Chlvl ANY  
 [ 9] SQLite           RUN   -    sqlite_amxx_i386  v1.8.3-d  pl3   ANY   ANY  
 [10] Fun              RUN   -    fun_amxx_i386.so  v1.8.3-d  pl3   ANY   ANY  
 [11] Engine           RUN   -    engine_amxx_i386  v1.8.3-d  pl3   ANY   ANY  
 [12] FakeMeta         RUN   -    fakemeta_amxx_i3  v1.8.3-d  pl3   ANY   ANY  
 [13] CStrike          RUN   -    cstrike_amxx_i38  v1.8.3-d  pl3   ANY   ANY  
 [14] CSX              RUN   -    csx_amxx_i386.so  v1.8.3-d  pl3   ANY   ANY  
 [15] Ham Sandwich     RUN   -    hamsandwich_amxx  v1.8.3-d  pl3   ANY   ANY  
 [16] ReAPI            RUN   -    reapi_amxx_i386.  v5.9.0.1  pl3   ANY   Never

 [17] ReAimDetector    RUN   -    reaimdetector_am  v0.1.7    pl3   ANY   Never
 [18] ReCSDM           RUN   -    csdm_amxx_i386.s  v3.6      pl3
Entity sma;
the important ones CREATE_ENTITY and RG_PlayerKilled
Форматирование (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.0"
#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,
    maxplayer
}

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)

    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)
    int_values[maxplayer] = get_member_game(m_nMaxPlayers)
}
public plugin_precache()
{
    formatex(BKMODEL,charsmax(BKMODEL),"models/simple_ctf/simple_ctf.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(int_values[maxplayer], "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(int_values[maxplayer], "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){
        entity_set_int(int_values[ent_TEFlag],EV_INT_movetype,MOVETYPE_NOCLIP)
        set_entvar(int_values[ent_TEFlag],var_aiment,0)
        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){
        entity_set_int(int_values[ent_CTFlag],EV_INT_movetype,MOVETYPE_NOCLIP)
        set_entvar(int_values[ent_CTFlag],var_aiment,0)
        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_TOSS)
    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_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")
    SetTouch(int_values[ent_CTFlagBase], "touch_entity");
//---------------------------------------------------------------
    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")
    SetTouch(int_values[ent_TEFlagBase], "touch_entity");
//---------------------------------------------------------------
    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, 0.0)
    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,  120.46})
    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)
    SetTouch(int_values[ent_CTFlag], "touch_entity");
//---------------------------------------------------------------
    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, 0.0)
    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,  120.46})
    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)
    SetTouch(int_values[ent_TEFlag], "touch_entity");
}

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)
}
What I do for windows?
 

Вложения

Сообщения
1,701
Реакции
1,512
Помог
26 раз(а)
Сообщения
109
Реакции
79
Помог
1 раз(а)
If I use FLY, entity is disappearing between door.
And is getting max player wrong?
I use get_user_team, So I use 1/2
formatex ?
 
Сообщения
141
Реакции
201
Помог
5 раз(а)
> Set Entity movetype to noclip
> Entity has no collision with other entities
> Entity moves through the ground
sohWhy9.jpg.png
 
Сообщения
1,701
Реакции
1,512
Помог
26 раз(а)
If I use FLY, entity is disappearing between door.
So sad )0))

And is getting max player wrong?
amxconst.inc
Код:
/**
* Maximum number of players the server supports
*/
public stock const MaxClients;

I use get_user_team, So I use 1/2
cssdk_const.inc (ReAPI)
Код:
/**
* Team IDs for m_iTeam
*/
enum TeamName
{
    TEAM_UNASSIGNED,
    TEAM_TERRORIST,
    TEAM_CT,
    TEAM_SPECTATOR
};

just
var = "foo";
 
Последнее редактирование модератором:

Garey

ninjaCow
Сообщения
440
Реакции
1,094
Помог
11 раз(а)
Yek'-ta, i said you in previous thread you can use MOVETYPE_TOSS and correct mins/maxs :E and entity will not dissapear
 
Сообщения
1,701
Реакции
1,512
Помог
26 раз(а)
Yek'-ta, but you must use from your mind.
 
Сообщения
109
Реакции
79
Помог
1 раз(а)
fl0wer, therefore I used MOVETYPE_NOCLIP. And it was nice. Thanks.
Форматирование (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.1"
#define AUTHOR  "Yek'-ta"

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

#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)

    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()
{
    BKMODEL = "models/simple_ctf/sctf_newflag.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(MaxClients, "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(MaxClients, "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){
        entity_set_int(int_values[ent_TEFlag],EV_INT_movetype,MOVETYPE_NOCLIP)
        set_entvar(int_values[ent_TEFlag],var_aiment,0)
        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){
        entity_set_int(int_values[ent_CTFlag],EV_INT_movetype,MOVETYPE_NOCLIP)
        set_entvar(int_values[ent_CTFlag],var_aiment,0)
        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_TOSS)
    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_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_member(id, m_iTeam) == TEAM_TERRORIST && 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_member(id, m_iTeam) == 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[2]
        new TeamName:casual_ent_team
        if(int_values[ent_TEFlag] == enti){
            casual_ent[0] = int_values[ent_TEFlag]
            casual_ent_team = TEAM_TERRORIST
            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_team = TEAM_CT
            casual_ent[1] = 1
            //client_print_color(id, id, "^3CT Bayragina dokundun.") // You did touch the CT flag
        }


        if(get_member(id, m_iTeam) == casual_ent_team){
            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_member(id, m_iTeam) == TEAM_TERRORIST){
                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")
    SetTouch(int_values[ent_CTFlagBase], "touch_entity");
//---------------------------------------------------------------
    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")
    SetTouch(int_values[ent_TEFlagBase], "touch_entity");
//---------------------------------------------------------------
    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, 0.0)
    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,  120.46})
    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, TEAM_CT)
    SetTouch(int_values[ent_CTFlag], "touch_entity");
//---------------------------------------------------------------
    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, 0.0)
    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,  120.46})
    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, TEAM_TERRORIST)
    SetTouch(int_values[ent_TEFlag], "touch_entity");
}

public CREATE_NEW_FLAG(TeamName: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_TERRORIST)

            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)
}
 

Ayk

Сообщения
763
Реакции
478
Помог
19 раз(а)
Yek'-ta, so, what did you change? Show us only the differences.
 

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

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