AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   call function on death, once per map (https://forums.alliedmods.net/showthread.php?t=140153)

SCHWEDEN 10-09-2010 09:26

call function on death, once per map
 
PHP Code:

public hook_DeathMsg()
{
    new 
iVictim read_data(2);
    
functionHere(iVictim);


I do this to call a function/method on iVictim everytime he dies, but I want it only to happen once per map, not every death.

How would I go about doing that? I think I need some kind of counter right?

alan_el_more 10-09-2010 09:36

Re: call function on death, once per map
 
Example:
PHP Code:

new gVariable33 ]

public 
hook_DeathMsg()
{
    new 
iVictim read_data(2);
    if( !
gVariableiVictim ] )
    {
         
functionHere(iVictim);
         
gVariableiVictim ] = true
    
}



shuttle_wave 10-09-2010 09:38

Re: call function on death, once per map
 
Quote:

Originally Posted by alan_el_more (Post 1320020)
Example:
PHP Code:

new gVariable33 ]

public 
hook_DeathMsg()
{
    new 
iVictim read_data(2);
    if( !
gVariableiVictim ] )
    {
         
functionHere(iVictim);
         
gVariableiVictim ] = true
    
}



y not use a boolen?

SCHWEDEN 10-10-2010 12:57

Re: call function on death, once per map
 
Quote:

Originally Posted by shuttle_wave (Post 1320026)
y not use a boolen?

How do you mean?

fysiks 10-10-2010 16:42

Re: call function on death, once per map
 
Quote:

Originally Posted by SCHWEDEN (Post 1321275)
How do you mean?

Not entirely sure what he means but it might be this:

PHP Code:

new bool:gVariable33 

public 
hook_DeathMsg() 

    new 
iVictim read_data(2); 
    if( !
gVariableiVictim ] ) 
    { 
         
functionHere(iVictim); 
         
gVariableiVictim ] = true 
    




SCHWEDEN 10-10-2010 16:43

Re: call function on death, once per map
 
Quote:

Originally Posted by fysiks (Post 1321497)
Not entirely sure what he means but it might be this:

PHP Code:

new bool:gVariable33 

public 
hook_DeathMsg() 

    new 
iVictim read_data(2); 
    if( !
gVariableiVictim ] ) 
    { 
         
functionHere(iVictim); 
         
gVariableiVictim ] = true 
    




Which method is the correct one?

fysiks 10-10-2010 16:44

Re: call function on death, once per map
 
Quote:

Originally Posted by SCHWEDEN (Post 1321501)
Which method is the correct one?

Both will work the same. Mine is technically the most correct form.

SCHWEDEN 10-10-2010 18:26

Re: call function on death, once per map
 
Worked great (Y) fysiks

Mxnn 10-10-2010 22:49

Re: call function on death, once per map
 
You have to clear the var when the user disconnects (for fysiks's plugin)

fysiks 10-11-2010 00:22

Re: call function on death, once per map
 
Quote:

Originally Posted by Mxnn (Post 1321707)
You have to clear the var when the user disconnects (for fysiks's plugin)

It's not my code btw, I just added "bool:". Don't blame me for the code lol :).


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

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