Breaker Punisher
I fixed most problems. Now you need to specify the entities for every map manually. If anyone break these entities you have chosen and there were a player (friend) on it he will be punished.
He who fails to plan is planning to fail
Thanks a lot, It's working perfectly now
raheem can't we make the plugin punish only the breaker himself? becz some teammates will try to make the entity easier to break when zm comes and also if we break on our-self it slays our-self only
LOL
I can block slay if player break it and he was on it, but it can be abused such that the breaker to block his mates he stand on entity and break it so he will not got slay.
Already punishment is for breaker and helpers in 2 seconds and you can reduce cvar to 1 and this is best approach, try it and let me know how it's working.
Already punishment is for breaker and helpers in 2 seconds and you can reduce cvar to 1 and this is best approach, try it and let me know how it's working.
He who fails to plan is planning to fail
its working fine but what about breaking on myself? i get auto killed when i break on myself
LOL
I have idea for this:
If there is no players else this player standing on the breakable entity then we will not slay him.
If there is more than player and he break it and was standing on the entity he will be slayed.
Will find time to implement this.
If there is no players else this player standing on the breakable entity then we will not slay him.
If there is more than player and he break it and was standing on the entity he will be slayed.
Will find time to implement this.
He who fails to plan is planning to fail
-
- Veteran Member
- Posts: 598
- Joined: 7 years ago
- Contact:
Hi,
there is a problem, When Human break on the Zombies, he get slay also?! but this shouldn't happen, I tested, when a zombie drop from something that human broke on him , the human get slayed! what is the solution!? it shouldn't slay human when he try to break in other team! which is (Zombies).
there is a problem, When Human break on the Zombies, he get slay also?! but this shouldn't happen, I tested, when a zombie drop from something that human broke on him , the human get slayed! what is the solution!? it shouldn't slay human when he try to break in other team! which is (Zombies).
Try and confirm that this is working so i update main plugin:
- #include <zombie_escape>
- // Define
- #define ACCESS ADMIN_RCON
- // Variables
- new g_szDamageData[33][41], Float:g_flLastTouched[33], g_iEnt[33],
- g_iMaxPlayers, g_szConfigDir[64], g_szFile[64], g_szDir[64]
- // Cvars
- new g_pCvarDamageTime
- public plugin_init()
- {
- register_plugin("[ZE] Breaker Punisher","1.0","Raheem")
- // Ham
- RegisterHam(Ham_TakeDamage, "func_breakable", "Fw_TakeDamage_Post", 1)
- RegisterHam(Ham_Touch, "func_breakable", "Fw_TouchBreakable_Pre", 0)
- // CVARs
- g_pCvarDamageTime = register_cvar("breaker_damage_time", "2") // If this time passed, damage player make to entity will not be counted and this player won't be punished
- // Commands
- register_clcmd("ze_breakmenu", "BreakableMenu")
- // Constants
- g_iMaxPlayers = get_member_game(m_nMaxPlayers)
- // Get config folder
- get_localinfo("amxx_configsdir", g_szConfigDir, charsmax(g_szConfigDir))
- // Get file path
- new szMapName[64]
- get_mapname(szMapName, charsmax(szMapName))
- formatex(g_szFile, charsmax(g_szFile), "%s/breakables/%s.txt", g_szConfigDir, szMapName)
- formatex(g_szDir, charsmax(g_szDir), "%s/breakables", g_szConfigDir)
- }
- public Fw_TakeDamage_Post(iEnt, iInflictor, iAttacker, Float:flDamage, bitsDamage)
- {
- if (!EntityExists(iEnt))
- return
- // iEnt Damage Time
- formatex(g_szDamageData[iAttacker], charsmax(g_szDamageData[]), "%i %f %f", iEnt, flDamage, get_gametime())
- // In case of breaking we check breakers
- if(get_entvar(iEnt, var_health) <= 0)
- {
- new szEnt[32], szDamage[32], szTime[32]
- for(new id = 1; id <= g_iMaxPlayers; id++)
- {
- if (!is_user_alive(id))
- continue;
- // Check if these users has empty data continue, somehow parse don't work with empty strings so this is important
- trim(g_szDamageData[id])
- if (strlen(g_szDamageData[id]) == 0)
- continue;
- parse(g_szDamageData[id], szEnt, charsmax(szEnt), szDamage, charsmax(szDamage), szTime, charsmax(szTime))
- // This is a friend that did no damage and touching our entity
- if (IsUserToucing(iEnt, id) && str_to_num(szDamage) == 0)
- continue;
- // Make sure the stored entity same as broken one
- if (str_to_num(szEnt) == iEnt)
- {
- // Make sure that time for this is just from 2 seconds (or value from cvar)
- if (str_to_num(szTime) + get_pcvar_num(g_pCvarDamageTime) >= floatround(get_gametime()))
- {
- // There is someone touching it
- if (AnyoneTouching(iEnt, iAttacker))
- {
- // Make sure first player not zombie
- if (!ze_is_user_zombie(id))
- {
- client_print_color(id, print_team_default, "^1[^4Team-Mate^1] ^3You have ^4exploded ^3because you ^4blocked ^3your team-mate(s)^1.")
- ExecuteHamB(Ham_TakeDamage, id, iEnt, iEnt, 99999.0, DMG_GENERIC)
- client_cmd(id, "spk vox/bizwarn")
- }
- }
- }
- }
- }
- }
- }
- public Fw_TouchBreakable_Pre(iEnt, id)
- {
- if (!is_user_connected(id) || ze_is_user_zombie(id))
- return HAM_IGNORED;
- g_flLastTouched[id] = get_gametime()
- g_iEnt[id] = iEnt
- return HAM_IGNORED;
- }
- public BreakableMenu(id)
- {
- // Player have no access?
- if (!(get_user_flags(id) & ACCESS))
- {
- client_print(id, print_console, "You have no access to that command")
- return PLUGIN_HANDLED
- }
- // Create our menu
- new iBreakMenu = menu_create("\yBreakable Menu\w:", "BreakMenuHandler")
- // Add elements
- menu_additem(iBreakMenu, "Add this entity", "", 0)
- // Remove elements
- menu_additem(iBreakMenu, "Remove this entity", "", 0)
- // Set some properties and display the menu
- menu_setprop(iBreakMenu, MPROP_EXIT, MEXIT_ALL);
- menu_display(id, iBreakMenu, 0)
- // Block annoying message in console after writing breakmenu
- return PLUGIN_HANDLED
- }
- public BreakMenuHandler(id, iMenu, iItem)
- {
- // If it's exit, destroy the menu
- if (iItem == MENU_EXIT)
- {
- menu_destroy(iMenu)
- return PLUGIN_HANDLED
- }
- // Variables
- new iEnt, szClassName[32], szModel[32], iFileHandler, iBody, szLine[32]
- // Get the entity index player aiming at
- get_user_aiming(id, iEnt, iBody)
- // Get classname for this entity player aiming at
- get_entvar(iEnt, var_classname, szClassName, charsmax(szClassName))
- // If the classname not ours then show wrong message and reshow menu
- if (!equal(szClassName, "func_breakable"))
- {
- client_print_color(id, print_team_default, "^3Failed^1, ^3you are aiming at wrong entity ^4not func_breakable^1.")
- BreakableMenu(id)
- return PLUGIN_HANDLED
- }
- // It's breakable then get it's model
- get_entvar(iEnt, var_model, szModel, charsmax(szModel))
- switch(iItem)
- {
- case 0:
- {
- // Now we check if breakables folder exist or not, if not create one
- if (!dir_exists(g_szDir))
- {
- mkdir(g_szDir)
- }
- // Now we open file for reading text
- iFileHandler = fopen(g_szFile, "rt")
- // Loop through the whole file to check if this model exist or not
- // Note that feof should be used only if file opened for reading
- // If you opened file for writting and try using feof you will fall in infinite loop
- while(!feof(iFileHandler))
- {
- // Read the line
- fgets(iFileHandler, szLine, charsmax(szLine))
- // Remove any spaces from it's start
- trim(szLine)
- // This line is empty? skip
- if (strlen(szLine) == 0)
- continue;
- // If model already exist then show fail message, and reshow menu
- if (equal(szLine, szModel))
- {
- client_print_color(id, print_team_default, "^3Failed^1, ^3this already exist in the file ^1(^4%s^1) !", szModel)
- BreakableMenu(id)
- // Close the file
- fclose(iFileHandler)
- return PLUGIN_HANDLED
- }
- }
- // Close the file
- fclose(iFileHandler)
- // Open file for appending text, and create if not exist
- iFileHandler = fopen(g_szFile, "at")
- // Append the text to the file
- fputs(iFileHandler, szModel)
- fputs(iFileHandler, "^n")
- // Close file again
- fclose(iFileHandler)
- // Success
- client_print_color(id, print_team_default, "^3Successfully added entity^1: ^4%s ^3to the file^1.", szModel)
- client_cmd(id, "spk buttons/bell1")
- // Reshow menu
- BreakableMenu(id)
- }
- case 1:
- {
- // Folder not exist? so file will exist? lol
- if (!dir_exists(g_szDir))
- {
- client_print_color(id, print_team_default, "^3Failed^1, ^3no text file exist for this map^1!")
- return PLUGIN_HANDLED
- }
- if (!EntityExists(iEnt))
- {
- client_print_color(id, print_team_default, "^3Failed^1, ^3this entity ^1(^4%s^1) ^3not exist in the file to be removed^1!", szModel)
- BreakableMenu(id)
- return PLUGIN_HANDLED
- }
- // Here it's exist so we need to delete it
- DeleteLine(g_szFile, szModel)
- client_print_color(id, print_team_default, "^3Successfully deleted entity^1: ^4%s ^3from the file^1.", szModel)
- client_cmd(id, "spk buttons/bell1")
- BreakableMenu(id)
- }
- }
- return PLUGIN_HANDLED
- }
- /*
- * Stock to check if any player touching specific entity (iEnt) or not
- */
- stock AnyoneTouching(const iEnt, const iAttacker)
- {
- // Check if anyone touch our ent or not
- for(new id = 1; id <= g_iMaxPlayers; id++)
- {
- if (!is_user_alive(id) || !(g_iEnt[id] == iEnt) || id == iAttacker)
- continue;
- if (g_flLastTouched[id] + 0.1 >= get_gametime()) /* For more accurecy lower 0.1 to for example 0.01*/
- {
- return true;
- }
- }
- return false;
- }
- /*
- * Stock to check if specific player (id) is touching specific entity (iEnt)
- */
- stock IsUserToucing(const iEnt, const id)
- {
- // Check if this user touching this ent or not
- if ((g_flLastTouched[id] + 0.1 >= get_gametime()) && (g_iEnt[id] == iEnt)) /* For more accurecy lower 0.1 to for example 0.01*/
- return true
- return false
- }
- /*
- * Check if entity in our file or not
- */
- stock EntityExists(const iEnt)
- {
- new iFileHandler, szModel[32], szLine[32]
- // Now we open file for reading text
- iFileHandler = fopen(g_szFile, "rt")
- // Get model
- get_entvar(iEnt, var_model, szModel, charsmax(szModel))
- while(!feof(iFileHandler))
- {
- // Read the line
- fgets(iFileHandler, szLine, charsmax(szLine))
- // Remove any spaces from it's start
- trim(szLine)
- // This line is empty? skip
- if (strlen(szLine) == 0)
- continue;
- // Exist in the file
- if (equal(szLine, szModel))
- {
- // Close file
- fclose(iFileHandler)
- return true;
- }
- }
- // Close file
- fclose(iFileHandler)
- return false;
- }
- /*
- * My stock to delete line:
- *
- * szFile is the file path.
- * szLine is the line to be deleted.
- */
- stock DeleteLine(const szFile[], const szLine[])
- {
- // Check if file there or not
- if (file_exists(szFile))
- {
- // Some variables
- new Array:szFileLines, szLineToRead[32], iFileHandler
- // Create dynamic array to handle all lines in our file (every line will be in element)
- szFileLines = ArrayCreate(32)
- // Open file for reading text so we can use feof
- iFileHandler = fopen(szFile, "rt")
- while(!feof(iFileHandler))
- {
- // Read line by line
- fgets(iFileHandler, szLineToRead, charsmax(szLineToRead))
- // Remove any spaces at start
- trim(szLineToRead)
- // If this is our line we need to delete, skip it
- if (equal(szLineToRead, szLine))
- continue
- // Push all lines to our array except one we need to delete
- ArrayPushString(szFileLines, szLineToRead)
- }
- // Close the file
- fclose(iFileHandler)
- // Delete the file - using delete_file native will cause problems, so i use this way
- iFileHandler = fopen(szFile, "wt")
- fclose(iFileHandler)
- /* We may use here the new system */
- // Now we open file for appending text
- iFileHandler = fopen(g_szFile, "at")
- // Recreate the file and print all data to it
- for (new iLine = 0; iLine < ArraySize(szFileLines) - 1; iLine++)
- {
- // Get strings in our array
- ArrayGetString(szFileLines, iLine, szLineToRead, charsmax(szLineToRead))
- // Write them to our file
- fputs(iFileHandler, szLineToRead)
- fputs(iFileHandler, "^n")
- }
- // Close file
- fclose(iFileHandler)
- // Destroy this array and free it's memory
- ArrayDestroy(szFileLines)
- }
- }
He who fails to plan is planning to fail
-
- Veteran Member
- Posts: 598
- Joined: 7 years ago
- Contact:
Working for me, try again and make sure you updated the plugin.
He who fails to plan is planning to fail
-
- Veteran Member
- Posts: 598
- Joined: 7 years ago
- Contact:
Why things work for you in second test
He who fails to plan is planning to fail
-
- Veteran Member
- Posts: 598
- Joined: 7 years ago
- Contact:
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute
Sign in
Who is online
Users browsing this forum: No registered users and 1 guest