AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Thunder, more than 1 use (https://forums.alliedmods.net/showthread.php?t=172181)

rodrigo286 11-16-2011 15:09

Thunder, more than 1 use
 
I already changed the havetk to other values ​​such as 3, but even so the use is limited to one use only.

PHP Code:

public zp_extra_item_selected(iditemid)
{
    if (
itemid == g_tknife)
    {
        
havetk[id] = 1
        client_print
(idprint_chat"[ZP] You got Thunder Knife! Slash a Zombie to kill him with thunder")
    }


thunder original plugin code by fiendshard
PHP Code:

#include <amxmodx>
#include <engine>
#include <zombieplague>

new havetk[33
new 
g_lightningg_smoke
new g_tknife

public plugin_init()
{
    
register_plugin"[ZP] Thunder Knife""0.1""fiendshard" );
    
register_event("Damage" "event_Damage" "b" "2>0");
    
g_tknife zp_register_extra_item("Thunder Knife (Once)"30ZP_TEAM_HUMAN
}
public 
plugin_precache()
{
    
g_lightning precache_model"sprites/lgtning.spr" );
    
g_smoke precache_model"sprites/steam1.spr" );
}

public 
zp_extra_item_selected(iditemid)
{
    if (
itemid == g_tknife)
    {
        
havetk[id] = 1
        client_print
(idprint_chat"[ZP] You got Thunder Knife! Slash a Zombie to kill him with thunder")
    }
}

public 
event_Damage(id)
{
    new 
weapon
    
new attacker get_user_attacker(id weapon);
    
    if(!
is_user_alive(attacker))
        return 
PLUGIN_CONTINUE;
    
    if       ((
zp_get_user_zombie(attacker)) ||
        (
zp_get_user_nemesis(attacker)) || 
        (
zp_get_user_survivor(attacker)))
    return 
PLUGIN_HANDLED;
    
    if(
weapon == CSW_KNIFE && havetk[attacker])
    {
        new 
vorigin], pos];
        
get_user_originidvorigin );
        
vorigin] -= 26;
        
pos] = vorigin] + 150;
        
pos] = vorigin] + 150;
        
pos] = vorigin] + 800;
        
        {
            if(
zp_get_user_nemesis(id))
            return 
PLUGIN_HANDLED;
        }
        
        
user_kill(id);
        
Thunderposvorigin );
        
Smokevorigin1010 );
        
        
havetk[attacker] = 0
        
return PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}
Thunderstart], end] )
{
message_beginMSG_BROADCASTSVC_TEMPENTITY ); 
write_byteTE_BEAMPOINTS ); 
write_coordstart] ); 
write_coordstart] ); 
write_coordstart] ); 
write_coordend] ); 
write_coordend] ); 
write_coordend] ); 
write_shortg_lightning ); 
write_byte);
write_byte);
write_byte);
write_byte150 );
write_byte30 );
write_byte200 ); 
write_byte200 );
write_byte200 );
write_byte200 );
write_byte200 );
message_end();

message_beginMSG_PVSSVC_TEMPENTITYend );
write_byteTE_SPARKS );
write_coordend]  );
write_coordend]);
write_coordend] );
message_end();
}

Smokeiorigin], scaleframerate )
{
message_beginMSG_BROADCASTSVC_TEMPENTITY );
write_byteTE_SMOKE );
write_coordiorigin] );
write_coordiorigin] );
write_coordiorigin] );
write_shortg_smoke );
write_bytescale );
write_byteframerate );
message_end();
}

public 
event_round_start()
{
    static 
imax_players
    
if (!max_playersmax_players get_maxplayers()

    for(
1<= max_playersi++)
        if (
is_user_connected(i)) havetk[i] = 0


Anyone know how to fix it?

Thanks.

Emp` 11-16-2011 15:29

Re: Thunder, more than 1 use
 
After you have set havetk[id] to a higher value, you need to change it to reduce the variable by one.

Currently, it just resets it to 0: havetk[attacker] = 0

But instead you should do: havetk[attacker]--

rodrigo286 11-16-2011 17:25

Re: Thunder, more than 1 use
 
It worked perfectly, thank you!

One more doubt please.

I would also put a time of 5 seconds for the player take damage, I tried the way down, but did not work.

PHP Code:

public event_Damage(id)
{
    new 
weapon
    
new attacker get_user_attacker(id weapon);
    
    if(!
is_user_alive(attacker))
        return 
PLUGIN_CONTINUE;
    
    if       ((
zp_get_user_zombie(attacker)) ||
        (
zp_get_user_nemesis(attacker)) || 
        (
zp_get_user_survivor(attacker)))
    return 
PLUGIN_HANDLED;
    
    if(
weapon == CSW_KNIFE && havetk[attacker])
    {    
        {
            if(
zp_get_user_nemesis(id))
            return 
PLUGIN_HANDLED;
        }
        
        
user_kill(id);
        
set_task5.0"explode"id ); 
        
emit_sound(idCHAN_STREAMsound_uhoo1.0ATTN_NORM0PITCH_NORM);
        
        
havetk[attacker]--
        return 
PLUGIN_HANDLED;
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
explode(id)
{
    new 
vorigin], pos];
    
get_user_originidvorigin );
    
vorigin] -= 26;
    
pos] = vorigin] + 150;
    
pos] = vorigin] + 150;
    
pos] = vorigin] + 800;
    
    
Smokevorigin1010 );
    
Thunderposvorigin );
}

Thunderstart], end] )
{
message_beginMSG_BROADCASTSVC_TEMPENTITY ); 
write_byteTE_BEAMPOINTS ); 
write_coordstart] ); 
write_coordstart] ); 
write_coordstart] ); 
write_coordend] ); 
write_coordend] ); 
write_coordend] ); 
write_shortg_lightning ); 
write_byte);
write_byte);
write_byte);
write_byte150 );
write_byte30 );
write_byte200 ); 
write_byte200 );
write_byte200 );
write_byte200 );
write_byte200 );
message_end();

message_beginMSG_PVSSVC_TEMPENTITYend );
write_byteTE_SPARKS );
write_coordend]  );
write_coordend]);
write_coordend] );
message_end();
}

Smokeiorigin], scaleframerate )
{
message_beginMSG_BROADCASTSVC_TEMPENTITY );
write_byteTE_SMOKE );
write_coordiorigin] );
write_coordiorigin] );
write_coordiorigin] );
write_shortg_smoke );
write_bytescale );
write_byteframerate );
message_end();


and i get 1 warning in this line:

PHP Code:

    Smokevorigin1010 ); 

Thanks very much!

#EDIT

I even managed to fix, but I still get warning of loose indentaion.

Evaldas.Grigas 11-17-2011 09:09

Re: Thunder, more than 1 use
 
tools -> indentor

rodrigo286 11-17-2011 09:41

Re: Thunder, more than 1 use
 
Two fixed and two generated in other lines.

I think it's okay to let the warnings.

Thanks.


All times are GMT -4. The time now is 08:35.

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