AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Autorepare Dmg (https://forums.alliedmods.net/showthread.php?t=87029)

One 03-05-2009 18:39

Autorepare Dmg
 
Hi,

im writing a new plug-in & want to add autorepare dmg to races...

example : race 1 has autorepare every sec. +2 HP

race 2 every sec. +5HP & ...

so i need the code & how can i add this to races?

so how i know, i cant have the same code in 1 plugin. :cry:

anakin_cstrike 03-06-2009 09:08

Re: Autorepare Dmg
 
Switch classes and check them. Assign a variable to 2.0 for example if the race is 1. The simplistic way is creating a task every 2.0 seconds and adding health to the player.

One 03-06-2009 09:26

Re: Autorepare Dmg
 
Quote:

Originally Posted by anakin_cstrike (Post 775100)
Switch classes and check them. Assign a variable to 2.0 for example if the race is 1. The simplistic way is creating a task every 2.0 seconds and adding health to the player.

TY,

could u give me 1 example?

anakin_cstrike 03-06-2009 09:53

Re: Autorepare Dmg
 
Something like this
PHP Code:

public funcid )
{
new 
Float:interval;
switch( 
g_classid ] )
{
case 
1interval 2.0;
case 
2interval 4.0;
case 
3interval 5.0;
}

set_taskinterval"addhp"id+123__"b" );
}

public 
addhpindex )
{
index -= 123;
new 
hp get_user_healthindex );
if( 
hp >= 100 )
{
set_user_healthindex100 );
remove_taskindex );
return 
1;
}

set_user_healthindexhp+1);
return 
0;



One 03-10-2009 04:01

Re: Autorepare Dmg
 
Ty anakin.so how can i add this to this code? :mrgreen:

PHP Code:

public characters_menu(idkeys)
{
    switch(
keys
    {
        case 
0:  
        { 
            
fm_strip_user_weapons(id);
            
fm_give_item(id"weapon_knife");
            
fm_give_item(id"weapon_m4a1");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"weapon_hegrenade");
            
fm_give_item(id"weapon_glock18");

            
fm_set_user_health(idget_pcvar_num(DOD_RifflemanHP));
            
fm_set_user_armor(idget_pcvar_num(DOD_RifllemanAR));
            
fm_set_rendering(idkRenderFxGlowShell01000kRenderNormal170);
    
        }
        case 
1:
        {
            
fm_strip_user_weapons(id);
            
fm_give_item(id"weapon_knife");
            
fm_give_item(id"weapon_galil");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato"); 
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"weapon_smokegrenade");
            
fm_give_item(id"weapon_hegrenade");
            
fm_give_item(id"weapon_usp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
    
            
fm_set_user_health(idget_pcvar_num(DOD_AssaultHP));
            
fm_set_user_armor(idget_pcvar_num(DOD_AssaultAR));
            
fm_set_rendering(idkRenderFxGlowShell02550kRenderNormal170);
        
        }

        case 
2:
        {
            
            
user_kill(id);
            
color_print(id"^x04You have died because you didn't select any class!");
            
fm_set_rendering(idkRenderFxGlowShell000kRenderNormal255);

            return 
0;
        }
    }
    return 
0;



iNspiratioN 03-10-2009 09:08

Re: Autorepare Dmg
 
Quote:

Originally Posted by One (Post 774770)
Hi,

im writing a new plug-in & want to add autorepare dmg to races...

example : race 1 has autorepare every sec. +2 HP

race 2 every sec. +5HP & ...

so i need the code & how can i add this to races?

so how i know, i cant have the same code in 1 plugin. :cry:

->
PHP Code:

#define TASK_REPARE 999

public autorepare(id)
{
    if ( 
id TASK_REPARE )
        
id -= TASK_REPARE ;
    
    if ( !
is_user_alive(id) )
        return ;
    
    
set_user_healthidget_user_health(id) +)        


and then add -> set_task( 1.0,"autorepare", TASK_REPARE+id )
--------------------------------------
PHP Code:

#define TASK_REPARE 999

public autorepare(id)
{
    if ( 
id TASK_REPARE )
        
id -= TASK_REPARE ;
    
    if ( !
is_user_alive(id) )
        return ;
    
    
set_user_healthidget_user_health(id) +
}

public 
characters_menu(idkeys)
{
    switch(
keys)
    {
        case 
0:  
        {
            
fm_strip_user_weapons(id);
            
fm_give_item(id"weapon_knife");
            
fm_give_item(id"weapon_m4a1");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"weapon_hegrenade");
            
fm_give_item(id"weapon_glock18");
            
            
fm_set_user_health(idget_pcvar_num(DOD_RifflemanHP));
            
fm_set_user_armor(idget_pcvar_num(DOD_RifllemanAR));
            
fm_set_rendering(idkRenderFxGlowShell01000kRenderNormal170);
            
set_task1.0,"autorepare"TASK_REPARE+id )
        }
        case 
1:
        {
            
fm_strip_user_weapons(id);
            
fm_give_item(id"weapon_knife");
            
fm_give_item(id"weapon_galil");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"weapon_smokegrenade");
            
fm_give_item(id"weapon_hegrenade");
            
fm_give_item(id"weapon_usp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
fm_give_item(id"ammo_45acp");
            
            
            
fm_set_user_health(idget_pcvar_num(DOD_AssaultHP));
            
fm_set_user_armor(idget_pcvar_num(DOD_AssaultAR));
            
fm_set_rendering(idkRenderFxGlowShell02550kRenderNormal170);
            
set_task1.0,"autorepare"TASK_REPARE+id )
        }
        
        case 
