[Request] Block Usp Damage
Hello, can a codder give me a basic code which blocks usp to give damage players?
|
Re: [Request] Block Usp Damage
The raw code is too out control to post. It breaks the game. There needs to be balance. Here is some basic code to make the USP only fire blanks and push magnum elites as a counter-measure. It pauses on Gungame and assassinations maps. Warns if using a scope plugin I made is running that is brings back Scope for Colt and works on USP too. The player name code could be added later for those who use Amxx 1.8.2. If using 182 the names will shows as letter n.
CVARS mp_leets 0|1 - replace default pistols with the Dual-Elites with armor piercing damage. mp_usp 0|1 - 0 is off USP is normal. 1 is USP fires blanks. PHP Code:
|
Re: [Request] Block Usp Damage
@DJ, this isn't going to work like you expect it to.
PHP Code:
PHP Code:
PHP Code:
|
Re: [Request] Block Usp Damage
It is functional. Do not see the difference except what you did is more vertical and what I did was horizontal. Yours translates like mine. The only potential problem how it was done is if admin resets rounds a bunch of times there could be some debris from extra elites since I thought it easier to give several instead of make a separate entry for ammo.
|
Re: [Request] Block Usp Damage
Not sure how you do not see the issue. Your version creates 4 DIFFERENT game_player_equip entities. One where you dispatch "item_assaultsuit" keyvalue, another one where you dispatch "weapon_knife" key value, another one where you dispatch "weapon_elite" keyvalue and another one that you actually call spawn on.
Ignore the fact that you wrote everything on one line(which is a bad thing to do btw) and I split it into multiple lines. Look at what is passed inside Dispatch* calls(this is what your code translates to after preprocessing): Code:
DispatchKeyValue( create_entity("game_player_equip"), "item_assaultsuit", "1" ) && DispatchKeyValue( create_entity("game_player_equip"), "weapon_knife", "1" ) && DispatchKeyValue( create_entity("game_player_equip"), "weapon_elite", "5" ) && DispatchSpawn(create_entity("game_player_equip"));#define is a textual replacement. Every single appearance of "ent" inside the sma file is replaced by create_entity(). Define does not create a variable. The code I posted creates only one entity because create_entity() is called only once and saved inside a variable. I suggest you read about #define and the preprocessor. Here, it may appear that it works because the effect is you create 4 entities, but in other causes it could seriously mess up your code and you'll have no clue why. |
Re: [Request] Block Usp Damage
Code:
Code:
Macro or not ent is still create_entity("game_player_equip") new const instead of variable is what I would have chosen. Code:
|
Re: [Request] Block Usp Damage
I feel like I'm talking to a wall, but I'll say it again, ignore the fact that you wrote everything in one line and used && to glue everything together. This isn't about that. If you do not see the difference between calling a native 4 times for literally no benefit vs only doing it once then I don't know what to tell you.
Doing #define ent create_entity("") and new ent = create_entity("") are 2 completely different things. The first one does a textual replacement, changing "ent" in every place inside the code with create_entity(""). If you wanted to create an entity, give it a model, make it solid, it wouldn't work. At every line where you wanted to set those properties, you would be creating a DIFFERENT entity, instead of only one entity with all the needed properties. Your code would end up with multiple ents where each ent has only one of the properties you were trying to set. The second code allocates memory on the stack for 4 bytes of memory. create_entity() return value is placed at that memory location. From now on, inside that function, when you use "ent" you refer to that one entity that was created, which will be the same entity. And static is wrong, it should be new. precache is called only once, you don't need to remember the value between function calls, therefore you do not need a global like variable with local scope. |
Re: [Request] Block Usp Damage
I would have made it new const instead of a variable.
https://cdn.discordapp.com/attachmen...wn_defines.jpg From the Pawn manual. I do know Amxx has it's own nuances since it relates to the GoldSrc HLDS but you were bringing up defines. |
Re: [Request] Block Usp Damage
Static won't even compile! lol I was in the wrong directory from force of habit. I meant new const instead of static. Macros do chump a bit but few maps use this ent and only custom ones at that. So like an array repeats everything in it when applied to a native like giving a weapon in this case, you are illustrating by using this as a macro it is a memory chewer? I would have not used a macro beyond small requests and only this one because do not feel comfortable sharing script flat out disabling the USP silently. Thanks for chiming in. Please help me understand further if this is so. Have any supporting documentation or evidence beyond I said so? I need to see this. I pasted what the manual shows on GitHub today.
Quote:
|
Re: [Request] Block Usp Damage
Quote:
For example: PHP Code:
PHP Code:
PHP Code:
PHP Code:
PHP Code:
Quote:
precache is called only once, you don't need a static variable. You can use it, but you don't need it. Use "new". It isn't a memory chewer. A macro isn't a variable. Macros do text based replacement(find and replace from word or notepad if it helps you visualize). Because of that, they have some quirks and if you aren't aware of how they work, you can end up with horribly hard to debug bugs and wrong code. In which way would it be wrong? It depends: wrong output, wasting memory, crashing, who knows. One thins is for sure: the plugin will not work as expected. Here is an example of such a bug: PHP Code:
PHP Code:
Macros are parsed before the code is actually compiled. They don't make it into the final binary. Macros are not functions. Macros are not variables. |
| All times are GMT -4. The time now is 23:56. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.