AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   [ZP] Extra item: Thunder Knife (https://forums.alliedmods.net/showthread.php?t=137947)

fiendshard 09-11-2010 10:48

[ZP] Extra item: Thunder Knife
 
1 Attachment(s)
Here it is, working now

THUNDER KNIFE

What it does: when human player purchases it, he will receive knife that crackles with electricity.
If zombie is slashed with thunder knife, he will die instantly.

Nemesis is immune to thunder knife

Update: lightning strike is now much more larger

TODO: Model for thunder knife?

Credits: fiendshard, Mercylezz, abdul, vechta, nikhil, laci, nido

Vechta 09-11-2010 10:56

Re: [HELP] [ZP] Extra item: Thunder Knife
 
Try this:

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)"15ZP_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] = true
        client_print
(idprint_chat"[ZP] You got Thunder Knife! Slash a Zombie to kill him with thunder")
    }
}

public 
client_putinserver(id)
    
havetk[id] = false

public event_Damage(id)
{
    new 
weapon ,attacker get_user_attacker(id weapon);
        
    if ( !
is_user_alive(attacker) ||zp_get_user_zombie(attacker) || zp_get_user_nemesis(attacker) ||  zp_get_user_survivor(attacker)) return;
    
    if(
weapon == CSW_KNIFE)
    {
        new 
vorigin], pos];
        
get_user_originidvorigin );
        
vorigin] -= 26;
        
pos] = vorigin] + 150;
        
pos] = vorigin] + 150;
        
pos] = vorigin] + 800;
        
        
user_kill(id);
        
Thunderposvorigin );
        
Smokevorigin1010 );
        
        
havetk[id] = false
    
}
}
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_byte20 );
    
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()
{
    for(new 
032i++)
        
havetk[i] = false



fiendshard 09-11-2010 11:37

Re: [HELP] [ZP] Extra item: Thunder Knife
 
Nope, doesn't work

Vechta 09-11-2010 11:42

Re: [HELP] [ZP] Extra item: Thunder Knife
 
check on event damage if user has the item & weapon is knife

nikhilgupta345 09-12-2010 00:30

Re: [HELP] [ZP] Extra item: Thunder Knife
 
Never ever used register_event("Damage"), but used takedamage. So idk why is passed in the paramter of the function eventDeath or w/e. What is the id? The victim?

Anyway, if it is as i suspect, this should work:

Code:

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

new havetk[33]
new g_lightning, g_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)", 15, ZP_TEAM_HUMAN)
}
public plugin_precache()
{
    g_lightning = precache_model( "sprites/lgtning.spr" );
    g_smoke = precache_model( "sprites/steam1.spr" );
}

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

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[ 3 ], pos[ 3 ];
        get_user_origin( id, vorigin );
        vorigin[ 2 ] -= 26;
        pos[ 0 ] = vorigin[ 0 ] + 150;
        pos[ 1 ] = vorigin[ 1 ] + 150;
        pos[ 2 ] = vorigin[ 2 ] + 800;
       
        user_kill(id);
        Thunder( pos, vorigin );
        Smoke( vorigin, 10, 10 );
       
        havetk[id] = 0
    }
   
    return PLUGIN_CONTINUE;
}
Thunder( start[ 3 ], end[ 3 ] )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_BEAMPOINTS );
write_coord( start[ 0 ] );
write_coord( start[ 1 ] );
write_coord( start[ 2 ] );
write_coord( end[ 0 ] );
write_coord( end[ 1 ] );
write_coord( end[ 2 ] );
write_short( g_lightning );
write_byte( 1 );
write_byte( 5 );
write_byte( 7 );
write_byte( 20 );
write_byte( 30 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
message_end();

message_begin( MSG_PVS, SVC_TEMPENTITY, end );
write_byte( TE_SPARKS );
write_coord( end[ 0 ]  );
write_coord( end[ 1 ]);
write_coord( end[ 2 ] );
message_end();
}

Smoke( iorigin[ 3 ], scale, framerate )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_SMOKE );
write_coord( iorigin[ 0 ] );
write_coord( iorigin[ 1 ] );
write_coord( iorigin[ 2 ] );
write_short( g_smoke );
write_byte( scale );
write_byte( framerate );
message_end();
}

public event_round_start()
{
    for(new i = 0; i < 32; i++)
        havetk[i] = 0
}


fiendshard 09-12-2010 01:45

Re: [HELP] [ZP] Extra item: Thunder Knife
 
Quote:

Originally Posted by nikhilgupta345 (Post 1297838)
Never ever used register_event("Damage"), but used takedamage. So idk why is passed in the paramter of the function eventDeath or w/e. What is the id? The victim?

