Raised This Month: $ Target: $400
 0% 

Killstreak plugin - problem


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
subs
Junior Member
Join Date: Aug 2013
Old 08-12-2013 , 21:21   Killstreak plugin - problem
Reply With Quote #1

Hi,

It's my first post ever here, on Allied Modders, today is also the first time I started writing my own plugin.
This forum is quite helpful for most of the cases but now it seems I can't find the answer in other threads/help requests/approved plugins. That's why I need Your help.

I've started writing Killstreak Plugin which (hopefully) is going to look like this:
If players' killstreak is equal or more than 5 he gets +2 points for each kill, if players' killstreak is equal or more than 10 he gets +3 points for each kill. In the end there's a HUD message with current killstreak count.

Everything is working great except for one thing..
Any kill made by every player on the server raises the killstreak counter thus making everyone having a killstreak. I've been trying to find the mistake for like an hour and it seems I'm either blind or just did something wrong from the very beginning.

Sorry for long post and thanks in advance for some guides/help.
Wall of text - off, here's another one:

PHP Code:
#include <amxmodx>
#include <fun>

#define PLUGIN "MISC Killstreak"
#define VERSION "1.0"
#define AUTHOR "subs"

new g_Killerg_Killsg_MsgScoreInfo

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg""msgDeath""a""1>0")
    
    
set_task(1.0"showKillstreak"0""0"b")
    
    
g_MsgScoreInfo get_user_msgid("ScoreInfo")
}

public 
msgDeath(id)
{
    
g_Killer read_data(1)
    
    if (
g_Killer && is_user_alive(g_Killer))
    {
        
g_Kills++    // Start killstreak counter
        
        
if (g_Kills >= && g_Kills 10// Give +2 points for each kill if players' killstreak is equal or more than 5
        
{
            
set_user_frags(g_Killerget_user_frags(g_Killer) + 1)
        }
            
        else if (
g_Kills >= 10// Give +3 points for each kill if players' killstreak is equal or more than 10
        
{
            
set_user_frags(g_Killerget_user_frags(g_Killer) + 2)
        }
        
message_begin(MSG_ALLg_MsgScoreInfo// Add points to scoreboard
        
write_byte(g_Killer)
        
write_short(get_user_frags(g_Killer))
        
write_short(get_user_deaths(g_Killer))
        
write_short(0)
        
write_short(get_user_team(g_Killer))
        
message_end()
    }
    else
    {
        
g_Kills // Clear killstreak counter when player dies
    
}
}

public 
showKillstreak(id)
{
    
set_hudmessage(0952450.00.000.01.10.10.515
    
show_hudmessage(id"Killstreak: %i"g_Kills


Last edited by subs; 08-12-2013 at 21:29. Reason: Correction
subs is offline
 



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 16:00.


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