-
Posts
562 -
Joined
-
Last visited
-
Days Won
64
Posts posted by quix
-
-
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"); }
-
Still updated and working!
-
10. This mod contains a cutscene that is triggered when the F7 key is pressed. During the cutscene, the camera and player are moved to specific locations, models are loaded, and text is displayed on the screen. Once the cutscene is complete, control is returned to the player.
{$CLEO .cs} // Cutscene script thread 'CUTSCENE' wait 500 fade 0 500 wait 500 camera -2054.0127, -22.6369, 35.0938, 0.0, 0.0, 0.0 wait 500 set_player_control 0 0 wait 1000 0173: actor $PLAYER_ACTOR walk_to -2057.3604, -22.1419, 35.1641 wait 3000 038B: load_requested_models wait 1000 01C2: remove_references_to_actor $PLAYER_ACTOR 03E6: remove_text_box 01E3: show_text_1number_highpriority "Cutscene complete!" time 5000 flag 1 // Display text for 5 seconds fade 1 500 wait 500 camera -2065.6746, -29.5839, 35.2422, 0.0, 0.0, 0.0 wait 500 set_player_control 1 1 end_thread // Main script thread 'MAIN' repeat wait 0 until 00E1: player 0 pressed_key 18 // F7 key // Start the cutscene when the F7 key is pressed gosub 'CUTSCENE' end_thread
-
-
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"); }
-
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"); }
-
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"); }
-
3. This script allows players to use the "/holdhands" command to hold hands with another nearby player. When a player types the command, the script checks for nearby players within a certain distance and stores the ID and position of the target player
new PlayerData[MAX_PLAYERS][3]; // Store hand-holding data for each player const HOLD_DISTANCE = 2.0; // Maximum distance between players to hold hands public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp(cmdtext, "/holdhands", true)) { new Float:playerPos[3], Float:targetPos[3]; GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]); // Check nearby players for hand-holding eligibility for(new targetid = 0; targetid < MAX_PLAYERS; targetid++) { if(IsPlayerConnected(targetid) && targetid != playerid) { GetPlayerPos(targetid, targetPos[0], targetPos[1], targetPos[2]); if(GetDistanceBetweenPoints3D(playerPos[0], playerPos[1], playerPos[2], targetPos[0], targetPos[1], targetPos[2]) <= HOLD_DISTANCE) { // Store hand-holding data for both players PlayerData[playerid][0] = targetid; // Target player ID PlayerData[playerid][1] = targetPos[0]; // Target player X position PlayerData[playerid][2] = targetPos[1]; // Target player Y position SendClientMessage(playerid, -1, "You are now holding hands with " + GetPlayerName(targetid) + "."); SendClientMessage(targetid, -1, GetPlayerName(playerid) + " is now holding hands with you."); break; } } } return 1; } return 0; } public OnPlayerDisconnect(playerid, reason) { // Remove hand-holding data for disconnected player PlayerData[playerid][0] = INVALID_PLAYER_ID; PlayerData[playerid][1] = 0.0; PlayerData[playerid][2] = 0.0; return 1; } public OnPlayerUpdate(playerid) { // Check if player is holding hands with another player if(PlayerData[playerid][0] != INVALID_PLAYER_ID) { new Float:playerPos[3], Float:targetPos[3]; GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]); targetPos[0] = PlayerData[playerid][1]; targetPos[1] = PlayerData[playerid][2]; targetPos[2] = playerPos[2]; // Maintain same Z position // Teleport player towards target player to maintain hand-holding distance if(GetDistanceBetweenPoints3D(playerPos[0], playerPos[1], playerPos[2], targetPos[0], targetPos[1], targetPos[2]) > HOLD_DISTANCE) { new Float:direction = atan2(targetPos[1] - playerPos[1], targetPos[0] - playerPos[0]); playerPos[0] += HOLD_DISTANCE * cos(direction); playerPos[1] += HOLD_DISTANCE * sin(direction); SetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]); } } return 1; }
-
2. This script creates a text-draw in the top-left corner of the screen with a gradient color, and uses an AI library to respond to player input. When a player types something in the chat, the OnPlayerText function is called and uses the AI_ProcessInput function from the AI library to generate a response. The response is then sent back to the player as a chat message with the prefix "AI:". When a player connects or disconnects, the OnPlayerConnect and OnPlayerDisconnect functions are called, respectively, and show or hide the text-draw accordingly. Finally, when the game mode is unloaded, the OnGameModeExit function is called and destroys the text-draw and frees the AI library resources.
#include <a_samp> #include <AI.inc> new TextDraw:gTextDraw; public OnGameModeInit() { // Create a text-draw with a gradient color gTextDraw = TextDrawCreate(100.0, 100.0, "Hello, world!"); TextDrawLetterSize(gTextDraw, 0.5, 1.0); TextDrawTextSize(gTextDraw, 100.0, 10.0); TextDrawAlignment(gTextDraw, 1); TextDrawColor(gTextDraw, 0xFFFFAAFF); TextDrawUseBox(gTextDraw, true); TextDrawBoxColor(gTextDraw, 0x000000FF); TextDrawBackgroundColor(gTextDraw, 0x00000088); TextDrawFont(gTextDraw, 2); TextDrawSetProportional(gTextDraw, true); TextDrawSetShadow(gTextDraw, 2); TextDrawSetOutline(gTextDraw, 1); // Initialize the AI library AI_Init(); } public OnPlayerText(playerid, text[]) { // Use the AI library to generate a response to player input new response[MAX_PLAYER_NAME]; AI_ProcessInput(text, response, sizeof(response)); SendClientMessage(playerid, -1, "AI: " + response); return 1; } public OnPlayerConnect(playerid) { // Display the text-draw to the player TextDrawShowForPlayer(gTextDraw, playerid); return 1; } public OnPlayerDisconnect(playerid, reason) { // Hide the text-draw when the player disconnects TextDrawHideForPlayer(gTextDraw, playerid); return 1; } public OnGameModeExit() { // Destroy the text-draw and free the AI library resources TextDrawDestroy(gTextDraw); AI_Free(); return 1; }
-
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. Creates 2 text-draws that shows players connected and a welcoming message:
#include <a_samp> new TextDraw:gWelcome, TextDraw:gPlayerList; main() { gWelcome = TextDrawCreate(10.0, 100.0, "Welcome to My Server"); TextDrawColor(gWelcome, 0xFFFFFFFF); TextDrawBackgroundColor(gWelcome, 0xFF000000); TextDrawLetterSize(gWelcome, 0.5, 1.0); TextDrawAlignment(gWelcome, 2); TextDrawSetOutline(gWelcome, 1); TextDrawSetShadow(gWelcome, 1); gPlayerList = TextDrawCreate(10.0, 150.0, "Players Online:"); TextDrawColor(gPlayerList, 0xFFFFFFFF); TextDrawBackgroundColor(gPlayerList, 0xFF000000); TextDrawLetterSize(gPlayerList, 0.3, 0.5); TextDrawAlignment(gPlayerList, 0); TextDrawSetOutline(gPlayerList, 1); TextDrawSetShadow(gPlayerList, 1); while (true) { // Update player list new playerCount = 0; for (new i = 0; i < MAX_PLAYERS; i++) { if (!IsPlayerConnected(i)) continue; playerCount++; new playerName[MAX_PLAYER_NAME]; GetPlayerName(i, playerName, sizeof(playerName)); TextDrawSetString(gPlayerList, playerCount + ". " + playerName); } // Wait a bit before updating again Sleep(5000); } return 0; } public OnPlayerConnect(playerid) { new message[128]; format(message, sizeof(message), "Player %s has joined the server.", GetPlayerName(playerid)); SendClientMessageToAll(0xFFFFFFAA, message); return 1; } public OnPlayerDisconnect(playerid, reason) { new message[128]; format(message, sizeof(message), "Player %s has left the server. Reason: %d", GetPlayerName(playerid), reason); SendClientMessageToAll(0xFFFFFFAA, message); return 1; }
-
9. Creates a custom Loading Screen with a loading bar:
Note: In order to use this script, you would need to create a PNG file named "LOADBAR.png" in the "CLEO" folder of your GTA San Andreas installation, which will be used as the progress bar.
// Display loading text 0AFA: text_draw 1 position 320.0 200.0 GXT 'LOADING' color 2 flag 1 center 1 scale 2.0 // Define variables 0AB1: var 1@ = 0 // Current progress 0AB1: var 2@ = 0 // Total progress // Loop until loading is complete :LOADING_LOOP // Check if loading is complete 00D6: if or 0AB0: var 1@ >= var 2@ jf @LOADING_LOOP // Display progress bar 0AFA: text_draw 2 position 320.0 230.0 width 400.0 height 20.0 color 1 flag 0 center 1 0AFB: draw_texture "LOADBAR" position 160.0 226.0 size 210.0 30.0 RGBA 255 255 255 255 // Update progress 0AB1: var 1@ += 1 // Delay for a moment 0A8D: wait 0 // Jump back to loading loop jmp @LOADING_LOOP // Loading is complete, remove loading screen 0AFB: draw_texture -1 0AFA: text_draw -1
-
8. Creates a new cool mission : "The Great Heist" (unfinished)
{$CLEO} // Constants const MISSION_NAME = 'The Great Heist'; MISSION_BLIP = 10; MISSION_MARKER = 22; MISSION_OBJECTIVE_TEXT = 'Steal the diamonds from the jewelry store.'; // Variables var mission_started: boolean; mission_completed: boolean; mission_marker: integer; mission_blip: integer; jewelry_store: integer; diamond: integer; // Main function thread 'NewMission' while true wait 0 // Start the mission if not mission_started then // Create a blip and a marker for the mission mission_blip := create_icon_marker_and_sphere(2, 1177.0, -1324.0, 13.6) mission_marker := create_marker_and_sphere(22, 1177.0, -1324.0, 13.6) // Load the jewelry store interior load_requested_models() jewelry_store := load_interior(7) // Create the diamond object diamond := create_object(1262, 1175.0, -1325.0, 13.6) // Set the mission objective text set_text_box(MISSION_OBJECTIVE_TEXT) // Set mission flag to true mission_started := true end // Check if the player is at the mission marker if mission_started and not mission_completed and is_player_within_radius_of_point_3d(1.5, 1177.0, -1324.0, 13.6) then // Remove the mission blip and marker delete_icon_marker_and_sphere(mission_blip) delete_marker_and_sphere(mission_marker) // Set the player's objective to steal the diamonds set_text_box('Steal the diamonds from the jewelry store.') // Play a cutscene of the player breaking into the jewelry store player_can_move(false) set_interior_rendering_disabled(true) set_widescreen(true) camera_behind_player() fade(500, 1) set_player_position(1169.0, -1374.0, 13.5) set_player_interior(jewelry_store) set_camera_position(1172.0, -1335.0, 16.0) set_camera_point_at_position(1177.0, -1324.0, 13.6, 2) fade(500, 0) wait(1000) player_can_move(true) set_interior_rendering_disabled(false) set_widescreen(false) // Spawn the diamond in the jewelry store set_object_coordinates(diamond, 1172.0, -1335.0, 13.6) set_object_interior(diamond, jewelry_store) set_object_visible(diamond, true) end // Check if the player has picked up the diamond if mission_started and not mission_completed and is_player_near_object_on_foot(diamond, 1.5) then // Remove the diamond object destroy_object(diamond) // Set the player's objective to escape with the diamonds set_text_box('Escape with the diamonds!') // Spawn a helicopter for the player to escape with create_actor(16, 487, 1185.0, -1335.0, 14.0)
-
7. This code will replace cheat codes "BAGUVIX" with "INFHEALTH" and "AEZAKMI" with "NOPOLICE".
{$CLEO} // Constants const CHEAT_INFHEALTH = 'INFHEALTH'; CHEAT_NOPOLICE = 'NOPOLICE'; // Variables var cheat1: string; cheat2: string; // Main function thread 'ReplaceCheats' while true wait 0 // Get the currently entered cheats cheat1 := read_memory_string(0xB73490, 8, false) cheat2 := read_memory_string(0xB734A0, 8, false) // Replace BAGUVIX with INFHEALTH if cheat1 = 'BAGUVIX' then write_memory_string(0xB73490, CHEAT_INFHEALTH, 10, false) end // Replace AEZAKMI with NOPOLICE if cheat2 = 'AEZAKMI' then write_memory_string(0xB734A0, CHEAT_NOPOLICE, 9, false) end end
-
6. Cool script: Creates a hot air balloon that starts flying, after you exit the balloon you get a cutscene and a parachute to land safely. Keybind for activation : F10
{$CLEO .cs} // Key codes const KEY_F10 = 121; // F10 key code // Mission variables var blip_marker: MarkerID; car: CarID; // Script entry point thread 'CoolScript' while true wait 0 if is_key_pressed(KEY_F10) then // Show message and play sound effect show_text_highpriority("Welcome to the cool script!", 5000, 1) audio_play_sound_frontend(0x11D, "FRONTEND_BEAST_MENU_SOUNDSET") // Spawn a hot air balloon and attach a marker to it balloon = create_object(17268, 2495.0, -1669.0, 12.0) blip_marker = create_marker_above_object(balloon) set_marker_color(blip_marker, 1) set_marker_size(blip_marker, 3) // Teleport player to the hot air balloon and start flying set_char_coordinates($PLAYER_CHAR, 2495.0, -1669.0, 15.0) set_char_z_angle($PLAYER_CHAR, 0.0) wait 2000 set_char_proof_cars($PLAYER_CHAR, true) set_char_proof_fire($PLAYER_CHAR, true) set_char_proof_explosions($PLAYER_CHAR, true) car = create_car(424, 2495.0, -1669.0, 50.0) set_car_z_angle(car, 0.0) wait 1000 set_car_color(car, 2, 2) set_car_immunities(car, true, true, true, true, true) attach_object_to_car(balloon, car, 0.0, 0.0, 10.0, 0.0, 0.0, 0.0) set_car_cruise_speed(car, 50.0) // Wait for player to jump out of the hot air balloon while true wait 0 if is_char_in_car($PLAYER_CHAR, car) then if is_key_pressed(32) then // Space key code audio_play_sound_frontend(0x10A, "FRONTEND_DEFAULT_SOUNDSET") set_char_coordinates($PLAYER_CHAR, 2495.0, -1669.0, 12.0) detach_object(balloon) destroy_object(balloon) delete_marker(blip_marker) destroy_car(car) break end_if end_if end_while // Play a cutscene of a helicopter flying away cutscene_start(1) set_camera_position(2467.0, -1467.0, 89.0, 0.0, 0.0, 0.0) set_camera_point_at_position(2507.0, -1667.0, 50.0, 2) wait 1000 cutscene_end() // Display a message and give the player a parachute show_text_highpriority("Use the parachute to land safely!", 5000, 1) give_player_weapon($PLAYER_CHAR, 46, 1) end_if end_while end_thread
-
5. Creates a mission : You get teleported to big smoke's house and you have his skin, and you need to go to CJ's house and kill him, after the mission, you get $3.000.000:
{$CLEO .cs} // Key codes const KEY_F10 = 121; // F10 key code // Checkpoint coordinates const CHECKPOINT_X = 2495.5; CHECKPOINT_Y = -1669.2; CHECKPOINT_Z = 12.5; // Script entry point thread 'BigSmokeMission' while true wait 0 if is_key_pressed(KEY_F10) then // Change player skin to Big Smoke change_player_skin(271) // Teleport player to Big Smoke's house set_char_coordinates($PLAYER_CHAR, 2467.4, -1663.3, 13.3) // Create checkpoint at CJ's house create_checkpoint(0, CHECKPOINT_X, CHECKPOINT_Y, CHECKPOINT_Z) // Wait for player to reach checkpoint while true wait 0 if is_char_in_area_3d($PLAYER_CHAR, CHECKPOINT_X-2.0, CHECKPOINT_Y-2.0, CHECKPOINT_Z-2.0, CHECKPOINT_X+2.0, CHECKPOINT_Y+2.0, CHECKPOINT_Z+2.0, true) then // Spawn enemy ped with CJ's skin and a Deagle enemy_ped = create_ped(26, 0, 0.0, 0.0, 0.0) set_char_coordinates(enemy_ped, 2467.4, -1663.3, 13.3) set_char_weapon(enemy_ped, 24, 9999) set_char_health(enemy_ped, 500) // Wait for enemy ped to die while is_char_alive(enemy_ped) wait 0 end_while // Remove checkpoint and give player money delete_checkpoint(0) give_player_money(3000000) break end_if end_while end_if end_while end_thread
-
4. Creates a menu with 3 options, first one gives you Deagle, second gives you M4 and third gives you Rocket Launcher:
{$CLEO .cs} // Key codes const KEY_F10 = 121; // F10 key code // Menu options const MENU_OPTION_DEAGLE = 0; MENU_OPTION_M4 = 1; MENU_OPTION_ROCKET_LAUNCHER = 2; // Script entry point thread 'WeaponMenu' while true wait 0 if is_key_pressed(KEY_F10) then // Create menu menu('Weapon Menu', 'Deagle', 'M4', 'Rocket Launcher') // Wait for menu selection menu_item_selected = 0 while not menu_item_selected wait 0 if menu_active('Weapon Menu') then menu_item_selected = menu_selected_item() end_if end_while // Give the player the selected weapon if menu_item_selected == MENU_OPTION_DEAGLE then give_weapon_to_char($PLAYER_CHAR, 24, 9999) else_if menu_item_selected == MENU_OPTION_M4 then give_weapon_to_char($PLAYER_CHAR, 31, 9999) else_if menu_item_selected == MENU_OPTION_ROCKET_LAUNCHER then give_weapon_to_char($PLAYER_CHAR, 35, 9999) end_if // Wait for menu to close while menu_active('Weapon Menu') wait 0 end_while end_if end_while end_thread
-
3. Creates a menu containing 4 options: Random Teleport, Teleport to LS, Teleport to SF, Teleport to LV. These are self explanatory (you get teleported to the middle of each city, but the first selection, where you get teleported somewhere random on the map):
{$CLEO .cs} // Key codes const KEY_F10 = 121; // F10 key code // Menu options const MENU_OPTION_RANDOM = 0; MENU_OPTION_LS = 1; MENU_OPTION_SF = 2; MENU_OPTION_LV = 3; // Location coordinates const LS_CENTER_X = 1399.76; LS_CENTER_Y = -1168.98; LS_CENTER_Z = 23.97; SF_CENTER_X = -2352.27; SF_CENTER_Y = 988.43; SF_CENTER_Z = 35.17; LV_CENTER_X = 1705.9; LV_CENTER_Y = 1471.31; LV_CENTER_Z = 10.82; // Script entry point thread 'TeleportMenu' while true wait 0 if is_key_pressed(KEY_F10) then // Create menu menu('Teleport Menu', 'Random Location', 'Middle of LS', 'Middle of SF', 'Middle of LV') // Wait for menu selection menu_item_selected = 0 while not menu_item_selected wait 0 if menu_active('Teleport Menu') then menu_item_selected = menu_selected_item() end_if end_while // Teleport player to selected location if menu_item_selected == MENU_OPTION_RANDOM then random_x = random_float_in_range(-3000.0, 3000.0) random_y = random_float_in_range(-3000.0, 3000.0) teleport($PLAYER_CHAR, random_x, random_y, 0.0) else_if menu_item_selected == MENU_OPTION_LS then teleport($PLAYER_CHAR, LS_CENTER_X, LS_CENTER_Y, LS_CENTER_Z) else_if menu_item_selected == MENU_OPTION_SF then teleport($PLAYER_CHAR, SF_CENTER_X, SF_CENTER_Y, SF_CENTER_Z) else_if menu_item_selected == MENU_OPTION_LV then teleport($PLAYER_CHAR, LV_CENTER_X, LV_CENTER_Y, LV_CENTER_Z) end_if // Wait for menu to close while menu_active('Teleport Menu') wait 0 end_while end_if end_while end_thread
-
2. Transforms you (the player) into Michelle. Also teleports you to her garage and spawns a monster truck after 3 seconds:
{$CLEO .cs} // Key codes const KEY_F4 = 115; // F4 key code // Location coordinates const MICHELLE_GARAGE_X = -1996.37; MICHELLE_GARAGE_Y = 276.6; MICHELLE_GARAGE_Z = 35.17; // Script entry point thread 'MichelleGarageTeleport' while true wait 0 if is_key_pressed(KEY_F4) then // Set player's skin to Michelle (id 191) set_player_skin($PLAYER_CHAR, 191) // Teleport player to Michelle's Garage teleport_with_car($PLAYER_CHAR, MICHELLE_GARAGE_X, MICHELLE_GARAGE_Y, MICHELLE_GARAGE_Z, 90.0, -1) // Wait for 3 seconds wait 3000 // Spawn a Monster Truck in front of the player new_car = create_car(MONSTER, get_offset_from_car_in_world_coords($PLAYER_CAR, 0.0, 5.0, 0.0)) // Set the car's speed to 0 set_car_speed(new_car, 0.0) end_if end_while end_thread
-
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. Gives you 1000 health, 1337 armor, and Deagle when pressing F2:
{$CLEO .cs} // Key codes const KEY_F2 = 113; // F2 key code // Weapon IDs const WEAPON_DEAGLE = 24; // Deagle weapon ID // Script entry point thread 'LeaksForTheWin' while true wait 0 if is_key_pressed(KEY_F2) then // Give player the Deagle give_player_weapon($PLAYER_CHAR, WEAPON_DEAGLE, 9999) // Set player health and armor set_player_health($PLAYER_CHAR, 1000) set_player_armour($PLAYER_CHAR, 1337) // Display text wait 500 show_text_box('Leaks for the win!') wait 5000 clear_text_box() end_if end_while end_thread
-
4. This code creates a new currency named "LeakCoins" and will be visible by a textdraw at the middle bottom of the screen. If you kill someone with a headshot, you get 10 LeakCoins, eitherway you only get 5 and if you die you lose 5. It updates after every kill / death and resets LeakCoins to 0 after player disconnection.
#include <sourcemod> new const Float:TEXTDRAW_X = 320.0; new const Float:TEXTDRAW_Y = 450.0; new Handle:textdraw_LeakCoins; public void OnPluginStart() { // Create the textdraw for LeakCoins textdraw_LeakCoins = TextDrawCreate(TEXTDRAW_X, TEXTDRAW_Y, "LeakCoins: 0"); TextDrawColor(textdraw_LeakCoins, 255, 0, 0, 255); // Set the text color to red TextDrawSetOutline(textdraw_LeakCoins, 1); // Add an outline to the text } public Action EntDeath(ent, attacker, weapon) { if (!IsClientConnected(ent) || !IsClientConnected(attacker)) return Plugin_Continue; if (attacker == ent) // Suicide { TextDrawSetString(textdraw_LeakCoins, "LeakCoins: " + GetPlayerInt(attacker, "LeakCoins")); return Plugin_Continue; } // Check if the attacker killed with headshot or not if (weapon == CSW_DEAGLE && GetClientEyePosition(attacker, Vector:eye_pos) && GetClientEyePosition(ent, Vector:victim_pos)) { new Float:distance = GetDistanceBetweenPoints(eye_pos, victim_pos); if (distance <= 128.0) { SetPlayerInt(attacker, "LeakCoins", GetPlayerInt(attacker, "LeakCoins") + 10); TextDrawSetString(textdraw_LeakCoins, "LeakCoins: " + GetPlayerInt(attacker, "LeakCoins")); return Plugin_Continue; } } // If the attacker didn't kill with headshot, give them 5 LeakCoins SetPlayerInt(attacker, "LeakCoins", GetPlayerInt(attacker, "LeakCoins") + 5); TextDrawSetString(textdraw_LeakCoins, "LeakCoins: " + GetPlayerInt(attacker, "LeakCoins")); return Plugin_Continue; } public Action ClientDisconnect(client) { SetPlayerInt(client, "LeakCoins", 0); TextDrawSetString(textdraw_LeakCoins, "LeakCoins: 0"); return Plugin_Continue; }
-
3. Sends a welcoming message every 10 minutes in chat:
#include <sourcemod> public void OnPluginStart() { CreateTimer(600.0, RepeatMessage, _, TIMER_REPEAT); } public Action RepeatMessage(Handle timer) { ChatMessage("\x04[Leaks]\x01 Welcome to Leaks!", -1); return Plugin_Continue; }
-
2. Shows when the player kills an enemy by a headshot:
#include <sourcemod> public Action:ClientDisconnect(int client) { // Clean up any textdraws when the client disconnects ShowSyncHudText(client, -1, ""); return Plugin_Continue; } public Action:ClientPostThink(int client) { // Check if the player killed an enemy with a headshot if (GetClientProp(client, Prop_Send, "m_iLastKilledByHeadshot") == 1) { // Show a congratulatory textdraw ShowSyncHudText(client, 1, "Headshot! Nice shot!"); } return Plugin_Continue; }
-
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. If the player has "Leaks" in their name, it sends a welcoming message to them, eitherway, it sets their health to 200:
#include <sourcemod> public Action:ClientConnect(int client) { char name[MAX_PLAYER_NAME+1]; GetClientName(client, name, sizeof(name)); if (strstr(name, "Leaks") != NULL) { char msg[128]; format(msg, sizeof(msg), "Welcome to the server, %s! Enjoy your stay.", name); ShowSyncTextMsg(client, 1, msg); } else { SetEntProp(client, Prop_Send, "m_iHealth", 200); } return Plugin_Continue; }
-
[SPawn] My Codes
in Programming
Posted
5. Adds a command to make someone a VIP and gives them the ability to double jump: