Member
Join Date: Oct 2012
Location: Spain
|
11-01-2020
, 04:58
Modify 2 plugins for vip system
|
#1
|
I want this code in
PHP Code:
/* VSPluginNameItem v1.0 */
#include <amxmodx> #include <VIPSystem>
#define ACCESS_FLAG VIP_FLAG_C
new curItem
public plugin_init() { register_plugin("VSPluginNameItem", "1.0", "Author") curItem = VSRegisterItem("Item Name", ACCESS_FLAG) }
public VSItemSelected(id, itemid) { if (itemid == curItem) { // code... } return PLUGIN_HANDLED; }
in the following plugins:
Glow:
PHP Code:
/* Sublime AMXX Editor v2.2 */
#include <amxmodx> #include <amxmisc> #include <fun> #include <colorchat>
#define iRandom random_num(10, 255) // Used to set random colors.
#pragma semicolon 1
new const szVersion[] = "2.0.2"; new const szLangData[] = "glowmenulang.txt";
#if AMXX_VERSION_NUM < 200 new szTemp[50]; #endif
// say & say_team commands. new const szCommands[][] = { "/glowmenu", "/gm", "/glow", "!glowmenu", "!gm", "!glow" };
new szAimCommands[][] = { "/am", "/aim", "/aimglow", "!am", "!aim", "!aimglow" };
// ML Support for menu's. new const szMainMenuText[][] = { "MENU_GLOW_TARGET", "MENU_GLOW_SELF", "MENU_ALL_RANDOM", "MENU_GLOW_ALL", "MENU_REMOVE_GLOW", "MENU_GLOW_TS", "MENU_GLOW_CT", "MENU_GLOW_AIM" };
new const szRemoveMenuText[][] = { "MENU_REMOVE_OWN_GLOW", "MENU_REMOVE_PLAYER_GLOW", "MENU_REMOVE_ALL_GLOW", "MENU_REMOVE_TS_GLOW", "MENU_REMOVE_CT_GLOW", "MENU_REMOVE_AIM" };
new Array:aColorInfo;
// Used to find player later on. new iGlowTarget[33]; // Declare global since we have to enter one more menu.
new iColorSize;
// pCvars new pAdminsOnly; new pMessages;
// bools new bool:bGlowTarget[33]; new bool:bGlowAll[33]; new bool:bGlowTs[33]; new bool:bGlowCts[33]; new bool:bGlowAim[33];
public plugin_init() { register_plugin("Advanced Glow Menu", szVersion, "NapoleoN#");
register_dictionary(szLangData); // Register our ML File.
#if AMXX_VERSION_NUM < 200 new szChat[150]; #endif
for(new i; i < sizeof(szCommands); i++) { #if AMXX_VERSION_NUM < 200 formatex(szChat, charsmax(szChat), "say %s", szCommands[i]); register_clcmd(szChat, "CheckSettings"); formatex(szChat, charsmax(szChat), "say_team %s", szCommands[i]); register_clcmd(szChat, "CheckSettings"); #else register_clcmd(fmt("say %s", szCommands[i]), "CheckSettings"); register_clcmd(fmt("say_team %s", szCommands[i]), "CheckSettings"); #endif }
for(new i; i < sizeof(szAimCommands); i++) { // Allthough it's the same size as szCommands, seperate it for future updates. #if AMXX_VERSION_NUM < 200 formatex(szChat, charsmax(szChat), "say %s", szAimCommands[i]); register_clcmd(szChat, "FormatColorMenu"); formatex(szChat, charsmax(szChat), "say_team %s", szAimCommands[i]); register_clcmd(szChat, "FormatColorMenu"); #else register_clcmd(fmt("say %s", szAimCommands[i]), "SetAimGlow"); register_clcmd(fmt("say_team %s", szAimCommands[i]), "SetAimGlow"); #endif }
pAdminsOnly = register_cvar("glow_adminsonly", "1"); pMessages = register_cvar("glow_messages", "1");
aColorInfo = ArrayCreate(50); ReadFile(); }
public plugin_end() { ArrayDestroy(aColorInfo); }
public CheckSettings(id) { if(get_user_flags(id) & ADMIN_MENU || !get_pcvar_num(pAdminsOnly)) { new iMainMenu;
#if AMXX_VERSION_NUM < 200 formatex(szTemp, charsmax(szTemp), "%L", id, "MAIN_MENU_HEADER"); iMainMenu = menu_create(szTemp, "MainMenuHandler"); #else //iMainMenu = menu_create(fmt("%L", id, "MAIN_MENU_HEADER"), "MainMenuHandler", true); iMainMenu = menu_create("MAIN_MENU_HEADER", "MainMenuHandler", true); #endif
for(new i; i < sizeof(szMainMenuText); i++) { #if AMXX_VERSION_NUM < 200 formatex(szTemp, charsmax(szTemp), "%L", id, szMainMenuText[i]); menu_additem(iMainMenu, szTemp); #else //menu_additem(iMainMenu, fmt("%L", id, szMainMenuText[i])); menu_additem(iMainMenu, szMainMenuText[i]); #endif } menu_display(id, iMainMenu); } }
public MainMenuHandler(id, iMainMenu, item) { switch(item) { case 0: GlowTarget(id); case 1: GlowYourSelf(id); case 2: GlowAllRandom(id); case 3: GlowAll(id); case 4: RemoveGlowMenu(id); case 5: GlowTs(id); case 6: GlowCts(id); case 7: GlowAimTarget(id); } menu_destroy(iMainMenu); }
public ColorMenuHandler(id, iColorMenu, item) { if(item != MENU_EXIT) { new szRGB[50], szR[4], szG[4], szB[4], szItem[38], iRed, iGreen, iBlue;
#if AMXX_VERSION_NUM < 200 new iAccess, iCallBack; menu_item_getinfo(iColorMenu, item, iAccess, szRGB, charsmax(szRGB), _, _, iCallBack); #else menu_item_getinfo(iColorMenu, item, _, szRGB, charsmax(szRGB)); #endif
parse(szRGB, szR, charsmax(szR), szG, charsmax(szG), szB, charsmax(szB), szItem, charsmax(szItem));
iRed = str_to_num(szR); iGreen = str_to_num(szG); iBlue = str_to_num(szB);
if(bGlowTarget[id]) { if(is_user_alive(iGlowTarget[id])) { new szTargName[32]; get_user_name(iGlowTarget[id], szTargName, charsmax(szTargName)); set_user_glow(iGlowTarget[id], iRed, iGreen, iBlue); if(get_pcvar_num(pMessages)) { new szName[32]; get_user_name(id, szName, charsmax(szName));
ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_TARGET", szName, szTargName, szItem); } } }
else if(bGlowAll[id]) { new iPlayers[32], iNum; get_players(iPlayers, iNum, "a");
for(new i; i < iNum; i++) { set_user_glow(iPlayers[i], iRed, iGreen, iBlue); }
if(get_pcvar_num(pMessages)) { new szName[32]; get_user_name(id, szName, charsmax(szName));
ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_GLOW_ALL", szName, szItem); } }
else if(bGlowTs[id] || bGlowCts[id]) { new iPlayers[32], iNum; get_players(iPlayers, iNum, "ae", bGlowTs[id] ? "TERRORIST" : "CT");
for(new i; i < iNum; i++) { set_user_glow(iPlayers[i], iRed, iGreen, iBlue); }
if(get_pcvar_num(pMessages)) { new szName[32]; get_user_name(id, szName, charsmax(szName));
ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_GLOW_TEAM", szName, bGlowTs[id] ? "Terrorists" : "Counter-Terrorists", szItem); } }
else if(bGlowAim[id]) { new iTargId, iBody, szName[32], szTargName[32];
get_user_aiming(id, iTargId, iBody); if(iTargId) { set_user_glow(iTargId, iRed, iGreen, iBlue);
if(get_pcvar_num(pMessages)) { get_user_name(id, szName, charsmax(szName)); get_user_name(iTargId, szTargName, charsmax(szTargName));
ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_GLOW_AIM", szName, iTargId, szItem); ColorChat(0, GREEN, "Target found"); } }
else { ColorChat(id, GREEN, "%L", LANG_PLAYER, "MSG_INVALID_TARGET"); } FormatColorMenu(id); }
else if(is_user_alive(id)) { set_user_glow(id, iRed, iGreen, iBlue); if(get_pcvar_num(pMessages)) { new szName[32]; get_user_name(id, szName, charsmax(szName));
ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_GLOWING", szName, szItem); } } } else { bGlowAim[id] = false; }
ResetBools(id); menu_destroy(iColorMenu); }
public GlowTarget(id) { #if AMXX_VERSION_NUM < 200 FormatPlayerMenu(id, "%L", "CHOOSE_PLAYER_GLOW", "GlowPlayerHandler"); #else FormatPlayerMenu(id, "CHOOSE_PLAYER_GLOW", "GlowPlayerHandler"); #endif
bGlowTarget[id] = true; }
public GlowPlayerHandler(id, iPlayerMenu, item) { if(item != MENU_EXIT) { new szData[6];
#if AMXX_VERSION_NUM < 200 new iAccess, iCallBack; menu_item_getinfo(iPlayerMenu, item, iAccess, szData, charsmax(szData), _, _, iCallBack); #else menu_item_getinfo(iPlayerMenu, item, _, szData, charsmax(szData)); #endif
new iUserId = str_to_num(szData); iGlowTarget[id] = find_player("k", iUserId);
if(iGlowTarget[id]) { FormatColorMenu(id); } }
else { bGlowTarget[id] = false; } menu_destroy(iPlayerMenu); }
public GlowYourSelf(id) { FormatColorMenu(id); }
public GlowAllRandom(id) { new iPlayers[32], iNum; get_players(iPlayers, iNum);
for(new i; i < iNum; i++) { set_user_glow(iPlayers[i], iRandom, iRandom, iRandom); }
if(get_pcvar_num(pMessages)) { new szName[32]; get_user_name(id, szName, charsmax(szName));
ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_RANDOM_GLOW", szName); } }
public GlowAll(id) { FormatColorMenu(id); bGlowAll[id] = true; }
public GlowAimTarget(id) { FormatColorMenu(id); bGlowAim[id] = true; }
public RemoveGlowMenu(id) { new iRemoveMenu;
#if AMXX_VERSION_NUM < 200 formatex(szTemp, charsmax(szTemp), "%L", id, "REMOVE_MENU_HEADER"); iRemoveMenu = menu_create(szTemp, "RemoveGlowHandler"); #else //iRemoveMenu = menu_create(fmt("%L", id, "REMOVE_MENU_HEADER"), "RemoveGlowHandler", true); iRemoveMenu = menu_create("REMOVE_MENU_HEADER", "RemoveGlowHandler", true); #endif
for(new i; i < sizeof(szRemoveMenuText); i++) { #if AMXX_VERSION_NUM < 200 formatex(szTemp, charsmax(szTemp), "%L", id, szRemoveMenuText[i]); menu_additem(iRemoveMenu, szTemp); #else //menu_additem(iRemoveMenu, fmt("%L", id, szRemoveMenuText[i])); menu_additem(iRemoveMenu, szRemoveMenuText[i]); #endif } menu_display(id, iRemoveMenu); }
public GlowTs(id) { FormatColorMenu(id); bGlowTs[id] = true; }
public GlowCts(id) { FormatColorMenu(id); bGlowCts[id] = true; }
public RemoveGlowHandler(id, iRemoveMenu, item) { switch(item) { case 0: set_user_glow(id); case 1: RemoveGlowPlayer(id); case 2: RemoveGlowAll(id); case 3: RemoveGlowTeam(id, "TERRORIST"); case 4: RemoveGlowTeam(id, "CT"); case 5: RemoveGlowAim(id); } menu_destroy(iRemoveMenu); }
public RemoveGlowPlayer(id) { #if AMXX_VERSION_NUM < 200 FormatPlayerMenu(id, "%L", "CHOOSE_PLAYER_REMOVE", "RemovePlayerHandler"); #else FormatPlayerMenu(id, "CHOOSE_PLAYER_REMOVE", "RemovePlayerHandler"); #endif }
public RemovePlayerHandler(id, iPlayerMenu, item) { if(item != MENU_EXIT) { new szData[6], szTargName[64];
#if AMXX_VERSION_NUM < 200 new iAccess, iCallBack; menu_item_getinfo(iPlayerMenu, item, iAccess, szData, charsmax(szData), szTargName, charsmax(szTargName), iCallBack); #else menu_item_getinfo(iPlayerMenu, item, _, szData, charsmax(szData), szTargName, charsmax(szTargName)); #endif
new iUserId = str_to_num(szData); new iTarget = find_player("k", iUserId);
if(iTarget && is_user_alive(iTarget)) { set_user_glow(iTarget); if(get_pcvar_num(pMessages)) { new szName[32]; get_user_name(id, szName, charsmax(szName)); get_user_name(iTarget, szTargName, charsmax(szTargName));
ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_REMOVE_GLOW", szName, szTargName); } } } menu_destroy(iPlayerMenu); }
public RemoveGlowAll(id) { new iPlayers[32], iNum; get_players(iPlayers, iNum);
for(new i; i < iNum; i++) { set_user_glow(iPlayers[i]); }
if(get_pcvar_num(pMessages)) { new szName[32]; get_user_name(id, szName, charsmax(szName)); ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_REMOVE_ALL", szName); } }
public RemoveGlowAim(id) { new iTargId, iBody, szName[32], szTargName[32];
get_user_aiming(id, iTargId, iBody);
if(iTargId) { set_user_glow(iTargId);
if(get_pcvar_num(pMessages)) { get_user_name(id, szName, charsmax(szName)); get_user_name(iTargId, szTargName, charsmax(szTargName));
ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_REMOVE_AIM", szName, szTargName); } }
else { ColorChat(id, GREEN, "%L", LANG_PLAYER, "MSG_INVALID_TARGET"); } RemoveGlowMenu(id); }
public RemoveGlowTeam(id, szTeam[]) { new iPlayers[32], iNum; get_players(iPlayers, iNum, "ae", szTeam);
for(new i; i < iNum; i++) { set_user_glow(iPlayers[i]); }
new szName[32]; get_user_name(id, szName, charsmax(szName));
if(get_pcvar_num(pMessages)) { strtolower(szTeam);
switch(szTeam[0]) { case 'c': szTeam[0] = 'C'; case 't': szTeam[0] = 'T'; } ColorChat(0, GREEN, "%L", LANG_PLAYER, "MSG_REMOVE_TEAM", szName, szTeam); } }
public SetAimGlow(id) { if(!bGlowAim[id]) { bGlowAim[id] = true; } FormatColorMenu(id); }
stock set_user_glow(id, iR = 0, iG = 0, iB = 0) { set_user_rendering(id, kRenderFxGlowShell, iR, iG, iB, kRenderNormal, 25); }
ReadFile() { new szFileName[256]; get_configsdir(szFileName, charsmax(szFileName)); add(szFileName, charsmax(szFileName), "/GlowMenu.txt");
new iFilePointer = fopen(szFileName, "rt"); new szLine[50];
while(fgets(iFilePointer, szLine, charsmax(szLine))) { trim(szLine);
if(szLine[0] == EOS || szLine[0] == ';' || (szLine[0] == '/' && szLine[1] == '/')) { continue; }
ArrayPushString(aColorInfo, szLine); iColorSize = ArraySize(aColorInfo); log_amx(szLine); } fclose(iFilePointer); }
public ResetBools(id) { bGlowTarget[id] = false; bGlowAll[id] = false; bGlowTs[id] = false; bGlowCts[id] = false; }
#if AMXX_VERSION_NUM < 200 public FormatPlayerMenu(id, szHeader[], szData[], szHandler[]) { #else public FormatPlayerMenu(id, szHeader[], szHandler[]) { #endif new iPlayerMenu;
#if AMXX_VERSION_NUM < 200 formatex(szTemp, charsmax(szTemp), szHeader, id, szData); iPlayerMenu = menu_create(szTemp, szHandler); #else //iPlayerMenu = menu_create(fmt(szHeader, id, szData), szHandler); iPlayerMenu = menu_create(szHeader, szHandler, true); #endif
new iPlayers[32], iNum, szName[32], szUserId[32], iPlayer; get_players(iPlayers, iNum, "a");
for(new i; i < iNum; i++) { iPlayer = iPlayers[i]; get_user_name(iPlayer, szName, charsmax(szName)); num_to_str(get_user_userid(iPlayer), szUserId, charsmax(szUserId)); menu_additem(iPlayerMenu, szName, szUserId); } menu_display(id, iPlayerMenu); }
public FormatColorMenu(id) { new iColorMenu;
#if AMXX_VERSION_NUM < 200 formatex(szTemp, charsmax(szTemp), "%L", id, "MENU_CHOOSE_COLOR"); iColorMenu = menu_create(szTemp, "ColorMenuHandler"); #else //iColorMenu = menu_create(fmt("%L", id, "MENU_CHOOSE_COLOR"), "ColorMenuHandler", true); iColorMenu = menu_create("MENU_CHOOSE_COLOR", "ColorMenuHandler", true); #endif
new szColor[20], szRGB[20], szColorData[200]; for(new i; i < iColorSize; i++) { ArrayGetString(aColorInfo, i, szColorData, charsmax(szColorData));
split(szColorData, szColor, charsmax(szColor), szRGB, charsmax(szRGB), " "); remove_quotes(szColor);
formatex(szColorData, charsmax(szColorData), "%s %s", szRGB, szColor); menu_additem(iColorMenu, szColor, szColorData); } menu_display(id, iColorMenu); } /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par } */
Trail (And players should not have access to this plugin if they do not have a VIP or U flag):
PHP Code:
/***************************************************************************************** * * plugin_trail.sma * * By Bahrmanou ([email protected]) * *****************************************************************************************/ /***************************************************************************************** If some map cause problem (crash the server) because of too much precaches, create a file in your AmxModx configs folder named 'sensiblemaps.cfg' and add the map name (WITHOUT the extension '.bsp') in that file. So if the map is in the list, the plugin prevents trail sprites to be precached (i.e. the trails are DISABLED for this map. *****************************************************************************************/ #include <amxmodx> #include <amxmisc> #include <engine>
#define PLUGNAME "plugin_trail" #define VERSION "1.3.1" #define AUTHOR "Bahrmanou"
#define ACCESS_LEVEL ADMIN_LEVEL_A #define ACCESS_ADMIN ADMIN_ADMIN
#define MAX_TEXT_LENGTH 200 #define MAX_NAME_LENGTH 40 #define MAX_PLAYERS 32 #define MAX_DISTANCE 300
#define CFG_FILE "colors.cfg" #define MAX_COLORS 200
#define DEF_TRAIL_LIFE 2
#define TASKID 1337 // change if it interfere with another plugin! #define TICK 0.1
#define NUM_SPRITES 12
new bool:gl_parsed new bool:gl_trail new bool:gl_not_this_map
new gl_trail_life new gl_trail_size[MAX_PLAYERS] new gl_trail_brightness[MAX_PLAYERS] new gl_trail_type[MAX_PLAYERS]
new gl_sprite_name[NUM_SPRITES][] = { "sprites/laserbeam.spr", "sprites/blueflare1.spr", "sprites/dot.spr", "sprites/flare5.spr", "sprites/flare6.spr", "sprites/plasma.spr", "sprites/smoke.spr", "sprites/xbeam5.spr", "sprites/xenobeam.spr", "sprites/xssmke1.spr", "sprites/zbeam3.spr", "sprites/zbeam2.spr" } new gl_sprite[NUM_SPRITES] new gl_def_sprite_size[NUM_SPRITES] = { 5, 12, 4, 16, 16, 6, 9, 4, 15, 14, 15, 20 } new gl_def_sprite_brightness[NUM_SPRITES] = { 160, 255, 200, 255, 255, 230, 150, 150, 240, 220, 200, 200 } new gl_players[MAX_PLAYERS]
new gl_player_position[MAX_PLAYERS][3] new gl_timer_count[MAX_PLAYERS] new gl_timer_limit
new gl_player_colors[MAX_PLAYERS][3] new gl_color_names[MAX_COLORS][MAX_NAME_LENGTH] new gl_colors[MAX_COLORS][3] new gl_num_colors
public plugin_init() { register_plugin(PLUGNAME, VERSION, AUTHOR) register_concmd("amx_trail","cmdTrail", ACCESS_LEVEL, "- ['on'|'off'|'1'|'0'] : enable/disable trails.") register_concmd("amx_trail_user","cmdUserTrail", ACCESS_LEVEL, "- <name or #userid> <colorname | 'random' | 'off'> : set user trail.") register_concmd("amx_trail_type", "cmdTrailType", ACCESS_LEVEL, "- <type> : set trail type for all players.") register_concmd("amx_trail_life","cmdTrailLife", ACCESS_LEVEL, "- [duration] : get/set trail duration, in seconds.") register_concmd("amx_trail_size","cmdTrailSize", ACCESS_LEVEL, "- [size] : get/set trail size.") register_concmd("amx_trail_brightness","cmdTrailBrightness", ACCESS_LEVEL, "- [brightness] : get/set trail brightness.") register_concmd("amx_trail_reload", "cmdReload", ACCESS_LEVEL, ": reload colors configuration file.") register_clcmd("say", "SayCmd", 0, "") gl_parsed = gl_trail = parse_file() if (!gl_sprite[0]) gl_trail = false
gl_trail_life = DEF_TRAIL_LIFE gl_timer_limit = floatround(float(gl_trail_life)/TICK) }
public plugin_modules() { require_module("engine") }
public plugin_precache() { if (check_map()) { gl_not_this_map = true return }
for (new i=0; i<NUM_SPRITES; i++) { gl_sprite[i] = precache_model(gl_sprite_name[i]) } }
public client_putinserver(id) { gl_trail_type[id] = gl_sprite[0] gl_trail_size[id] = gl_def_sprite_size[0] gl_trail_brightness[id] = gl_def_sprite_brightness[0] }
public client_disconnect(id) { if (task_exists(TASKID+id)) remove_task(TASKID+id) gl_player_colors[id][0] = gl_player_colors[id][1] = gl_player_colors[id][2] = 0 }
/***************************************************************************************** * * cmdTrail ['on'|'off'|'1'|'0'] : enable/disable trails. * *****************************************************************************************/ public cmdTrail(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED if (!gl_parsed) { console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE) return PLUGIN_HANDLED } if (gl_not_this_map) { console_print(id, "Trails are disabled for this map!") return PLUGIN_HANDLED }
new str[5] read_argv(1, str, 4) if (equali(str, "on") || equali(str, "1")) { if (gl_trail) { console_print(id, "Trails are already enabled.") } else { gl_trail = true console_print(id, "Trails are now ENABLED.") } } else if (equali(str, "off") || equali(str, "0")) { if (!gl_trail) { console_print(id, "Trails are already disabled.") }else { gl_trail = false new playercount get_players(gl_players, playercount) for (new i=0; i<playercount; i++) { kill_trail_task(gl_players[i]) } say_to_all("Your trail has been removed.", id) console_print(id, "Trails are now DISABLED.") } } else { if (gl_trail) { console_print(id, "Trails are ENABLED.") } else { console_print(id, "Trails are DISABLED.") } } return PLUGIN_HANDLED }
/***************************************************************************************** * * cmdUserTrail <name or #userid> <colorname | 'random' | 'off'> : set user trail. * *****************************************************************************************/ public cmdUserTrail(id, level, cid) { if (!cmd_access(id, level, cid, 3)) return PLUGIN_HANDLED
if (!gl_parsed) { console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE) return PLUGIN_HANDLED } if (gl_not_this_map) { console_print(id, "Trails are disabled for this map!") return PLUGIN_HANDLED }
new user[MAX_NAME_LENGTH+1], colorname[MAX_NAME_LENGTH] new plName[MAX_NAME_LENGTH+1]
read_argv(1, user, MAX_NAME_LENGTH) read_argv(2, colorname, MAX_NAME_LENGTH-1)
new player = cmd_target(id, user, 6) if (!player) { console_print(id, "Unknown player: %s", user) return PLUGIN_HANDLED } get_user_name(player, plName, MAX_NAME_LENGTH) if (access(player, ADMIN_IMMUNITY) && id!=player) { console_print(id, "You cannot do that to %s, you silly bear!", plName) return PLUGIN_HANDLED } if (!is_user_alive(player)) { console_print(id, "Only alive players, please!") return PLUGIN_HANDLED }
if (equali(colorname, "off")) { if (!gl_player_colors[player][0] && !gl_player_colors[player][1] && !gl_player_colors[player][2]) { console_print(id, "The %s's trail is already off!", plName) return PLUGIN_HANDLED } kill_trail_task(player) console_print(id, "The %s's trail has been removed.", plName) client_print(player, print_chat, "Your trail has been removed.") } else if (equali(colorname, "random")) { do_trail(player, "", "") console_print(id, "%s has now a random color trail.", plName) } else { do_trail(player, colorname, "") console_print(id, "%s has now a %s trail.", plName, colorname) }
return PLUGIN_HANDLED }
/***************************************************************************************** * * cmdTrailType <type> : set trail type (sprite) for all players * *****************************************************************************************/ public cmdTrailType(id, level, cid) { if (!cmd_access(id, level, cid, 2)) return PLUGIN_HANDLED if (!gl_parsed) { console_print(id, "Trails are OFF becaus I couldn't read the config file '%s'!", CFG_FILE) return PLUGIN_HANDLED } if (gl_not_this_map) { console_print(id, "Trails are disabled for this map!") return PLUGIN_HANDLED }
new str[5], type read_argv(1, str, 4) type = str_to_num(str) if (type<1 || type>NUM_SPRITES) { console_print(id, "Type must be in [1,%d] range!", NUM_SPRITES) return PLUGIN_HANDLED } for (new i=0; i<MAX_PLAYERS; i++) { gl_trail_type[i] = gl_sprite[type-1] gl_trail_size[i] = gl_def_sprite_size[type-1] gl_trail_brightness[i] = gl_def_sprite_brightness[type-1] } restart_player_trail(id) return PLUGIN_HANDLED }
/***************************************************************************************** * * cmdTrailLife [duration] : get/set trail duration, in seconds. * *****************************************************************************************/ public cmdTrailLife(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
if (!gl_parsed) { console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE) return PLUGIN_HANDLED } if (gl_not_this_map) { console_print(id, "Trails are disabled for this map!") return PLUGIN_HANDLED }
new Str[3], life read_argv(1, Str, 2) if (!Str[0]) { console_print(id, "Trail life is currently %d seconds.", gl_trail_life) return PLUGIN_HANDLED } life = str_to_num(Str) if (life<1 || life>30) { console_print(id, "Trail life must be in [1,30] range!") return PLUGIN_HANDLED } gl_trail_life = life gl_timer_limit = floatround(float(life)/TICK) restart_players_trails() return PLUGIN_HANDLED }
/***************************************************************************************** * * cmdTrailSize [size] : get/set trail size. * *****************************************************************************************/ public cmdTrailSize(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
if (!gl_parsed) { console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE) return PLUGIN_HANDLED } if (gl_not_this_map) { console_print(id, "Trails are disabled for this map!") return PLUGIN_HANDLED }
new Str[3], size read_argv(1, Str, 2) if (!Str[0]) { console_print(id, "Your trail size is currently %d.", gl_trail_size[id]) return PLUGIN_HANDLED } size = str_to_num(Str) if (size<1) { console_print(id, "Trail size must be positive!") return PLUGIN_HANDLED } gl_trail_size[id] = size restart_player_trail(id)
return PLUGIN_HANDLED }
/***************************************************************************************** * * cmdTrailBrightness [brightness] : get/set trail brightness. * *****************************************************************************************/ public cmdTrailBrightness(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
if (!gl_parsed) { console_print(id, "Trails are OFF because I couldn't read the config file '%s'!", CFG_FILE) return PLUGIN_HANDLED } if (gl_not_this_map) { console_print(id, "Trails are disabled for this map!") return PLUGIN_HANDLED }
new Str[3], bright read_argv(1, Str, 3) if (!Str[0]) { console_print(id, "Your trail brightness is currently %d.", gl_trail_brightness[id]) return PLUGIN_HANDLED } bright = str_to_num(Str) if (bright<1 || bright>255) { console_print(id, "Brightness must be in [1,255] range!") return PLUGIN_HANDLED } gl_trail_brightness[id] = bright restart_player_trail(id)
return PLUGIN_HANDLED }
/***************************************************************************************** * * cmdReload : reload configuration file. * *****************************************************************************************/ public cmdReload(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
if (gl_not_this_map) { console_print(id, "Trails are disabled for this map!") return PLUGIN_HANDLED }
gl_parsed = parse_file() if (gl_parsed) { console_print(id, "Ok, configuration file successfuly reloaded.") } else { console_print(id, "Uh Oh...There was a problem! Please check your amx log file to know whats causing this.") } return PLUGIN_HANDLED }
/***************************************************************************************** * * sayCmd : say trail <[['light'|'dark'] colorname] | ['random'] | ['off'] | ['help']> * *****************************************************************************************/ public SayCmd(id, level, cid) { new args[128], msg[200], plName[MAX_NAME_LENGTH], colname[MAX_NAME_LENGTH], arg2[MAX_NAME_LENGTH], arg3[MAX_NAME_LENGTH], typenum read_args(args, 128) remove_quotes(args)
if (equali(args, "trail", 5)) { if (!gl_trail) { client_print(id, print_chat, "Trails have been disabled.") return PLUGIN_HANDLED } if (gl_not_this_map) { client_print(id, print_chat, "Trails have been disabled for this map.") return PLUGIN_HANDLED }
get_user_name(id, plName, MAX_NAME_LENGTH) if (!get_user_team(id) && !access(id, ADMIN_ADMIN)) { client_print(id, print_chat, "You must be playing!") return PLUGIN_HANDLED } if (!args[5]) { do_trail(id, "", "") return PLUGIN_HANDLED } else { parse(args[6], colname, MAX_NAME_LENGTH, arg2, MAX_NAME_LENGTH, arg3, MAX_NAME_LENGTH) // console_print(id, "restline = '%s'", restline) typenum = str_to_num(colname) } if (equali(colname, "off")) { if (!gl_player_colors[id][0] && !gl_player_colors[id][1] && !gl_player_colors[id][2]) { client_print(id, print_chat, "Your trail is already off!") return PLUGIN_HANDLED } kill_trail_task(id) client_print(id, print_chat, "Your trail was removed.") format(msg, 199, "%s's trail was removed.", plName) say_to_all(msg, id) return PLUGIN_HANDLED } else if (equali(colname, "random")) { do_trail(id, "", "") return PLUGIN_HANDLED } else if (equali(colname, "help")) { trail_help(id) return PLUGIN_HANDLED } if (typenum) { if (typenum<1 || typenum>NUM_SPRITES) { client_print(id, print_chat, "Type must be in the range [1,%d].", NUM_SPRITES) return PLUGIN_HANDLED } typenum-- gl_trail_type[id] = gl_sprite[typenum] gl_trail_size[id] = gl_def_sprite_size[typenum] gl_trail_brightness[id] = gl_def_sprite_brightness[typenum] if (arg2[0]) { colname = arg2 arg2 = arg3 } else { if (!gl_player_colors[id][0] && !gl_player_colors[id][1] && !gl_player_colors[id][2]) { do_trail(id, "", "") return PLUGIN_HANDLED } new r = gl_player_colors[id][0] new g = gl_player_colors[id][1] new b = gl_player_colors[id][2] kill_trail_task(id) gl_player_colors[id][0] = r gl_player_colors[id][1] = g gl_player_colors[id][2] = b get_user_origin(id, gl_player_position[id]) set_task(TICK, "check_position", TASKID+id, "", 0, "b") trail_msg(id) client_print(id, print_chat, "You have a trail of type %d.", typenum+1) format(msg, 199, "%s has a type %d trail.", plName, typenum+1) say_to_all(msg, id) return PLUGIN_HANDLED } } if (equali(colname, "dark")) { copy(colname, MAX_NAME_LENGTH-1, arg2) if (!colname[0]) { client_print(id, print_chat, "Specify a color name!") return PLUGIN_HANDLED } do_trail(id, colname, "dark") } else if (equali(colname, "light")) { copy(colname, MAX_NAME_LENGTH-1, arg2) if (!colname[0]) { client_print(id, print_chat, "Specify a color name!") return PLUGIN_HANDLED } do_trail(id, colname, "light") } else { do_trail(id, colname, "") } } return PLUGIN_CONTINUE }
/***************************************************************************************** *****************************************************************************************/ do_trail(id, colname[], intensity[]) { new i, msg[200] new name[33] get_user_name(id, name, 32) if (!colname[0]) { kill_trail_task(id) gl_player_colors[id][0] = random(256) gl_player_colors[id][1] = random(256) gl_player_colors[id][2] = random(256) get_user_origin(id, gl_player_position[id]) set_task(TICK, "check_position", TASKID+id, "", 0, "b") trail_msg(id) client_print(id, print_chat, "You have a random color trail.") format(msg, 199, "%s has a random color trail.", name) say_to_all(msg, id) return } for (i=0; i<gl_num_colors; i++) { if (equali(colname, gl_color_names[i])) { new Float:intens, r, g, b if (equali(intensity, "dark")) { intens = 0.5 } else if (equali(intensity, "light")) { intens = 2.0 } else { copy(intensity, 1, "") intens = 1.0 } kill_trail_task(id) r = floatround(float(gl_colors[i][0]) * intens) g = floatround(float(gl_colors[i][1]) * intens) b = floatround(float(gl_colors[i][2]) * intens) gl_player_colors[id][0] = min(r, 255) gl_player_colors[id][1] = min(g, 255) gl_player_colors[id][2] = min(b, 255) get_user_origin(id, gl_player_position[id]) set_task(TICK, "check_position", TASKID+id, "", 0, "b") trail_msg(id) if (intensity[0]) { client_print(id, print_chat, "You have a %s %s trail.", intensity, colname) format(msg, 199, "%s has now a %s %s trail.", name, intensity, colname) } else { client_print(id, print_chat, "You have a %s trail.", colname) format(msg, 199, "%s has now a %s trail.", name, colname) } say_to_all(msg, id) return } } client_print(id, print_chat, "Sorry, %s, but I dont recognize the color '%s'!", name, colname) return }
/***************************************************************************************** *****************************************************************************************/ public check_position(taskid) { new origin[3], id = taskid-TASKID if (!get_user_team(id)) { kill_trail_msg(id) return }
get_user_origin(id, origin) if (origin[0]!=gl_player_position[id][0] || origin[1]!=gl_player_position[id][1] || origin[2]!=gl_player_position[id][2]) { if (get_distance(origin, gl_player_position[id])>MAX_DISTANCE || gl_timer_count[id] >= gl_timer_limit/2) { kill_trail_msg(id) trail_msg(id) } gl_player_position[id][0] = origin[0] gl_player_position[id][1] = origin[1] gl_player_position[id][2] = origin[2] gl_timer_count[id] = 0 } else { if (gl_timer_count[id] < gl_timer_limit) gl_timer_count[id]++ } }
/***************************************************************************************** *****************************************************************************************/ kill_trail_task(id) { if (task_exists(TASKID+id)) remove_task(TASKID+id) kill_trail_msg(id) gl_player_colors[id][0] = gl_player_colors[id][1] = gl_player_colors[id][2] = 0 }
/***************************************************************************************** *****************************************************************************************/ kill_trail_msg(id) { gl_timer_count[id] = 0
message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(99) // TE_KILLBEAM write_short(id) message_end() }
/***************************************************************************************** *****************************************************************************************/ trail_msg(id) { message_begin(MSG_BROADCAST, SVC_TEMPENTITY) write_byte(22) // TE_BEAMFOLLOW write_short(id) write_short(gl_trail_type[id]) write_byte(gl_trail_life*10) write_byte(gl_trail_size[id]) write_byte(gl_player_colors[id][0]) write_byte(gl_player_colors[id][1]) write_byte(gl_player_colors[id][2]) write_byte(gl_trail_brightness[id]) message_end()
}
/***************************************************************************************** *****************************************************************************************/ restart_player_trail(id) { if (task_exists(TASKID+id)) { remove_task(TASKID+id) kill_trail_msg(id) get_user_origin(id, gl_player_position[id]) set_task(TICK, "check_position", TASKID+id, "", 0, "b") trail_msg(id) } }
/***************************************************************************************** *****************************************************************************************/ restart_players_trails() { new playercount get_players(gl_players, playercount) for (new i=0; i<playercount; i++) { restart_player_trail(gl_players[i]) } }
/***************************************************************************************** *****************************************************************************************/ say_to_all(msg[], id) { new playercount get_players(gl_players, playercount) for (new i=0; i<playercount; i++) { if (gl_players[i]!=id) client_print(gl_players[i], print_chat, msg) } }
/***************************************************************************************** *****************************************************************************************/ trail_help(id) { new msg[200], clen=0 console_print(id, "^nTrail Colors List:^n") for (new i=0; i<gl_num_colors; i++) { clen += format(msg[clen], 199-clen, "%s ", gl_color_names[i]) if (clen > 80) { console_print(id, msg) copy(msg, 1, "") clen = 0 } } console_print(id, "^nNOTE: All colors can be prefixed by the words 'light' or 'dark'.^n") console_print(id, "^nSay 'trail <color>' to get a colored trail.^nSay 'trail off' to turn trail off.") console_print(id, "Say 'trail <number> [color]' to change the look of the trail.^n") console_print(id, "^nExamples:") console_print(id, " trail") console_print(id, " trail off") console_print(id, " trail tomato") console_print(id, " trail 6 gold") console_print(id, " trail 11 light blue") client_print(id, print_chat, "The colors list has been displayed in your console.") }
/***************************************************************************************** *****************************************************************************************/ bool:parse_file() { new got_line, line_num=0, len=0, parsed new r[3][4], g[3][4], b[3][4] new full_line[MAX_TEXT_LENGTH], rest_line[MAX_TEXT_LENGTH], cfgdir[MAX_TEXT_LENGTH], cfgpath[MAX_TEXT_LENGTH] gl_num_colors = 0 get_configsdir(cfgdir, MAX_TEXT_LENGTH) format(cfgpath, MAX_TEXT_LENGTH, "%s/%s", cfgdir, CFG_FILE) if (!file_exists(cfgpath)) { log_amx("ERROR: Cannot find configuration file '%s'!", cfgpath) return false } got_line = read_file(cfgpath, line_num, full_line, MAX_TEXT_LENGTH, len) if (got_line <=0) { log_amx("ERROR: Cannot read configuration file '%s'!", cfgpath) return false } while (got_line>0) { if (!equal(full_line, "//", 2) && len) { strtok(full_line, gl_color_names[gl_num_colors], MAX_NAME_LENGTH, rest_line, MAX_TEXT_LENGTH, ' ', 1) copy(full_line, MAX_TEXT_LENGTH, rest_line)
parsed = parse(full_line,r[0],3,g[0],3,b[0],3) if (parsed<3) { log_amx("ERROR: Not enough colors, line %d in configuration file '%s'!", 1+line_num, CFG_FILE) return false } gl_colors[gl_num_colors][0] = str_to_num(r[0]) gl_colors[gl_num_colors][1] = str_to_num(g[0]) gl_colors[gl_num_colors][2] = str_to_num(b[0])
gl_num_colors++ if (gl_num_colors>=MAX_COLORS) { log_amx("WARNING: Max colors reached in file '%s'!", CFG_FILE) return true } } line_num++ got_line = read_file(cfgpath, line_num, full_line, MAX_TEXT_LENGTH, len) } return true }
check_map() { new got_line, line_num, len new cfgdir[MAX_TEXT_LENGTH] new cfgpath[MAX_TEXT_LENGTH] new mapname[MAX_NAME_LENGTH] new txt[MAX_TEXT_LENGTH]
get_configsdir(cfgdir, MAX_TEXT_LENGTH-1) get_mapname(mapname, MAX_NAME_LENGTH-1)
format(cfgpath, MAX_TEXT_LENGTH, "%s/sensiblemaps.cfg", cfgdir) if (file_exists(cfgpath)) { got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len) while (got_line>0) { if (equali(txt, mapname)) return 1 line_num++ got_line = read_file(cfgpath, line_num, txt, MAX_TEXT_LENGTH-1, len) } } return 0 }
__________________
We have over 400 skins on weapons and 5 types for hands!
Costumes for players!
New style for Top15 and stats!
Kill marks, molotov!
And many more are waiting for you to play!
Last edited by GaBy96; 11-01-2020 at 05:09.
|
|