2:
        {
            
            
user_kill(id);
            
color_print(id"^x04You have died because you didn't select any class!");
            
fm_set_rendering(idkRenderFxGlowShell000kRenderNormal255);
            
set_task1.0,"autorepare"TASK_REPARE+id )
            return 
0;
        }
    }
    return 
0;


Maybe that helped :)

One 03-10-2009 09:15

Re: Autorepare Dmg
 
Ok, ty . thats very nice, no error & looks good. anyway i have to test first. ill test when im @ home. however a new problem :

Case 0 has autorepare :

PHP Code:

        case 0:  
        { 
            
fm_strip_user_weapons(id);
            
fm_give_item(id"weapon_knife");
            
fm_give_item(id"weapon_m4a1");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"weapon_hegrenade");
            
fm_give_item(id"weapon_glock18");
            
fm_set_user_maxspeedid265.0 ); 
            
get_user_footsteps(1);            ///Must be checked.if not work, delete + fun.inc
            
new Float:gravity get_cvar_float("amxx_gravity");
            
gravity *= 0.8
            set_user_gravity
(idgravity)  
            
fm_set_user_health(idget_pcvar_num(DOD_RifflemanHP));
            
fm_set_user_armor(idget_pcvar_num(DOD_RifllemanAR));
            
set_task1.0,"autorepare"TASK_REPARE+id 

how can i give case 1 autorepare too but this should be repared every sec. +1 HP & not 2HP

iNspiratioN 03-10-2009 14:15

Re: Autorepare Dmg
 
Quote:

Originally Posted by One (Post 777677)
Ok, ty . thats very nice, no error & looks good. anyway i have to test first. ill test when im @ home. however a new problem :

Case 0 has autorepare :

PHP Code:

        case 0:  
        { 
            
fm_strip_user_weapons(id);
            
fm_give_item(id"weapon_knife");
            
fm_give_item(id"weapon_m4a1");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"ammo_556nato");
            
fm_give_item(id"weapon_hegrenade");
            
fm_give_item(id"weapon_glock18");
            
fm_set_user_maxspeedid265.0 ); 
            
get_user_footsteps(1);            ///Must be checked.if not work, delete + fun.inc
            
new Float:gravity get_cvar_float("amxx_gravity");
            
gravity *= 0.8
            set_user_gravity
(idgravity)  
            
fm_set_user_health(idget_pcvar_num(DOD_RifflemanHP));
            
fm_set_user_armor(idget_pcvar_num(DOD_RifllemanAR));
            
set_task1.0,"autorepare"TASK_REPARE+id 

how can i give case 1 autorepare too but this should be repared every sec. +1 HP & not 2HP

Simply change
Quote:

set_user_health( id, get_user_health(id) +2 )
to
Quote:

set_user_health( id, get_user_health(id) +1 )
{To change HEALTH}

+number to give health :)

PHP Code:

#define TASK_REPARE2 999

public autorepare2(id)
{
    if ( 
id TASK_REPARE2 )
        
id -= TASK_REPARE2;
    
    if ( !
is_user_alive(id) )
        return ;
    
set_user_healthidget_user_health(id) +)


Then add in case1 -> set_task( 1.0,"autorepare2", TASK_REPARE2+id )

I think like this... post here if you will get error from this.

One 03-10-2009 14:20

Re: Autorepare Dmg
 
Quote:

Originally Posted by iNspiratioN (Post 777903)
Simply change (+2) -> (+1) {To change HEALTH}

PHP Code:

#define TASK_REPARE2 999

public autorepare2(id)
{
    if ( 
id TASK_REPARE2 )
        
id -= TASK_REPARE2;
    
    if ( !
is_user_alive(id) )
        return ;
    
set_user_healthidget_user_health(id) +)


Then set_task( 1.0,"autorepare2", TASK_REPARE2+id )

I think like this... post here if you will get error at this.

lol. but i cant have 2 time this here :

PHP Code:

public autorepare(id

    if ( 
id TASK_REPARE 
        
id -= TASK_REPARE 
     
    if ( !
is_user_alive(id) ) 
        return ; 
     
set_user_healthidget_user_health(id) +


PHP Code:

public autorepare(id

    if ( 
id TASK_REPARE 
        
id -= TASK_REPARE 
     
    if ( !
is_user_alive(id) ) 
        return ; 
     
set_user_healthidget_user_health(id) +


Example :
race 1 become +2
race 2 become +3
race 4 become +5

or is it poss. that i try this so :
PHP Code:

public autorepare(id

    if ( 
id TASK_REPARE 
        
id -= TASK_REPARE 
     
    if ( !
is_user_alive(id) ) 
        return ; 
     
set_user_healthidget_user_health(id) +


PHP Code:

set_task1.0,"autorepare2"TASK_REPARE2+id+id+id+id 


iNspiratioN 03-10-2009 14:30

Re: Autorepare Dmg
 
Actually i don't know i'm still beginner on AMXX Scripting... But have you tried ?


All times are GMT -4. The time now is 17:02.

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