Raised This Month: $ Target: $400
 0% 

Valid player problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 04-03-2015 , 09:24   Valid player problem
Reply With Quote #1

This is the plugin:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
#include <fun>
#include <engine>
#include <biohazard>
#include <bhextra2> 

#define VipFlag ADMIN_LEVEL_H

#define SOUND "biohazard/hammer_round.wav"

#define PLUGIN "Only Knife"
#define VERSION "1.0"
#define AUTHOR "MAN?"

#define is_valid_player(%1) (1 <= %1 <= 32)

new bool:g_superhuman
new bool:g_superhuman_knife

new cvar_knockback

new g_iItem

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
g_iItem bh_register_extra_item("|VIP|Hammer Round""humans are hammer warriors"12000BH_TEAM_SURVIVORGAMEPLAY);

    
RegisterHam(Ham_Touch"weaponbox""fw_TouchWeapon")
    
RegisterHam(Ham_Touch"armoury_entity""fw_TouchWeapon")
    
RegisterHam(Ham_Touch"weapon_shield""fw_TouchWeapon")
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage")
    
register_event("CurWeapon""event_CurWeapon""be""1!0","1=1")
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
register_logevent("round_end"2"1=Round_End");

    
cvar_knockback register_cvar("knockback_power2""7.0")
}

public 
event_gamestart()
{
    static 
id
    
new numiPlayers[32]
    
get_players(iPlayersnum)
    if( !
num )
    {
        return;
    }
    for(new 
0numi++)
    {
        
id iPlayers[i]
        if(!
is_user_connected(id) || !is_user_alive(id) || is_user_zombie(id))
            continue

        if(
g_superhuman == true)
        {
              
g_superhuman_knife true
        
}
        
              if(!
is_user_zombie(id) && g_superhuman == trueset_user_armor(id1900)
        
    }
}

public 
bh_extra_item_selected(idiItem)
{
    if(
iItem == g_iItem)
    {
        
g_superhuman true  

        client_cmd
(0"spk %s"SOUND)
    }
}

public 
round_end()
{
    if(
g_superhuman == true)
    { 
        
g_superhuman false 
        g_superhuman_knife 
false
    
}
}

public 
fw_TakeDamage(victiminflictorattackerFloat:damage)
{
  if(
g_superhuman_knife == true)
  {
    if(!
is_user_zombie(attacker) && is_valid_player(attacker) && get_user_weapon(attacker) == CSW_KNIFE)
    {
        
SetHamParamFloat(4damage 20)

        if(
is_user_zombie(victim))
        {
            new 
Float:vec[3
            new 
Float:oldvelo[3
            
get_user_velocity(victimoldvelo
            
create_velocity_vector(victim attacker vec
            
vec[0] += oldvelo[0
            
vec[1] += oldvelo[1
            
set_user_velocity(victim vec
        }
    } 
  }    
}

stock create_velocity_vector(victim,attacker,Float:velocity[3])
{
    if(!
is_user_alive(victim) || !is_user_alive(attacker))
        return 
0

    
new Float:vicorigin[3]
    new 
Float:attorigin[3]
    
entity_get_vector(victim   EV_VEC_origin vicorigin)
    
entity_get_vector(attacker EV_VEC_origin attorigin)

    new 
Float:origin2[3]
    
origin2[0] = vicorigin[0] - attorigin[0]
    
origin2[1] = vicorigin[1] - attorigin[1]

    new 
Float:largestnum 0.0

    
if(floatabs(origin2[0])>largestnumlargestnum floatabs(origin2[0])
    if(
floatabs(origin2[1])>largestnumlargestnum floatabs(origin2[1])

    
origin2[0] /= largestnum
    origin2
[1] /= largestnum

    velocity
[0] = ( origin2[0]*(get_pcvar_float(cvar_knockback) * 3000)) / get_entity_distance(victim attacker)
    
velocity[1] = ( origin2[1]*(get_pcvar_float(cvar_knockback) * 3000)) / get_entity_distance(victim attacker)
    if(
velocity[0] <= 20.0 || velocity[1] <= 20.0)
        
velocity[2] = random_float(200.0 275.0)

    return 
1
}

public 
plugin_precache()
{
    
precache_sound(SOUND)
}

public 
fw_TouchWeapon(ent,id)
{
    if(!
is_user_connected(id))return HAM_IGNORED
    
if(g_superhuman_knife)return HAM_SUPERCEDE
    
return HAM_IGNORED
}
public 
event_CurWeapon(id)
if(
g_superhuman_knife && is_user_alive(id) && get_user_weapon(id) != CSW_KNIFE && !is_user_zombie(id))
engclient_cmd(id"weapon_knife"
For some reason this does not work (knife does not have more damage and knockback)
PHP Code:
public fw_TakeDamage(victiminflictorattackerFloat:damage)
{
  if(
g_superhuman_knife == true)
  {
    if(!
is_user_zombie(attacker) && is_valid_player(attacker) && get_user_weapon(attacker) == CSW_KNIFE)
    {
        
SetHamParamFloat(4damage 20)

        if(
is_user_zombie(victim))
        {
            new 
Float:vec[3
            new 
Float:oldvelo[3
            
get_user_velocity(victimoldvelo
            
create_velocity_vector(victim attacker vec
            
vec[0] += oldvelo[0
            
vec[1] += oldvelo[1
            
set_user_velocity(victim vec
        }
    } 
  }    

But,when I delete check get_user_weapon(attacker) == CSW_KNIFE then working properly (knife have more damage and knockback). But,when I delete that check,players are dying for no reason,just die like they committed suicide and after a short time server crash.
Can someone please help me how to solve this?

Last edited by Krtola; 04-03-2015 at 09:59.
Krtola is offline
Send a message via Skype™ to Krtola
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 10:37.


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