This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Max player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Process
Junior Member
Join Date: Jan 2015
Location: Banned
Old 01-03-2015 , 05:45   Max player
Reply With Quote #1

Hello,

today I found a code but I did not understand well a part of the script ,

Code:
/* Plugin generated by AMXX-Studio */ #include <  amxmodx  > #include <  hamsandwich  > #define PLUGIN "Modificare Damage" #define VERSION "0.1" #define AUTHOR "hadesownage" #define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers ) new g_iMaxPlayers; public plugin_init ( ) {         register_plugin ( PLUGIN, VERSION, AUTHOR );         g_iMaxPlayers = get_maxplayers ( )     RegisterHam ( Ham_TakeDamage, "player", "Player_TakeDamage" ); } public Player_TakeDamage ( iVictim, iInflictor, iAttacker, Float:fDamage ) {         if ( iInflictor == iAttacker && IsPlayer ( iAttacker ) ) {             SetHamParamFloat ( 4, fDamage * 2.0 );         return HAM_HANDLED;             }         return HAM_IGNORED;     }

this is what i didn't understand

Code:
#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

why its %0 can i replace it with 1 and what is <= and get_maxplayers is it take the max player from server or what !



I'm still learning ...
Process is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-03-2015 , 06:59   Re: Max player
Reply With Quote #2

What you see is called a macro. %0, %1, up to %9. are just arguments you pass.
A macro is replaced at compilation time.

For example, if you have IsPlayer(iAttacker) in your code, it will be replaced at compilation with 1 <= iAttacker <= g_iMaxPlayers
%0 is just a way to say that macro takes one argument.
__________________

Last edited by Arkshine; 01-03-2015 at 07:02.
Arkshine is offline
Process
Junior Member
Join Date: Jan 2015
Location: Banned
Old 01-03-2015 , 07:09   Re: Max player
Reply With Quote #3

Yes i understand the replace of the 'Macro' , i've already read a 'tuto'

the actually define what is it , why we need a maxplayers in this define ! ?
Process is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-03-2015 , 07:15   Re: Max player
Reply With Quote #4

To check whether index is actually a player. If index is between 1 and maxclients (maxclients being the current server max slots), then it's a player. If your server has 16 slots, a player's index can't be 17.

It's just a fast way to filter between players and others entities. You can take damage from something other than a player. The code will work only if attacker is a player.
__________________

Last edited by Arkshine; 01-03-2015 at 07:17.
Arkshine is offline
Process
Junior Member
Join Date: Jan 2015
Location: Banned
Old 01-03-2015 , 07:25   Re: Max player
Reply With Quote #5

Really thanks dude ^^'
Process is offline
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 01-03-2015 , 07:31   Re: Max player
Reply With Quote #6

1 return if is a less than or equal a attacker and the attacker return if is a less than or equal a maxplayers

and

for an example :

switch (a)
{
case 0 .. 50:
{
//This code will run if 0 <= a <= 50
// which is From 0 to 49
}

so

('THIS IS WRONG ITS JUST A EXAMPLE')
switch (attacker){
case 1..maxplayers
//1 <= attacker <= maxplayers
// from 1 to maxplayers if maxplayers = 16 then from 1 to 15
}


maybe this is a easy way to unders...
Freezo Begin is offline
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 11:12.


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