AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Can someone teach me something ? (https://forums.alliedmods.net/showthread.php?t=95588)

ƒa†es™ 06-25-2009 04:26

Can someone teach me something ?
 
I have a plugin

PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <fun>
 
new TechnoPack
new bool:Techno_Pack[33]
 
public 
plugin_init()
{
 
register_plugin("[ZP] Techno Pack""1.0""ƒa†es™")
 
TechnoPack zp_register_extra_item("Techno Pack ( Techno )"0ZP_TEAM_HUMAN)
 
register_event("HLTV""event_round_start""a""1=0""2=0")
}
 
public 
zp_extra_item_selected(iditemid)
{
 if (
itemid == TechnoPack)
 {      
             
Techno_Packid ] = true  
 
             Glows
id )
 
             
client_print(idprint_chat"[ZP] You have bought a Techno Pack")
 }
 
 else
 {
             
Techno_Packid ] = false
             remove_task
id
             
client_print(idprint_chat"[ZP] Techno Pack finish.")
  }
 
}       
 
public 
event_round_start()
{
 for (new 
idid <= 32id++)
 {
             
Techno_Packid ] = false
  
}

}
 
public 
Death()
{
 
Techno_Packread_data) ] = false
}
 
public 
Glowsid )
{
     
set_task(1.0"Glows"id)
     if( 
is_user_aliveid ) || Techno_Packid ] )
     {
             
set_user_rendering(idkRenderFxGlowShell,  random_num0,255 ),  random_num0,255 ),  random_num0,255 ), kRenderNormal16 )
     }


Anyone know how to remove_task from set_task(1.0, "Glows", id)

I want when Techno_Pack[ id ] = false

It will remove:

PHP Code:

             set_user_rendering(idkRenderFxGlowShell,  random_num0,255 ),  random_num0,255 ),  random_num0,255 ), kRenderNormal16 

The problem is when Techno_Pack[ id ] = false

The
PHP Code:

             set_user_rendering(idkRenderFxGlowShell,  random_num0,255 ),  random_num0,255 ),  random_num0,255 ), kRenderNormal16 

remain.. i want to remove it.

zacky 06-25-2009 04:51

Re: Can someone teach me something ?
 
Do this when you set Techno_Pack to false:
PHP Code:

set_user_rendering(idkRenderFxNone,  255,  255,  255kRenderNormal16 

EDIT: Also do this when you set Techno_Pack to false:
PHP Code:

remove_task(id


ƒa†es™ 06-25-2009 05:46

Re: Can someone teach me something ?
 
Quote:

Originally Posted by zacky (Post 856542)
Do this when you set Techno_Pack to false:
PHP Code:

set_user_rendering(idkRenderFxNone,  255,  255,  255kRenderNormal16 

EDIT: Also do this when you set Techno_Pack to false:
PHP Code:

remove_task(id


Doesn't work.

Or maybe i did wrong ?

Can you redo my codes ?

zacky 06-25-2009 06:19

Re: Can someone teach me something ?
 
Try this:
PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <fun>
 
new TechnoPack
new bool:Techno_Pack[33]
 
public 
plugin_init()
{
    
register_plugin("[ZP] Techno Pack""1.0""fates")
    
TechnoPack zp_register_extra_item("Techno Pack ( Techno )"0ZP_TEAM_HUMAN)
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
register_event("DeathMsg""event_DeathMsg""a""1>0")
}
 
public 
zp_extra_item_selected(iditemid)
{
    if (
itemid == TechnoPack)
    {      
        
Techno_Packid ] = true  
 
        Glows
id )
 
        
client_print(idprint_chat"[ZP] You have bought a Techno Pack")
    }
 
    else
    {
        
Techno_Packid ] = false
        remove_task
(id)
        
set_user_rendering(idkRenderFxNone,  255,  255,  255kRenderNormal16 )
        
client_print(idprint_chat"[ZP] Techno Pack finish.")
    }
}       
 
public 
event_new_round()
{
    for (new 
idid <= 32id++)
    {
        
Techno_Packid ] = false
        remove_task
(id)
        
set_user_rendering(idkRenderFxNone,  255,  255,  255kRenderNormal16 )
    }
}
 
public 
event_DeathMsg()
{
    new 
iVictim read_data(2)
    
Techno_Pack[iVictim] = false
    remove_task
(iVictim)
    
set_user_rendering(iVictimkRenderFxNone,  255,  255,  255kRenderNormal16 )
}
 
public 
Glowsid )
{
    if( 
is_user_aliveid ) || Techno_Packid ] )
    {
        
set_user_rendering(idkRenderFxGlowShell,  random_num0,255 ),  random_num0,255 ),  random_num0,255 ), kRenderNormal16 )
        
set_task(1.0"Glows"id)
    }



xPaw 06-25-2009 06:30

Re: Can someone teach me something ?
 
PHP Code:

