AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   About Code (https://forums.alliedmods.net/showthread.php?t=179151)

kevin14144 02-26-2012 11:20

About Code
 
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 ) ?

Jheshka 02-26-2012 11:21

Re: About Code
 
|| represents OR

So if either condition is met.

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

Bugsy 02-26-2012 11:21

Re: About Code
 
Quote:

Originally Posted by kevin14144 (Post 1657866)
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.

kevin14144 02-26-2012 11:32

Re: About Code
 
Quote:

Originally Posted by Bugsy (Post 1657869)
|| 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.

Bugsy 02-26-2012 11:35

Re: About Code
 
Quote:

Originally Posted by kevin14144 (Post 1657875)
If player is dead.
How to get item (TouchWeapon) ?

He can't, and the plugin lets the game engine handle it instead of interfering.

kevin14144 02-26-2012 11:41

Re: About Code
 
Quote:

Originally Posted by Bugsy (Post 1657878)
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 ?

Bugsy 02-26-2012 11:44

Re: About Code
 
Quote:

Originally Posted by kevin14144 (Post 1657883)
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.

kevin14144 02-26-2012 11:56

Re: About Code
 
Quote:

Originally Posted by Bugsy (Post 1657888)
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

Bugsy 02-26-2012 12:08

Re: About Code
 
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.

kevin14144 02-26-2012 12:14

Re: About Code
 
Quote:

Originally Posted by Bugsy (Post 1657899)
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))


All times are GMT -4. The time now is 09:28.

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