AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help a newb with bad code? (https://forums.alliedmods.net/showthread.php?t=74205)

iheartshrooms 07-13-2008 22:19

Help a newb with bad code?
 
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



Vet 07-14-2008 00:23

Re: Help a newb with bad code?
 
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)
}


iheartshrooms 07-14-2008 00:43

Re: Help a newb with bad code?
 
oops. it didnt copy that part. yes i have it. thanks =]

iheartshrooms 07-14-2008 01:22

Re: Help a newb with bad code?
 
It still doesnt work and I cant find an issue...

=(

Lee 07-14-2008 01:56

Re: Help a newb with bad code?
 
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 }

iheartshrooms 07-14-2008 02:01

Re: Help a newb with bad code?
 
Thank you very much! =]

iheartshrooms 07-14-2008 02:21

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


=O =[

Lee 07-14-2008 02:28

Re: Help a newb with bad code?
 
Nope, it definitely compiles.


All times are GMT -4. The time now is 05:38.

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