if( is_user_aliveid ) || Techno_Packid ] )

// ->

if( is_user_aliveid ) && Techno_Packid ] ) 

PHP Code:

for (new idid <= 32id++) // very bad




new g_iMaxplayers;

// plugin init
g_iMaxplayers get_maxplayers( );

// then like this
for (new idid <= g_iMaxplayersid++) 


Since you removing pack on death then you need todo
PHP Code:

register_event("DeathMsg""event_DeathMsg""a""1>0")

// ->

register_event("DeathMsg""event_DeathMsg""a""2>0"// 2 is from read_data ;) 


ƒa†es™ 06-25-2009 06:40

Re: Can someone teach me something ?
 
Quote:

Originally Posted by xPaw (Post 856585)
PHP Code:

if( is_user_aliveid ) || Techno_Packid ] )
 
// ->
 
if( is_user_aliveid ) && Techno_Packid ] ) 

PHP Code:

for (new idid <= 32id++) // very bad
 
 
 
 
new g_iMaxplayers;
 
// plugin init
g_iMaxplayers get_maxplayers( );
 
// then like this
for (new idid <= g_iMaxplayersid++) 


Since you removing pack on death then you need todo
PHP Code:

register_event("DeathMsg""event_DeathMsg""a""1>0")
 
// ->
 
register_event("DeathMsg""event_DeathMsg""a""2>0"// 2 is from read_data ;) 


Can i ask something ?

what is the different with this || and &&

minimiller 06-25-2009 06:45

Re: Can someone teach me something ?
 
|| = or
&& = and

ƒa†es™ 06-25-2009 06:45

Re: Can someone teach me something ?
 
Quote:

Originally Posted by zacky (Post 856579)
Try this:
PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <fun>
 
new TechnoPack
new bool:Techno_Pack[33]
 
public 
plugin_init()
{
    
register_plugin("[ZP] Techno Pack""1.0""fates")
    
TechnoPack zp_register_extra_item("Techno Pack ( Techno )"0ZP_TEAM_HUMAN)
    
register_event("HLTV""event_new_round""a""1=0""2=0")
    
register_event("DeathMsg""event_DeathMsg""a""1>0")
}
 
public 
zp_extra_item_selected(iditemid)
{
    if (
itemid == TechnoPack)
    {      
        
Techno_Packid ] = true  
 
        Glows
id )
 
        
client_print(idprint_chat"[ZP] You have bought a Techno Pack")
    }
 
    else
    {
        
Techno_Packid ] = false
        remove_task
(id)
        
set_user_rendering(idkRenderFxNone,  255,  255,  255kRenderNormal16 )
        
client_print(idprint_chat"[ZP] Techno Pack finish.")
    }
}       
 
public 
event_new_round()
{
    for (new 
idid <= 32id++)
    {
        
Techno_Packid ] = false
        remove_task
(id)
        
set_user_rendering(idkRenderFxNone,  255,  255,  255kRenderNormal16 )
    }
}
 
public 
event_DeathMsg()
{
    new 
iVictim read_data(2)
    
Techno_Pack[iVictim] = false
    remove_task
(iVictim)
    
set_user_rendering(iVictimkRenderFxNone,  255,  255,  255kRenderNormal16 )
}
 
public 
Glowsid )
{
    if( 
is_user_aliveid ) || Techno_Packid ] )
    {
        
set_user_rendering(idkRenderFxGlowShell,  random_num0,255 ),  random_num0,255 ),  random_num0,255 ), kRenderNormal16 )
        
set_task(1.0"Glows"id)
    }




Didn't work.

New round the Glow still remain.

zacky 06-25-2009 06:55

Re: Can someone teach me something ?
 
It should work.

EDIT: Try this:
Remove new round event and instead add this:
PHP Code:

// plugin_init()
register_logevent("cmdRoundEnded"2"1=Round_End")

public 
cmdRoundEnded()
{
    for (new 
i<= 32i++)
    {
        if (
Techno_Pack[i]) {
            
Techno_Pack[i] = false
            remove_task
(i)
            
set_user_rendering(ikRenderFxNone,  255,  255,  255kRenderNormal16 )
        }
    }



ƒa†es™ 06-25-2009 07:41

Re: Can someone teach me something ?
 
Quote:

Originally Posted by zacky (Post 856605)
It should work.

EDIT: Try this:
Remove new round event and instead add this:
PHP Code:

// plugin_init()
register_logevent("cmdRoundEnded"2"1=Round_End")
 
public 
cmdRoundEnded()
{
    for (new 
i<= 32i++)
    {
        if (
Techno_Pack[i]) {
            
Techno_Pack[i] = false
            remove_task
(i)
            
set_user_rendering(ikRenderFxNone,  255,  255,  255kRenderNormal16 )
        }
    }



Thanks Zacky it work :)


All times are GMT -4. The time now is 15:44.

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