Raised This Month: $51 Target: $400
 12% 

Help - Whats wrong with this code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
recimo
Junior Member
Join Date: Aug 2011
Old 04-12-2012 , 13:22   Help - Whats wrong with this code?
Reply With Quote #1

I tried to make plugin which will give He grenade to player who kills 5 other players in round. I test it with bots in lan server, but didn't work. Does anyone know what's the problem?
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fun>

new number_of_kills[33

public 
plugin_init()
{
    
register_plugin("Earn HE","1.0","recimo")
    
RegisterHam(Ham_Killed"player""Kill"1)
    
register_logevent("new_round"2"1=Round_Start")
}
public 
Kill(victim,killer)
{
    if(!
is_user_connected(killer))
    {
        return 
HAM_IGNORED
    
}
    if(
get_user_team(killer) != get_user_team(victim))
    {
        
number_of_kills[killer] ++
    }
    if(
number_of_kills[killer] == 5)
    {
        
give_item(killer"weapon_hegrenade")
        return 
HAM_SUPERCEDE
    
}
        return 
PLUGIN_CONTINUE
}
public 
new_round()
{
    new 
players[32], inum
    get_players
(playersinum)
    for(new 
a=0a<inum; ++a)
    {
        
number_of_kills[players[a]] = 0
    
}

recimo is offline
kiki33hun
Veteran Member
Join Date: Jul 2011
Location: Magyarország
Old 04-12-2012 , 13:26   Re: Help - Whats wrong with this code?
Reply With Quote #2

return HAM_SUPERCEDE ??
__________________
kiki33hun is offline
recimo
Junior Member
Join Date: Aug 2011
Old 04-12-2012 , 17:06   Re: Help - Whats wrong with this code?
Reply With Quote #3

Im beginner, so i don't understand all... ;) I was told to put that line "return HAM_SUPERCEDE" instead of "return PLUGIN_CONTINUE"... What you propose to put?
recimo is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 04-12-2012 , 17:12   Re: Help - Whats wrong with this code?
Reply With Quote #4

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

new number_of_kills[33

public 
plugin_init()
{
    
register_plugin("Earn HE","1.0","recimo")
    
RegisterHam(Ham_Killed"player""Kill"1)
    
register_logevent("new_round"2"1=Round_Start")
}
// properly declare your function header
public Kill(victimkillershould_gib)
{
    if(!
is_user_connected(killer))
    {
        return 
HAM_IGNORED
    
}
    if(
get_user_team(killer) != get_user_team(victim))
    {
        if(++
number_of_kills[killer] == 5)
        {
            
give_item(killer"weapon_hegrenade")
            
// no need to return this
            // supercede blocks a hook, but this is a post hook so nothing is done
            //return HAM_SUPERCEDE
        
}
    }
    
    
// use HAM_* returns for ham hooks and nothing else
    //return PLUGIN_CONTINUE
    
return HAM_IGNORED
}
public 
new_round()
{
    
/*new players[32], inum
    get_players(players, inum)
    for(new a=0; a<inum; ++a)
    {
        number_of_kills[players[a]] = 0
    }*/
    // arrayset() does the work for you with less code
    // also fixes any issues with players joining late
    
arrayset(number_of_kills0sizeof(number_of_kills))

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
recimo
Junior Member
Join Date: Aug 2011
Old 04-12-2012 , 17:21   Re: Help - Whats wrong with this code?
Reply With Quote #5

Ty exolent, it helped a lot. Just one more question. Whats "should_gib" for?
Edit: sry for disturbance, but i tried it again it didn't worked. Maybe because bots are in game instead of actual players?

Last edited by recimo; 04-12-2012 at 17:44.
recimo is offline
claudiuhks
Yam Inside®™℠
Join Date: Jan 2010
Location: Living Randomly
Old 04-12-2012 , 20:34   Re: Help - Whats wrong with this code?
Reply With Quote #6

Quote:
Originally Posted by recimo View Post
Just one more question. Whats "should_gib" for?
If the third argument is positive, an explosion of bones and raw meat will happen.

Last edited by claudiuhks; 04-12-2012 at 20:36.
claudiuhks is offline
Send a message via MSN to claudiuhks Send a message via Yahoo to claudiuhks Send a message via Skype™ to claudiuhks
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 04-12-2012 , 21:12   Re: Help - Whats wrong with this code?
Reply With Quote #7

Quote:
Originally Posted by recimo View Post
Ty exolent, it helped a lot. Just one more question. Whats "should_gib" for?
Edit: sry for disturbance, but i tried it again it didn't worked. Maybe because bots are in game instead of actual players?
I don't think so... but.. test.. add this..

PHP Code:
 new bool:g_bot

public client_putinserver(id) {
    if(
is_user_bot(id) && !g_bot) {
        
RegisterHamFromEntity(Ham_Killedid"Kill")
        
g_bot true
    
}

__________________

www.amxmodx-es.com

Steam: Luchokoldo

Last edited by rak; 04-12-2012 at 21:12.
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
recimo
Junior Member
Join Date: Aug 2011
Old 04-13-2012 , 06:38   Re: Help - Whats wrong with this code?
Reply With Quote #8

I tried it on public server and it worked
Tnx for help!
recimo is offline
recimo
Junior Member
Join Date: Aug 2011
Old 04-13-2012 , 17:44   Re: Help - Whats wrong with this code?
Reply With Quote #9

Sry for double post. Can someone tell me whats wrong with this one:
PHP Code:
#include <amxmodx> 
#include <hamsandwich> 
#include <fun>
#include <cstrike> 

new number_of_kills[33

public 
plugin_init() 

    
register_plugin("Knife VIP","1.0","recimo"
    
RegisterHam(Ham_Killed"player""Kill"1
    
register_logevent("new_round"2"1=Round_Start"
}
public 
plugin_precache()
{
    
precache_model("v_knife_vip.mdl"
}     
public 
Kill(victimkillershould_gib

    if(!
is_user_connected(killer)) 
    { 
        return 
HAM_IGNORED 
    
}
    if(
get_user_flags(killer ADMIN_LEVEL_H)) 
    {
    
cs_set_user_model(killer"v_knife_vip.mdl")
    return 
PLUGIN_CONTINUE
    
}
    if(
get_user_team(killer) != get_user_team(victim)) 
    { 
        if(++
number_of_kills[killer] == 4)  
        { 
            
give_item(killer"weapon_hegrenade")
        }       
    } 
    return 
HAM_IGNORED 

public 
new_round() 

    
arrayset(number_of_kills0sizeof(number_of_kills)) 

It should give model to player who has "t" flag and give He grenade to that same player when he kill 4 other players in round. Its some sort of Vip plugin.
I know that this is for some of you easy stuff, but im still learning...

Last edited by recimo; 04-13-2012 at 17:46. Reason: Gramatic mistakes...
recimo is offline
rak
Veteran Member
Join Date: Oct 2011
Location: banned country
Old 04-13-2012 , 18:24   Re: Help - Whats wrong with this code?
Reply With Quote #10

PHP Code:
if(get_user_flags(killer) & ADMIN_LEVEL_H
PHP Code:
return PLUGIN_CONTINUE 
again? -.-

delete this
__________________

www.amxmodx-es.com

Steam: Luchokoldo
rak is offline
Send a message via MSN to rak Send a message via Skype™ to rak
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 12:52.


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