AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   New Plugin Submissions (https://forums.alliedmods.net/forumdisplay.php?f=26)
-   -   Entity Resources Replacement[ V 1.4 ] (https://forums.alliedmods.net/showthread.php?t=250244)

Jhob94 10-21-2014 10:49

Re: Weapons Model Replacement[ OKAPI ]
 
Well, when you have your definitive final version, you should request an approver/moderator to add everything to zip file including amxx for make the job easier to who doesn't knows how to compile localy.
And nice that you added sounds support :)

HamletEagle 10-21-2014 10:52

Re: Weapons Model Replacement[ OKAPI ]
 
Quote:

Originally Posted by Jhob94 (Post 2213988)
Well, when you have your definitive final version, you should request an approver/moderator to add everything to zip file including amxx for make the job easier to who doesn't knows how to compile localy.
And nice that you added sounds support :)

Thx for your advice, I will do it.

Arkshine 10-21-2014 13:03

Re: Weapons Model Replacement[ OKAPI ]
 
I don't have much to say for now, but I think you should review your "Usage" section. It's confusing and kind of unreadable.

Like for example:
- you say in 1. to create a file, but you provide already a config file.
- The config file should contain a dummy example with explanations.
- Make sure to warn about not using mp3 sounds.
- Make sure to emphasis about the length restriction.
- Make sure to emphasis about putting the map name.
- Your example should follow your current config file syntax, and you should not hesitate to use [code] bbcode.
- No need to duplicate 2 times your examples
- Basically rewrite the whole section \o/.

HamletEagle 10-21-2014 13:15

Re: Weapons Model Replacement[ OKAPI ]
 
Ok, this is for the topic, about the code do you spot some problems ? Yeah, I will rewrite it.

Edit: done, new file uploaded.

Arkshine 10-21-2014 13:50

Re: Weapons Model Replacement[ OKAPI ]
 
Code as it is seems ok.

Though you can always improve a bit:
  • If g_arraySize is empty, you could already destroy the Array and not calling patchMemory.
  • Put some comment about what does the plugin and cvar. Best practice would be an admin doesn't need to check the first post of the plugin thread to know how about what plugin does/how to config/how to insall etc.
  • I think you should check the string size in plugin and warn about it (meaning ignoring it in case new size > original one + log_amx for example).
  • Increase buffer for get_configsdir ; remember that's something that any admin could change in core.ini. 32 might a bit short.
  • I'm not sure to like how you parse the section in your config file. For safety, you should explicitly check for section name. Even better, you don't need section at all, there is no reason to separate like that, you can always do that with comments and in your code, just a matter to check extension for example. Less prone to user's error.

HamletEagle 10-21-2014 14:07

Re: Weapons Model Replacement[ OKAPI ]
 
I like too much my parsing method and if a user simply fallow the instructions he can't be wrong :D
Everything else updated.

Arkshine 10-21-2014 15:20

Re: Weapons Model Replacement[ OKAPI ]
 
But I don't care you like much your method. :twisted:
You should also be aware that you can be sure user won't follow instructions. Never trust user. A gold rule. This is not a joke.

When you think again, more things:
  • You must check if file exists before and warn about it if not (optional but welcomed). This means you will have to deal with "sound/" because you need the full path with file_exists, and best would be probably to force user to prepend sound/, then in the code just a matter to do string[6] to ignore it. You can do the reverse too.
  • Actually you don't need to precache. Since you're using a way to replace directly in memory, this means, file will be precached properly by the game. No need to duplicate this. At the end, this makes your section totally pointless since you're using that only for precache. That's simplify your code.

Since I'm a evil bastard, the last point should make you realize your plugin is no more about only Weapon Model anymore but a generic memory replacer for entity's resources. That's it, your plugin can replace any sounds/models/sprites that the game precaches. You should rename your plugin to something else. Don't tell me you want to keep only for weapons, it would not make sense at all since your plugin would already allows that \o/, and it's better to be generic so your plugin has more chance to be used for more things.

If you are a masochist, you could take the thing a bit further, like config file allows to replace any string (so not a file, your have already the code ready).
If you are a masochist, you could add some parameter in config file to replace any string in the engine library as well.

HamletEagle 10-22-2014 11:14

Re: Weapons Model Replacement[ OKAPI ]
 
Quote:

Originally Posted by Arkshine (Post 2214125)
But I don't care you like much your method. :twisted:
You should also be aware that you can be sure user won't follow instructions. Never trust user. A gold rule. This is not a joke.

When you think again, more things:
  • You must check if file exists before and warn about it if not (optional but welcomed). This means you will have to deal with "sound/" because you need the full path with file_exists, and best would be probably to force user to prepend sound/, then in the code just a matter to do string[6] to ignore it. You can do the reverse too.
  • Actually you don't need to precache. Since you're using a way to replace directly in memory, this means, file will be precached properly by the game. No need to duplicate this. At the end, this makes your section totally pointless since you're using that only for precache. That's simplify your code.

Since I'm a evil bastard, the last point should make you realize your plugin is no more about only Weapon Model anymore but a generic memory replacer for entity's resources. That's it, your plugin can replace any sounds/models/sprites that the game precaches. You should rename your plugin to something else. Don't tell me you want to keep only for weapons, it would not make sense at all since your plugin would already allows that \o/, and it's better to be generic so your plugin has more chance to be used for more things.

If you are a masochist, you could take the thing a bit further, like config file allows to replace any string (so not a file, your have already the code ready).
If you are a masochist, you could add some parameter in config file to replace any string in the engine library as well.

Now it has suport for sprites, sounds and weapons :D

Arkshine 10-22-2014 11:33

Re: Weapons Resources Replacement[ OKAPI ]
 
You did not rename your plugin. What plugin does is not related to weapon specifically anymore, but to entities more generally. An entity can be a weapon, an item, or anything else like func_*, env_* etc. Such entities precaches resources as well (just look at HLSDK.

HamletEagle 10-22-2014 11:51

Re: Weapons Resources Replacement[ OKAPI ]
 
Quote:

Originally Posted by Arkshine (Post 2214472)
You did not rename your plugin. What plugin does is not related to weapon specifically anymore, but to entities more generally. An entity can be a weapon, an item, or anything else like func_*, env_* etc. Such entities precaches resources as well (just look at HLSDK.

You forgot to close ) :twisted:
Check the code, forget the name, it can be easely changed :P I'm sure you still have a lot of suggestions.


All times are GMT -4. The time now is 06:59.

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