Raised This Month: $51 Target: $400
 12% 

Solved [ H3LP ] Entity TakeDamage?


Post New Thread Reply   
 
Thread Tools Display Modes
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-23-2017 , 12:15   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #21

Don't use get_maxplayers() at a loop. As I said, it will loop 32 ids even if the server has only 10. The get_playersnum() basically is the same as get_players() does. Both will return player's id when you use it as loop. But get_players() has more parameters: flag, team... while the get_playersnum() hasn't. If you'll loop player's ID with get_playersnum(), will be like this:

PHP Code:
for(new i;get_playersnum();i++)
{
     if(!
is_user_connected(i) && !is_user_alive(i) && !is_user_bot(i) && !is_user_hltv(i) && get_user_team(i) != 2)
       return

While when you'll loop with get_players, you only need this:

PHP Code:
new iPlayers[32], iNumiPlayer
get_players
(iPlayersiNum"acehi""CT")
for(new 
i;iNum;i++)
{
      
iPlayer iPlayers[i]

iPlayer is all player's ID.

https://www.amxmodx.org/api/amxmodx/get_players

Edit: get_playersnum() is not the same as get_players(). I guessed it was, but isn't https://forums.alliedmods.net/showpo...0&postcount=23
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 05-23-2017 at 14:52.
EFFx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-23-2017 , 13:27   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #22

Quote:
or proving that fakemeta_util it is bad
Let's make this one clear: fakemeta_util is not bad just because it's bad. There are few reasons:
1.Some stocks are simple conversions(NOTHING MORE ADDED, JUST A CONVERSION) from module natives. This is slower and useless.
2.Some stocks are just wrappers around already-existing functions(for example #define fm_precache_generic(%1) engfunc(EngFunc_PrecacheGeneric, %1). While this is not wrong, it's just stupid and will create confusions.
3.Some stocks are poor ways of doing something, probably because at the point when fm_util was written there were no better alternatives(as an example see fm_get_weaponbox_type).

Some stocks may be usefull depending on what you are doing(like fm_transfer_user_gun). All comes down to what function is being used from that include.
__________________
HamletEagle is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-23-2017 , 14:02   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #23

Quote:
Originally Posted by EFFx View Post
If you'll loop player's ID with get_playersnum(), will be like this:

PHP Code:
for(new i;get_playersnum();i++)
{
     if(!
is_user_connected(i) && !is_user_alive(i) && !is_user_bot(i) && !is_user_hltv(i) && get_user_team(i) != 2)
       return

This code is fully incorrect. You can't use get_playersnum for player loop. Imagine that there is only 1 player and it has index 32.
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-23-2017 , 14:48   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #24

Yes, that's so incorrect. But my point was to explain that get_players() is better anyway. And I didn't knew that was possible a player get 32 index while he's alone. I guessed it went be 1. I've so much time without play the game. I forgot somethings.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 05-23-2017 , 15:16   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #25

If the others disconnect and he is the 32rd player, then playersnum is 1 and his index is 32.
__________________
HamletEagle is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-23-2017 , 15:32   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #26

There's.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-23-2017 , 15:46   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #27

HamletEagle/EFFx, now I understand, thanks for the explanation, but, why exists since it's incorrectly to use? I don't understand nothing about the logic of amxx dev team. Well, without further ado, the issue has already been solved.

More one thing, then if I need to check if is a valid alive player, or something. This is completly incorrectly?

PHP Code:
#define is_user_valid_alive (1 <= %1 <= get_maxplayers && is_user_alive(%1))

#define is_user_valid_alive (1 <= %1 <= get_playersnum() && is_user_alive(%1)) 
__________________









Last edited by CrazY.; 05-23-2017 at 15:49.
CrazY. is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-23-2017 , 16:04   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #28

Everythings on amxx have one purpose. Nothing is there just for decoration. But about your question:

get_maxplayers() is the correct one. As I said, it returns how much players the server can support. So 1 <= id <= get_maxplayers. It means that the player's id should be between 1 and X, where X is the max players that the server can support. An example: The server's slot is 16, only is possible 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 and 16 IDS. get_maxplayers() will return 16. Then

1 <= ID <= get_maxplayers()
more than or equal to 1 or less than or equal to get_maxplayers() ( 16 ). Only can be possible ids less than 1 or more than get_maxplayers() weapon's ID, entities, etc... Everything that's not player. 'Cuz that some people call that macro as IsPlayer(%1).
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 05-23-2017 at 16:07.
EFFx is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 05-23-2017 , 17:11   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #29

Mmm, well, thanks for the explanation.
__________________








CrazY. is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 05-23-2017 , 17:23   Re: [ H3LP ] Entity TakeDamage?
Reply With Quote #30

Quote:
Originally Posted by CrazY. View Post
why exists since it's incorrectly to use?
It is done for other purposes. For example, for current player count printing:
Code:
server_print("There are %d players on the server", get_playersnum());

Quote:
Originally Posted by CrazY. View Post
PHP Code:
#define is_user_valid_alive (1 <= %1 <= get_maxplayers && is_user_alive(%1))

#define is_user_valid_alive (1 <= %1 <= get_playersnum() && is_user_alive(%1)) 
The first one is the same as is_user_alive. The second is incorrect.

Quote:
Originally Posted by EFFx View Post
weapon's ID
Maybe weapon entities?
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:16.


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