Anyway, if it is as i suspect, this should work:

Code:

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

new havetk[33]
new g_lightning, g_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)", 15, ZP_TEAM_HUMAN)
}
public plugin_precache()
{
    g_lightning = precache_model( "sprites/lgtning.spr" );
    g_smoke = precache_model( "sprites/steam1.spr" );
}

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

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[ 3 ], pos[ 3 ];
        get_user_origin( id, vorigin );
        vorigin[ 2 ] -= 26;
        pos[ 0 ] = vorigin[ 0 ] + 150;
        pos[ 1 ] = vorigin[ 1 ] + 150;
        pos[ 2 ] = vorigin[ 2 ] + 800;
       
        user_kill(id);
        Thunder( pos, vorigin );
        Smoke( vorigin, 10, 10 );
       
        havetk[id] = 0
    }
   
    return PLUGIN_CONTINUE;
}
Thunder( start[ 3 ], end[ 3 ] )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_BEAMPOINTS );
write_coord( start[ 0 ] );
write_coord( start[ 1 ] );
write_coord( start[ 2 ] );
write_coord( end[ 0 ] );
write_coord( end[ 1 ] );
write_coord( end[ 2 ] );
write_short( g_lightning );
write_byte( 1 );
write_byte( 5 );
write_byte( 7 );
write_byte( 20 );
write_byte( 30 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
write_byte( 200 );
message_end();

message_begin( MSG_PVS, SVC_TEMPENTITY, end );
write_byte( TE_SPARKS );
write_coord( end[ 0 ]  );
write_coord( end[ 1 ]);
write_coord( end[ 2 ] );
message_end();
}

Smoke( iorigin[ 3 ], scale, framerate )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_SMOKE );
write_coord( iorigin[ 0 ] );
write_coord( iorigin[ 1 ] );
write_coord( iorigin[ 2 ] );
write_short( g_smoke );
write_byte( scale );
write_byte( framerate );
message_end();
}

public event_round_start()
{
    for(new i = 0; i < 32; i++)
        havetk[i] = 0
}


It partially works; if purchased, player gets one hit kill knife for the rest of the map time

abdul-rehman 09-12-2010 02:46

Re: [HELP] [ZP] Extra item: Thunder Knife
 
You need to change this
Code:
public event_round_start() {     for(new i = 0; i < 32; i++)         havetk[i] = 0 }
To this:
Code:
public event_round_start() {     static i, max_players     if (!max_players) max_players = get_maxplayers()     for(i = 1; i <= max_players; i++)         if (is_user_connected(i)) havetk[i] = 0 }

Or for setting havetk[i] to 0 you can use arrayset( ... ) native to achieve your goal

And change this:
Code:
public zp_extra_item_selected(id, itemid) {     if (itemid == g_tknife)     havetk[id] = 1     client_print(id, print_chat, "[ZP] You got Thunder Knife! Slash a Zombie to kill him with thunder")     return PLUGIN_CONTINUE;     }
To this:
Code:
public zp_extra_item_selected(id, itemid) {     if (itemid == g_tknife)     {         havetk[id] = 1         client_print(id, print_chat, "[ZP] You got Thunder Knife! Slash a Zombie to kill him with thunder")     } }
Or else the if statement wouldnt be properly read by the compiler :)

nikhilgupta345 09-12-2010 21:07

Re: [HELP] [ZP] Extra item: Thunder Knife
 
You justt LOVE using static right :)

Got a question, does maxplayers just get hte max amount of players that are allowed int he server or the amount of players in the server at the moment?

Because I usuallly use get_players

abdul-rehman 09-13-2010 02:43

Re: [HELP] [ZP] Extra item: Thunder Knife
 
Quote:

Originally Posted by nikhilgupta345 (Post 1297957)
You justt LOVE using static right :)

Got a question, does maxplayers just get hte max amount of players that are allowed int he server or the amount of players in the server at the moment?

Because I usuallly use get_players

Regarding static i will say that they are faster and act more like a global variable because they are only created once as you can see in the above code

And regarding max players, get_maxplayers() returns the maximum slots on the server and you can store this value as a global during plugin start since the to change the max player setting you need to restart your server :up:
AND plz dont use get_players( ... ) bcoz it is resource ful and difficult :nono:

fiendshard 09-13-2010 07:09

Re: [ZP] Extra item: Thunder Knife
 
It is necessary to use STATIC bcoz static electricity is used in this knife


All times are GMT -4. The time now is 14:46.

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