Raised This Month: $ Target: $400
 0% 

Help a newb with bad code?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iheartshrooms
Junior Member
Join Date: Mar 2007
Location: wa
Old 07-13-2008 , 22:19   Help a newb with bad code?
Reply With Quote #1

This is my first attempt at a plugin (and c++). It probably is all wrong, but I would like to know what I need to fix.

I want this plugin to give players a start health and extra health for kills.

When I try to compile, i get this error a whole bunch of times: "error 075: input line too long"

Any and all help will be appreciated. =]

PHP Code:
public plugin_init()
{
    
register_plugin("Fun Health","0.1beta","iheartshrooms")
    
    
p_enabled register_cvar("funhealth_on","1")
    
p_givehealth register_cvar("funhealth_bonus","50")
    
p_spawnhealth register_cvar("funhealth_spawn","300")
    
register_statsfwd(XMF_DEATH)
}

public 
dod_client_spawn(id)
{
   new 
spawnhp get_pcvr_num(p_spawnhealth)
   
   if(
get_pcvar_num(p_enabled) == 1)
    {
    
set_user_health(id,p_spawnhealth)
        }
   return 
PLUGIN_CONTINUE
}
    


public 
client_death(killer,victim,wpnindex,hitplace,TK)
{
   if(
get_pcvar_num(p_enabled) == && is_user_connected(killer))
    {
    if(
TK == 0)
        {
        new 
killername[32]
        
get_user_name(killer,killername,31)
        new 
oldhealth get_user_health(killer)
        new 
addition get_pcvar_num(p_givehealth)

        if(
wpnindex == DODW_GARAND_BUTT || wpnindex == DODW_K43_BUTT || wpnindex == DODW_KAR_BAYONET || wpnindex == DODW_AMERKNIFE || wpnindex == DODW_BRITKNIFE || wpnindex == DODW_GERKNIFE || wpnindex == DODW_SPADE)
            {
            
set_user_health(killer,(oldhealth+addition+addition))
            
set_hudmessage(3639192, -1.00.906.04.00.10.24)
            
show_hudmessage(killer,"+%dhp",(addition+addition))
            }

        else
            {
            
set_user_health(killer,(oldhealth+addition))
            
set_hudmessage(3639192, -1.00.906.04.00.10.24)
            
show_hudmessage(killer,"+%dhp",addition)
            }
        }
    }
   return 
PLUGIN_HANDLED


Last edited by iheartshrooms; 07-14-2008 at 00:45. Reason: thanx vet.
iheartshrooms is offline
Vet
Veteran Member
Join Date: Jul 2006
Location: I|O wa
Old 07-14-2008 , 00:23   Re: Help a newb with bad code?
Reply With Quote #2

Is that the entire code? If it is, the you need to use plugin_init routine.
Code:
 
public plugin_init()
{
 register_plugin("Fun Health","0.1beta","iheartshrooms")
 
 p_enabled = register_cvar("funhealth_on","1")
 p_givehealth = register_cvar("funhealth_bonus","50")
 p_spawnhealth = register_cvar("funhealth_spawn","300")
 register_statsfwd(XMF_DEATH)
}
__________________
=====================================
- My Plugins -
=====================================
Vet is offline
Send a message via MSN to Vet
iheartshrooms
Junior Member
Join Date: Mar 2007
Location: wa
Old 07-14-2008 , 00:43   Re: Help a newb with bad code?
Reply With Quote #3

oops. it didnt copy that part. yes i have it. thanks =]
iheartshrooms is offline
iheartshrooms
Junior Member
Join Date: Mar 2007
Location: wa
Old 07-14-2008 , 01:22   Re: Help a newb with bad code?
Reply With Quote #4

It still doesnt work and I cant find an issue...

=(
iheartshrooms is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 07-14-2008 , 01:56   Re: Help a newb with bad code?
Reply With Quote #5

AMXX plugins are not written in C++, but Pawn. This compiles.

Code:
#include <amxmodx> #include <fun> #include <dodx> new p_enabled, p_givehealth, p_spawnhealth public plugin_init() {     register_plugin("Fun Health","0.1beta","iheartshrooms")         p_enabled = register_cvar("funhealth_on","1")     p_givehealth = register_cvar("funhealth_bonus","50")     p_spawnhealth = register_cvar("funhealth_spawn","300")     register_statsfwd(XMF_DEATH) } public dod_client_spawn(id) {     if(get_pcvar_num(p_enabled) == 1)     {         set_user_health(id, get_pcvar_num(p_spawnhealth))     }     return PLUGIN_CONTINUE } public client_death(killer,victim,wpnindex,hitplace,TK) {     if(get_pcvar_num(p_enabled) == 1 && is_user_connected(killer))     {         if(TK == 0)         {             new killername[32]             get_user_name(killer,killername,31)             new oldhealth = get_user_health(killer)             new addition = get_pcvar_num(p_givehealth)                         if(wpnindex == DODW_GARAND_BUTT || wpnindex == DODW_K43_BUTT || wpnindex == DODW_KAR_BAYONET || wpnindex == DODW_AMERKNIFE || wpnindex == DODW_BRITKNIFE || wpnindex == DODW_GERKNIFE || wpnindex == DODW_SPADE)             {                 set_user_health(killer,(oldhealth+addition+addition))                 set_hudmessage(36, 39, 192, -1.0, 0.9, 0, 6.0, 4.0, 0.1, 0.2, 4)                 show_hudmessage(killer,"+%dhp",(addition+addition))             }                         else             {                 set_user_health(killer,(oldhealth+addition))                 set_hudmessage(36, 39, 192, -1.0, 0.9, 0, 6.0, 4.0, 0.1, 0.2, 4)                 show_hudmessage(killer,"+%dhp",addition)             }         }     }     return PLUGIN_HANDLED }
__________________
No support via PM.
Lee is offline
iheartshrooms
Junior Member
Join Date: Mar 2007
Location: wa
Old 07-14-2008 , 02:01   Re: Help a newb with bad code?
Reply With Quote #6

Thank you very much! =]
iheartshrooms is offline
iheartshrooms
Junior Member
Join Date: Mar 2007
Location: wa
Old 07-14-2008 , 02:21   Re: Help a newb with bad code?
Reply With Quote #7

/home/groups/amxmodx/tmp3/phpk15jQf.sma(43) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpk15jQf.sma(4 : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpk15jQf.sma(4 : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp3/phpk15jQf.sma(4 : warning 215: expression has no effect
/home/groups/amxmodx/tmp3/phpk15jQf.sma(4 : error 001: expected token: ";", but found "if"
/home/groups/amxmodx/tmp3/phpk15jQf.sma(4 : fatal error 107: too many error messages on one line


=O =[
iheartshrooms is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 07-14-2008 , 02:28   Re: Help a newb with bad code?
Reply With Quote #8

Nope, it definitely compiles.
__________________
No support via PM.
Lee 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 05:38.


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