View Single Post
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-22-2014 , 11:14   Re: Weapons Model Replacement[ OKAPI ]
Reply With Quote #18

Quote:
Originally Posted by Arkshine View Post
But I don't care you like much your method.
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
__________________
HamletEagle is offline