AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Approved Plugins (https://forums.alliedmods.net/forumdisplay.php?f=8)
-   -   Deathrun: CTSafe buttons (prevent CTs from activating traps) (https://forums.alliedmods.net/showthread.php?t=283308)

OciXCrom 05-30-2016 15:34

Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
7 Attachment(s)
https://raw.githubusercontent.com/Oc...er/version.png

Deathrun: CTSafe buttons (prevent CTs from activating traps)

Description
  • This plugin prevents the Counter-Terrorists from activating traps after they finish the map or traps that can be activated through thin walls, bugs on the map etc. By default, CT players are unable to press any buttons on the map, but you can enable them to do so on specific ones, by holding down the "R" button and pressing "G" while at the same time looking at the button. On some maps the button is inside a wall, so in such cases you can hold down "R" and press the button with "E". This is needed for maps that have buttons who must be pressed by CTs in order to continue playing. The files are saved in data/CTSafeButtons/mapname.txt.



Translations
  • English: by me (OciXCrom)
  • Macedonian: by me (OciXCrom)
  • Bulgarian: by Unbr3akable
  • Romanian: by HamletEagle
  • Spanish: by ACM1PT
  • Brazil Portuguese: by EFFx
  • Hungarian: by RaZ_HU


https://raw.githubusercontent.com/Oc...using_this.png
https://raw.githubusercontent.com/Oc...plugin_lab.png
https://raw.githubusercontent.com/Oc...ad_default.png

ComedyShotsGamer 05-31-2016 10:53

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
Wow

siriusmd99 07-05-2016 09:18

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
I can give you some suggestions:
1. Use button id instead of model
2. Save buttons to one file

You can look into this post:

https://forums.alliedmods.net/showth...16#post2433716

It works with button id , why you use model?

Look:

PHP Code:

if(pev_valid(iEnt) && pev(iEntpev_iuser2) == MARKED_BUTTON)
{
    
pev(iEntpev_modelszModelcharsmax(szModel))
    
fprintf(iFilePointer"%s %s %d^n"g_szButtons[i], szModeliEnt)
    
iCount++


:arrow:

PHP Code:

if(pev_valid(iEnt) && pev(iEntpev_iuser2) == MARKED_BUTTON)
{
    
fprintf(iFilePointer"%s %d^n"g_szButtons[i],  iEnt// button class and button's id , why to save by model if you can simply add iEnt ,which is button id?
    
iCount++



OciXCrom 07-05-2016 10:31

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
I used xPaw's method in this plugin. It saves it by model. Is there actually a difference? If it's better, I'll remake it with id.

I prefer saving them in different files because it's much easier to transfer files from one server to another instead of adding lines in a single file. I'm talking about when you need to make a small change to a button on a map, not transfering all of them at once.

safetymoose 07-05-2016 10:55

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
IMO using the model works better, xPaw knows his stuff. It's better to use different files because you can customize them for each map and it's easier to find the map file, rather than searching a big file for the correct line. Also, way more readable and organized.

HamletEagle 07-05-2016 11:31

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
Using entity id is totally unreliable, because if another entity is spawned it could break the code(since index will be changed). Also using multiple files is more organized, so don't change.

PHP Code:

new g_szDirectory[512], g_szFilename[512

Way too much, 256 would be just enough.

PHP Code:

new iEnt find_ent_by_model(-1szClassszModel

Create iEnt var before looping.

PHP Code:

fclose(iFilePointer

should be inside if(iFilePointer) check.

Since pev_mins and pev_maxs give you float values use EngFunc_WriteCoord instead of converting float to int.

OciXCrom 07-05-2016 11:36

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
Thanks for the advices. I'm keeping it this way then.

Everything else is fixed and code is updated.

HamletEagle 07-05-2016 13:08

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
Also check if iFilePointer is non 0 in case 1.

I don't like that all configurations are hardcoded, but they don't look like things that one would like to change, so I guess it's fine.

OciXCrom 07-05-2016 13:27

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
Done.

I made the configurations that way because I don't think it's necessary stuff like that to be changed. It would be rather dumb to make cvars for them. Like you said - I don't think someone would like to change them. Hope it's not a problem.

HamletEagle 07-05-2016 14:08

Re: Deathrun: CTSafe buttons (prevent CTs from activating traps)
 
Remove iCount var from fileRead, it does nothing.
Again, wrong use of ML system. To print in player language, use player id instead of LANG_PLAYER.


All times are GMT -4. The time now is 04:42.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.