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

About Code


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kevin14144
Member
Join Date: Jul 2007
Old 02-26-2012 , 11:20   About Code
Reply With Quote #1

This code is form Hide_N_Seek.sma.

Code:
public fwdTouchWeapon( iEntity, id )
{
 if( !g_bAlive[ id ] || get_pcvar_num( g_pPickup ) )
 {
  return HAM_IGNORED;
 }
 
 return HAM_SUPERCEDE;
}

Code:
if( !g_bAlive[ id ] || get_pcvar_num( g_pPickup ) )
what's mean?

So the player not alive , it will go next.

why use get_pcvar_num( g_pPickup ) ?

Last edited by kevin14144; 02-26-2012 at 11:30.
kevin14144 is offline
Jheshka
Senior Member
Join Date: Dec 2005
Old 02-26-2012 , 11:21   Re: About Code
Reply With Quote #2

|| represents OR

So if either condition is met.

As opposed to && which represents AND.
So both conditions would need to be met.
__________________
James

Last edited by Jheshka; 02-26-2012 at 11:22.
Jheshka is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-26-2012 , 11:21   Re: About Code
Reply With Quote #3

Quote:
Originally Posted by kevin14144 View Post
This code is form Hide_N_Seek.sma.

Code:
public fwdTouchWeapon( iEntity, id )
{
 if( !g_bAlive[ id ] || get_pcvar_num( g_pPickup ) )
 {
  return HAM_IGNORED;
 }
 
 return HAM_SUPERCEDE;
}

Code:
if( !g_bAlive[ id ] || get_pcvar_num( g_pPickup ) )
what's "||" mean?

One condition is true ,so it will go next ?
|| is logical Or

If the player is dead (not alive) or the cvar pickup is true then let the hook call normally. Otherwise, block (supercede) touch.
__________________
Bugsy is offline
kevin14144
Member
Join Date: Jul 2007
Old 02-26-2012 , 11:32   Re: About Code
Reply With Quote #4

Quote:
Originally Posted by Bugsy View Post
|| is logical Or

If the player is dead (not alive) or the cvar pickup is true then let the hook call normally. Otherwise, block (supercede) touch.
Code:
 
public client_disconnect(id)
{
g_bAlive[ id ] = false
....
..
}
public eventDeathMsg()
{
g_bAlive[ iVictim ] = false
...
...
}
 
public fwdPlayerSpawn( id )
{
 
....
...
g_bAlive[ id ] = true;
}
Sorry , i don't give you more information.

Last edited by kevin14144; 02-26-2012 at 11:37.
kevin14144 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-26-2012 , 11:35   Re: About Code
Reply With Quote #5

Quote:
Originally Posted by kevin14144 View Post
If player is dead.
How to get item (TouchWeapon) ?
He can't, and the plugin lets the game engine handle it instead of interfering.
__________________
Bugsy is offline
kevin14144
Member
Join Date: Jul 2007
Old 02-26-2012 , 11:41   Re: About Code
Reply With Quote #6

Quote:
Originally Posted by Bugsy View Post
He can't, and the plugin lets the game engine handle it instead of interfering.
So, dead player and the cvar "g_pPickup=1" are the same ?
kevin14144 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-26-2012 , 11:44   Re: About Code
Reply With Quote #7

Quote:
Originally Posted by kevin14144 View Post
So, dead player and the cvar "g_pPickup=1" are the same ?
g_bAlive[ id ] is a boolean variable which holds a value for whether or not the player is dead or alive, same as is_user_alive().

get_pcvar_num( g_pPickup ) is the value of a cvar for, I'm assuming, if a user is able to pickup weapons.
__________________
Bugsy is offline
kevin14144
Member
Join Date: Jul 2007
Old 02-26-2012 , 11:56   Re: About Code
Reply With Quote #8

Quote:
Originally Posted by Bugsy View Post
g_bAlive[ id ] is a boolean variable which holds a value for whether or not the player is dead or alive, same as is_user_alive().

get_pcvar_num( g_pPickup ) is the value of a cvar for, I'm assuming, if a user is able to pickup weapons.
Why determine the player alive or dead ?

If the player is alive and the cvar is equal to 0. How it will be? Can the player pick up weapon ?


File Link: http://forums.alliedmods.net/showthread.php?p=643707

Last edited by kevin14144; 02-26-2012 at 12:07.
kevin14144 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-26-2012 , 12:08   Re: About Code
Reply With Quote #9

Because, if he is dead then he cannot pickup a weapon so the plugin allows the game engine to handle it.

If he is alive and cvar is 0 then the plugin blocks him from picking up the weapon.
__________________
Bugsy is offline
kevin14144
Member
Join Date: Jul 2007
Old 02-26-2012 , 12:14   Re: About Code
Reply With Quote #10

Quote:
Originally Posted by Bugsy View Post
Because, if he is dead then he cannot pickup a weapon so the plugin allows the game engine to handle it.

If he is alive and cvar is 0 then the plugin blocks him from picking up the weapon.
So , is the "g_bAlive[ id ]" a condition or not ?

Why don't use

Code:
 if(get_pcvar_num( g_pPickup))

Last edited by kevin14144; 02-26-2012 at 12:15.
kevin14144 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 19:58.


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