Manager quix Posted March 16, 2023 Manager Share Posted March 16, 2023 In this topic, I'll post some codes I'll create for you to understand how this language works. (NOTE: These codes might not work as intended and might need some changes!) 1. This plugin will allow players to initiate a duel with one another using the "/duel" command. They can choose from four different weapons: knife, deagle, AK47, and AWP. If a player does not specify a target for the duel, the duel will be initiated with themselves. The plugin will then teleport the players to a platform where they can fight with their chosen weapon. The platform is located 128 units away from each player, and each player is facing the other. The plugin also disables rendering for the players, which makes them invisible to other players during the duel. #include < amxmodx > #include < amxmisc > new const DuelWeapon[][32] = { "Knife", "Deagle", "AK47", "AWP" }; public plugin_init() { register_plugin("Duel Plugin", "1.0", "Your Name"); register_clcmd("duel", "Start a duel", "duel <weapon> <player>", 1); } public client_cmd(id, cmd[]) { if(!equali(cmd, "duel", strlen(cmd))) { return PLUGIN_CONTINUE; } new weapon, target; if(sscanf(get_arg(1, cmd), "%d", weapon) != 1) { return PLUGIN_CONTINUE; } if(sscanf(get_arg(2, cmd), "%d", target) != 1) { target = id; } new weaponName[32]; format(weaponName, sizeof(weaponName), "Duel with %s", DuelWeapon[weapon]); new Float:origin1[3], origin2[3]; get_user_origin(id, origin1); get_user_origin(target, origin2); origin1[2] += 64.0; origin2[2] += 64.0; new Float:angles1[3], angles2[3]; get_user_angles(id, angles1); get_user_angles(target, angles2); new Float:forward1[3], forward2[3], right1[3], right2[3], up1[3], up2[3]; angle_vectors(angles1, forward1, right1, up1); angle_vectors(angles2, forward2, right2, up2); new Float:distance = 128.0; new Float:offset1[3], offset2[3]; vector_scale(forward1, -distance, offset1); vector_scale(forward2, distance, offset2); new Float:final1[3], final2[3]; vector_add(origin1, offset1, final1); vector_add(origin2, offset2, final2); teleport(id, final1, angles1); teleport(target, final2, angles2); set_user_rendering(id, kRenderFxNone, 0); set_user_rendering(target, kRenderFxNone, 0); message_begin(MSG_ONE, get_user_msgid(id, 1), _, id); write_byte(6); write_byte(0); write_short(1); message_end(); message_begin(MSG_ONE, get_user_msgid(target, 1), _, target); write_byte(6); write_byte(0); write_short(1); message_end(); } public plugin_end() { unregister_clcmd("duel"); } : adelinrzo : quiixx. : raizo (24.01.2023) (12.03.2023) (30.03.2023) Link to comment Share on other sites More sharing options...
Manager quix Posted March 16, 2023 Author Manager Share Posted March 16, 2023 2. The plugin is called "Super Powers Plugin" and it provides players with four different powers they can use during the game. Here are the four powers: Teleport: Allows players to teleport to a different location on the map. Invisibility: Makes players invisible to other players for a certain period of time. Super Speed: Makes players move faster than normal for a certain period of time. Fireball: Allows players to shoot a fireball at their enemies, causing damage. This plugin will allow players to use their super powers during the game by typing "/powers" #include < amxmodx > #include < amxmisc > enum SuperPower { TELEPORT = 1, INVISIBILITY, SUPER_SPEED, FIREBALL }; public plugin_init() { register_plugin("Super Powers Plugin", "1.0", "Your Name"); register_clcmd("powers", "Use your super powers", "powers <power>", 1); } public client_cmd(id, cmd[]) { if(!equali(cmd, "powers", strlen(cmd))) { return PLUGIN_CONTINUE; } new power; if(sscanf(get_arg(1, cmd), "%d", power) != 1) { return PLUGIN_CONTINUE; } switch(power) { case TELEPORT: teleport_power(id); break; case INVISIBILITY: invisibility_power(id); break; case SUPER_SPEED: super_speed_power(id); break; case FIREBALL: fireball_power(id); break; default: break; } } public teleport_power(id) { new Float:origin[3]; get_user_origin(id, origin); origin[0] += random_num(-200, 200); origin[1] += random_num(-200, 200); origin[2] += 64.0; set_user_origin(id, origin); } public invisibility_power(id) { set_user_rendering(id, kRenderFxNone, 0); set_task(10.0, "reset_rendering", id); } public reset_rendering(id) { set_user_rendering(id, kRenderFxNone, 1); } public super_speed_power(id) { set_user_maxspeed(id, 400); set_task(10.0, "reset_maxspeed", id); } public reset_maxspeed(id) { set_user_maxspeed(id, 320); } public fireball_power(id) { new Float:angles[3], forward[3], end[3], traceline[3]; get_user_angles(id, angles); angle_vectors(angles, forward, _, _); vector_scale(forward, 8192.0, end); vector_add(end, get_user_origin(id), end); trace_line(get_user_origin(id), end, ignore_monsters, id, traceline); new entity = create_entity("env_explosion"); set_entity_origin(entity, traceline); set_entity_model(entity, "sprites/explode.spr"); set_entity_scale(entity, 1.0, 1.0, 1.0); set_entity_rendering(entity, kRenderFxNone, 0); set_task(0.5, "remove_entity", entity); } public remove_entity(entity) { remove_entity(entity); } public plugin_end() { unregister_clcmd("powers"); } : adelinrzo : quiixx. : raizo (24.01.2023) (12.03.2023) (30.03.2023) Link to comment Share on other sites More sharing options...
Manager quix Posted March 16, 2023 Author Manager Share Posted March 16, 2023 3. This plugin will allow players to use grappling hooks during the game by typing "/grapple". When they use the grappling hook, it will shoot out a beam in the direction they are facing and pull them towards it, allowing them to move quickly and traverse the map in a unique way. #include < amxmodx > #include < amxmisc > public plugin_init() { register_plugin("Grappling Hook Plugin", "1.0", "Your Name"); register_clcmd("grapple", "Use your grappling hook", "grapple", 0); } public client_cmd(id, cmd[]) { if(!equali(cmd, "grapple", strlen(cmd))) { return PLUGIN_CONTINUE; } new Float:angles[3], forward[3], end[3], traceline[3]; get_user_angles(id, angles); angle_vectors(angles, forward, _, _); vector_scale(forward, 8192.0, end); vector_add(end, get_user_origin(id), end); trace_line(get_user_origin(id), end, ignore_monsters, id, traceline); if(traceline[0] == 1.0 && traceline[1] == 0.0 && traceline[2] == 0.0) { return PLUGIN_CONTINUE; } new entity = create_entity("env_beam"); set_entity_origin(entity, get_user_origin(id)); set_entity_destination(entity, traceline); set_entity_model(entity, "sprites/laserbeam.spr"); set_entity_rendering(entity, kRenderFxNone, 0); set_task(0.5, "remove_entity", entity); new Float:velocity[3]; vector_subtract(traceline, get_user_origin(id), velocity); vector_normalize(velocity, velocity); vector_scale(velocity, 1000.0, velocity); set_user_origin(id, traceline); set_user_velocity(id, velocity); } public remove_entity(entity) { remove_entity(entity); } public plugin_end() { unregister_clcmd("grapple"); } : adelinrzo : quiixx. : raizo (24.01.2023) (12.03.2023) (30.03.2023) Link to comment Share on other sites More sharing options...
Manager quix Posted March 17, 2023 Author Manager Share Posted March 17, 2023 4. Zombie Survival and Escape Plugin (UNFINISHED) : #include < amxmodx > #include < amxmisc > #include < hamsandwich > const MAX_PLAYERS = 32; const ZOMBIE_MODEL = "models/player/zombie/zombie.mdl"; const ZOMBIE_HEALTH = 250.0; const ZOMBIE_DAMAGE = 50.0; const ZOMBIE_SPEED = 100.0; const ZOMBIE_KNOCKBACK = 150.0; new zombie_spawn_points[32][3]; new current_wave; new current_wave_time; new current_wave_end_time; new zombie_count; new zombie_killed_count; public plugin_init() { register_plugin("Zombie Survival", "1.0", "Your Name"); register_concmd("zs_start", "Start a new game of Zombie Survival", "zs_start", FCVAR_SERVER); register_event("HLTV", "HLTVStarted", "a", "0"); register_event("HLTV", "HLTVStopped", "a", "0"); register_event("Weapon_Headshot", "weapon_headshot", "a", "1=attacker"); register_event("Player_Killed", "player_killed", "a", "2=victim,1=attacker"); set_task(1.0, "check_wave_end"); set_task(1.0, "check_wave_start"); } public client_cmd(id, cmd[]) { if(!equali(cmd, "zs_start", strlen(cmd))) { return PLUGIN_CONTINUE; } start_game(); } public start_game() { current_wave = 0; current_wave_time = 0.0; current_wave_end_time = 0.0; zombie_count = 0; zombie_killed_count = 0; for(new i = 1; i <= MAX_PLAYERS; i++) { if(is_user_connected(i) && get_user_team(i) == CS_TEAM_T) { zombie_spawn_points[zombie_count][0] = get_user_origin(i)[0]; zombie_spawn_points[zombie_count][1] = get_user_origin(i)[1]; zombie_spawn_points[zombie_count][2] = get_user_origin(i)[2]; zombie_count++; } } client_print(null, print_chat, "A new game of Zombie Survival has begun!"); start_wave(); } public start_wave() { current_wave++; current_wave_time = 0.0; current_wave_end_time = get_gametime() + 60.0; client_print(null, print_chat, "Wave %d has begun!", current_wave); for(new i = 0; i < zombie_count * current_wave; i++) { new zombie = create_zombie(zombie_spawn_points[random_num(0, zombie_count)][0], zombie_spawn_points[random_num(0, zombie_count)][1], zombie_spawn_points[random_num(0, zombie_count)][2]); give_zombie_weapon(zombie); } } public end_wave() { client_print(null, print_chat, "Wave %d has ended!", current_wave); zombie_killed_count = 0; current_wave_time = 0.0; current_wave_end_time = 0.0; if(current_wave == 10) { end_game(); } else { start_wave(); } } public end_game() { client_print(null, print_chat, "The game of Zombie Survival has ended!"); current_wave = 0; current_wave_time = 0.0; current_wave_end_time = 0.0; zombie_count = 0; zombie_killed_count = 0; for(new i = 1; i <= MAX_PLAYERS; i++) { if(is_user_connected(i)) { set_user_team(i, CS_TEAM_T); set_user_model(i, ZOMBIE_MODEL); set_user_health(i, ZOMBIE_HEALTH); set_user_maxspeed(i, ZOMBIE_SPEED); set_user_knockback_scale(i, ZOMBIE_KNOCKBACK); strip_user_weapons(i); give_item(i, "weapon_knife"); } } start_wave(); } public check_wave_start() { if(current_wave_end_time > 0.0 && get_gametime() >= current_wave_end_time) { end_wave(); } new seconds_remaining = (current_wave_end_time - get_gametime()) % 60; if(current_wave_end_time > 0.0 && seconds_remaining == 30) { client_print(null, print_chat, "Wave %d will end in 30 seconds!", current_wave); } set_task(1.0, "check_wave_start"); } public check_wave_end() { for(new i = 1; i <= MAX_PLAYERS; i++) { if(is_user_connected(i) && get_user_team(i) == CS_TEAM_CT && get_user_health(i) > 0) { return; } } end_wave(); } public create_zombie(Float:x, Float:y, Float:z) { new zombie = create_player(ZOMBIE_MODEL, "255 255 255"); set_entity_origin(zombie, Float:x, Float:y, Float:z); set_entity_prop(zombie, Prop_Data, "m_flHealth", ZOMBIE_HEALTH); set_entity_prop(zombie, Prop_Data, "m_flMaxspeed", ZOMBIE_SPEED); set_entity_prop(zombie, Prop_Data, "m_flKnockbackScale", ZOMBIE_KNOCKBACK); set_task(0.1, "zombie_ai", zombie); return zombie; } public zombie_ai(zombie) { if(!is_valid_entity(zombie)) { return; } new enemy = find_nearest_player(zombie); if(is_valid_entity(enemy)) { aim_entity(zombie, enemy, 0.1); shoot_entity(zombie); } set_task(0.1, "zombie_ai", zombie); } public give_zombie_weapon(zombie) { new weapon_names[] = {"weapon_m4a1", "weapon_ak47", "weapon_aug", "weapon_sg552", "weapon_g3sg1", "weapon_awp", "weapon_deagle", "weapon_p228", "weapon_elite", "weapon_fiveseven"}; new weapon = weapon_names[random_num(0, sizeof(weapon_names) - 1)]; give_item(zombie, weapon); } public find_nearest_player(entity) { new Float:origin[3], Float:nearest_origin[3]; get_entity_origin(entity, origin); new nearest_distance = 999999.0, nearest_player = -1; for(new i = 1; i <= MAX_PLAYERS; i++) { if(is_user_connected(i) && get_user_team(i) == CS_TEAM_CT && get_user_health(i) > 0) { get_user_origin(i, nearest_origin); new distance = get_distance_3d (origin[0], origin[1], origin[2], nearest_origin[0], nearest_origin[1], nearest_origin[2]); if(distance < nearest_distance) { nearest_distance = distance; nearest_player = i; } } } return nearest_player; } public wave_start() { current_wave++; current_wave_time = get_gametime(); current_wave_end_time = current_wave_time + (WAVE_DURATION * 60.0); zombie_count = ZOMBIE_COUNT_BASE + (current_wave - 1) * ZOMBIE_COUNT_INCREMENT; zombie_killed_count = 0; for(new i = 1; i <= zombie_count; i++) { new x = ZOMBIE_SPAWN_X + random_num(-ZOMBIE_SPAWN_OFFSET, ZOMBIE_SPAWN_OFFSET); new y = ZOMBIE_SPAWN_Y + random_num(-ZOMBIE_SPAWN_OFFSET, ZOMBIE_SPAWN_OFFSET); new z = ZOMBIE_SPAWN_Z; create_zombie(x, y, z); } client_print(null, print_chat, "Wave %d started! %d zombies incoming!", current_wave, zombie_count); set_task(1.0, "check_wave_start"); } public wave_end() { for(new i = 1; i <= MAX_PLAYERS; i++) { if(is_user_connected(i) && get_user_team(i) == CS_TEAM_T && get_user_health(i) > 0) { kill_entity(i); } } client_print(null, print_chat, "Wave %d ended! You killed %d out of %d zombies!", current_wave, zombie_killed_count, zombie_count); if(current_wave < MAX_WAVES) { start_wave(); } else { end_game(); } } public end_wave() { set_task(1.0, "check_wave_end"); } public end_game() { client_print(null, print_chat, "Game over! You survived all waves!"); zombie_escape_end(); } } public client_spawn(id) { set_user_team(id, CS_TEAM_T); set_user_health(id, PLAYER_HEALTH); set_user_armor(id, PLAYER_ARMOR); give_item(id, "weapon_knife"); give_item(id, "weapon_deagle"); give_item(id, "weapon_ak47"); give_item(id, "weapon_awp"); } public check_wave_start() { new time_left = current_wave_end_time - get_gametime(); if(time_left <= 0) { end_wave(); return; } if(zombie_killed_count == zombie_count) { end_wave(); return; } if(get_num_alive_players(CS_TEAM_T) == 0) { end_wave(); return; } if(time_left == WAVE_DURATION * 60.0 * 0.5) { client_print(null, print_chat, "Half time! You have %d minutes left to finish the wave!", WAVE_DURATION * 0.5); } set_task(1.0, "check_wave_start"); } public check_wave_end() { if(get_num_alive_players(CS_TEAM_T) == 0) { wave_end(); return; } if(zombie_killed_count == zombie_count) { wave_end(); return; } if(current_wave_end_time - get_gametime() <= 0) { wave_end(); return; } set_task(1.0, "check_wave_end"); } public zombie_killed() { zombie_killed_count++; if(zombie_killed_count == zombie_count) { client_print(null, print_chat, "All zombies killed! Finish the wave!"); } } public zombie_escape_start() { current_wave = 0; zombie_count = ZOMBIE_COUNT_ESCAPE; zombie_killed_count = 0; for(new i = 1; i <= zombie_count; i++) { new x = ZOMBIE_SPAWN_X + random_num(-ZOMBIE_SPAWN_OFFSET, ZOMBIE_SPAWN_OFFSET); new y = ZOMBIE_SPAWN_Y + random_num(-ZOMBIE_SPAWN_OFFSET, ZOMBIE_SPAWN_OFFSET); new z = ZOMBIE_SPAWN_Z; create_zombie(x, y, z); } client_print(null, print_chat, "Zombie escape mode started! %d zombies incoming!", zombie_count); set_task(1.0, "check_escape_start"); } public zombie_escape_end() { for(new i = 1; i <= MAX_PLAYERS; i++) { if(is_user_connected(i) && get_user_team(i) == CS_TEAM_T && get_user_health(i) > 0) { kill_entity(i); } } client_print(null, print_chat, "Zombie escape mode ended! You killed %d out of %d zombies!", zombie_killed_count, zombie_count); } public check_escape_start() { if(zombie_killed_count == zombie_count) { zombie_escape_end(); return; } if(get_num_alive_players(CS_TEAM_T) == 0) { zombie_escape_end(); return; } set_task(1.0, "check_escape_start"); } : adelinrzo : quiixx. : raizo (24.01.2023) (12.03.2023) (30.03.2023) Link to comment Share on other sites More sharing options...
testchesti Posted June 7 Share Posted June 7 better to unpin topic, all of the posted codes are wrong..don t trust so much gpt Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now