Raised This Month: $ Target: $400
 0% 

[ZP] Extra item: Thunder Knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fiendshard
Senior Member
Join Date: Dec 2009
Location: In Water
Old 09-11-2010 , 10:48   [ZP] Extra item: Thunder Knife
Reply With Quote #1

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
Attached Files
File Type: sma Get Plugin or Get Source (zp_thunder.sma - 3036 views - 2.7 KB)
__________________

Last edited by fiendshard; 09-20-2010 at 19:05. Reason: update
fiendshard is offline
Vechta
Veteran Member
Join Date: Jun 2010
Old 09-11-2010 , 10:56   Re: [HELP] [ZP] Extra item: Thunder Knife
Reply With Quote #2

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

Vechta is offline
fiendshard
Senior Member
Join Date: Dec 2009
Location: In Water
Old 09-11-2010 , 11:37   Re: [HELP] [ZP] Extra item: Thunder Knife
Reply With Quote #3

Nope, doesn't work
__________________
fiendshard is offline
Vechta
Veteran Member
Join Date: Jun 2010
Old 09-11-2010 , 11:42   Re: [HELP] [ZP] Extra item: Thunder Knife
Reply With Quote #4

check on event damage if user has the item & weapon is knife
Vechta is offline
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 09-12-2010 , 00:30   Re: [HELP] [ZP] Extra item: Thunder Knife
Reply With Quote #5

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
}
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
fiendshard
Senior Member
Join Date: Dec 2009
Location: In Water
Old 09-12-2010 , 01:45   Re: [HELP] [ZP] Extra item: Thunder Knife
Reply With Quote #6

Quote:
Originally Posted by nikhilgupta345 View Post
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
__________________

Last edited by fiendshard; 09-12-2010 at 02:17.
fiendshard is offline
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 09-12-2010 , 02:46   Re: [HELP] [ZP] Extra item: Thunder Knife
Reply With Quote #7

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
__________________

My Plugins For ZP

Inactive due to College and Studies

Last edited by abdul-rehman; 09-12-2010 at 02:48.
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
nikhilgupta345
Veteran Member
Join Date: Aug 2009
Location: Virginia
Old 09-12-2010 , 21:07   Re: [HELP] [ZP] Extra item: Thunder Knife
Reply With Quote #8

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
nikhilgupta345 is offline
Send a message via ICQ to nikhilgupta345 Send a message via Yahoo to nikhilgupta345
abdul-rehman
Veteran Member
Join Date: Jan 2010
Location: Khi, Pakistan
Old 09-13-2010 , 02:43   Re: [HELP] [ZP] Extra item: Thunder Knife
Reply With Quote #9

Quote:
Originally Posted by nikhilgupta345 View Post
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
AND plz dont use get_players( ... ) bcoz it is resource ful and difficult
__________________

My Plugins For ZP

Inactive due to College and Studies
abdul-rehman is offline
Send a message via Yahoo to abdul-rehman Send a message via Skype™ to abdul-rehman
fiendshard
Senior Member
Join Date: Dec 2009
Location: In Water
Old 09-13-2010 , 07:09   Re: [ZP] Extra item: Thunder Knife
Reply With Quote #10

It is necessary to use STATIC bcoz static electricity is used in this knife
__________________
fiendshard is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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