Raised This Month: $ Target: $400
 0% 

Error with a simple plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 12-31-2009 , 01:14   Error with a simple plugin
Reply With Quote #1

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

#define PLUGIN "He-slap"
#define VERSION "1.0"
#define AUTHOR "r4nDoMz"

register_cvar("heslap_dmg""75")

public 
plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
}

register_concmd("say /he","henade","1","Gives a nade, but slaps you")

public 
henade()
{
    new 
dmg get_cvar_num("heslap_dmg")
    
give_item(id,"weapon_hegrenade")
    
user_slap(id,dmg,0)

Wtf is wrong with the code? I know that give_item(id,"weapon_hegrenade")
is wrong but what do the other errors mean?

PHP Code:
//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// Heslap.sma
// C:\Documents and Settings\******\Desktop\compiler\Heslap.sma(8) : error 021: sy
mbol already defined"register_cvar"
// C:\Documents and Settings\*****\Desktop\compiler\Heslap.sma(16) : error 021: s
ymbol already defined"register_concmd"
// C:\Documents and Settings\*****\Desktop\compiler\Heslap.sma(21) : error 017: u
ndefined symbol "give_item"
// C:\Documents and Settings\*****\Desktop\compiler\Heslap.sma(21) : warning 215:
 
expression has no effect
// C:\Documents and Settings\*****\Desktop\compiler\Heslap.sma(21) : error 001: e
xpected token";"but found ")"
// C:\Documents and Settings\*****\Desktop\compiler\Heslap.sma(21) : error 029: i
nvalid expressionassumed zero
// C:\Documents and Settings\*****\Desktop\compiler\Heslap.sma(21) : fatal error
107too many error messages on one line
//
// Compilation aborted.
// 6 Errors.
// Could not locate output file C:\Documents and Settings\*****\Desktop\compiler\
compiled\Heslap.amx (compile failed).
//
// Compilation Time: 0.19 sec
// ----------------------------------------

Press enter to exit ... 
__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME
r4ndomz is offline
Send a message via Skype™ to r4ndomz
stupok
Veteran Member
Join Date: Feb 2006
Old 12-31-2009 , 01:40   Re: Error with a simple plugin
Reply With Quote #2

You misplaced a few things. register_cvar() and register_concmd() should be within the braces of plugin_init()

I suggest you start by reading this:
http://wiki.amxmodx.org/Intro_to_AMX_Mod_X_Scripting
__________________

Last edited by stupok; 12-31-2009 at 01:43.
stupok is offline
worldspawn
Senior Member
Join Date: Aug 2009
Location: Russia, Yekaterinburg
Old 12-31-2009 , 05:29   Re: Error with a simple plugin
Reply With Quote #3

solved

Last edited by worldspawn; 12-31-2009 at 09:19.
worldspawn is offline
Send a message via ICQ to worldspawn Send a message via Skype™ to worldspawn
AppStore
BANNED
Join Date: Dec 2009
Location: Saladillo
Old 12-31-2009 , 08:35   Re: Error with a simple plugin
Reply With Quote #4

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

#define PLUGIN "He-slap"
#define VERSION "1.0"
#define AUTHOR "r4nDoMz"


public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_cvar("heslap_dmg""75")
    
register_concmd("amx_he","henade"ADMIN_CVAR)
    
}

public 
henade(idlevelcid)
{
    if (!
cmd_access(idlevelcid2) )
        return 
PLUGIN_HANDLED
    
    
new arg[33]
    
read_argv(1arg32)
    new 
player cmd_target(idarg7)
    
    if(!
player)
        return 
PLUGIN_HANDLED
    
    give_item
(id,"weapon_hegrenade")
    
user_slap(idget_cvar_num("heslap_dmg"), 0)
    
    return 
PLUGIN_CONTINUE
    

or..

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

public plugin_init() {
    
    
register_plugin("He-slap""1.0""r4nDoMz")
    
register_cvar("heslap_dmg""75")
    
register_clcmd("say /he","henade")
    
}

public 
henade(id)
{
    
give_item(id,"weapon_hegrenade")
    
user_slap(idget_cvar_num("heslap_dmg"), 0)
    


Last edited by AppStore; 12-31-2009 at 08:38.
AppStore is offline
r4ndomz
Senior Member
Join Date: Jul 2009
Location: The Hood
Old 12-31-2009 , 13:20   Re: Error with a simple plugin
Reply With Quote #5

Ahh i see now. Thanks guys for your help =)
__________________
HideNSeek bug fixed here:http://forums.alliedmods.net/showpos...&postcount=951

PM me if you want a nice HideNSeek shop
NEED PLUGIN TESTERS PM ME
r4ndomz is offline
Send a message via Skype™ to r4ndomz
matsi
Thinkosaur
Join Date: Sep 2006
Old 12-31-2009 , 13:29   Re: Error with a simple plugin
Reply With Quote #6

Quote:
Originally Posted by AppStore View Post
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "He-slap"
#define VERSION "1.0"
#define AUTHOR "r4nDoMz"


public plugin_init() {
    
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_cvar("heslap_dmg""75")
    
register_concmd("amx_he","henade"ADMIN_CVAR)
    
}

public 
henade(idlevelcid)
{
    if (!
cmd_access(idlevelcid2) )
        return 
PLUGIN_HANDLED
    
    
new arg[33]
    
read_argv(1arg32)
    new 
player cmd_target(idarg7)
    
    if(!
player)
        return 
PLUGIN_HANDLED
    
    give_item
(id,"weapon_hegrenade")
    
user_slap(idget_cvar_num("heslap_dmg"), 0)
    
    return 
PLUGIN_CONTINUE
    

or..

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

public plugin_init() {
    
    
register_plugin("He-slap""1.0""r4nDoMz")
    
register_cvar("heslap_dmg""75")
    
register_clcmd("say /he","henade")
    
}

public 
henade(id)
{
    
give_item(id,"weapon_hegrenade")
    
user_slap(idget_cvar_num("heslap_dmg"), 0)
    

What's with the first code?
matsi is offline
AppStore
BANNED
Join Date: Dec 2009
Location: Saladillo
Old 12-31-2009 , 17:33   Re: Error with a simple plugin
Reply With Quote #7

Quote:
Originally Posted by matsi View Post
What's with the first code?
You choose with whom slapen amx_he and takes out 75 of life, according as defined by cvar heslap_dmg, a fact that you see a grenade Sets
AppStore is offline
matsi
Thinkosaur
Join Date: Sep 2006
Old 12-31-2009 , 17:52   Re: Error with a simple plugin
Reply With Quote #8

Quote:
Originally Posted by AppStore View Post
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "He-slap" #define VERSION "1.0" #define AUTHOR "r4nDoMz" public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR)     register_cvar("heslap_dmg", "75")     register_concmd("amx_he","henade", ADMIN_CVAR)     } public henade(id, level, cid) {     if (!cmd_access(id, level, cid, 2) )         return PLUGIN_HANDLED         new arg[33]     read_argv(1, arg, 32)     new player = cmd_target(id, arg, 7)         if(!player)         return PLUGIN_HANDLED         give_item(id,"weapon_hegrenade")     user_slap(id, get_cvar_num("heslap_dmg"), 0)         return PLUGIN_CONTINUE     }
First you register_concmd like this:
Code:
register_concmd("amx_he","henade", ADMIN_CVAR)
And there is no ADMIN_CVAR on the code? Maybe
Code:
#define ADMIN_CVAR ADMIN_KICK
also you could add "<target>" in the info parameter. And you're giving nades to the person who used the command instead of target.

Code:
new player = cmd_target(id, arg, 7)
I'm not sure about this but is there even flag 7 ?

edit: Also pcvars should be used.
matsi is offline
floatman
Senior Member
Join Date: Oct 2009
Location: nowhere.
Old 12-31-2009 , 18:36   Re: Error with a simple plugin
Reply With Quote #9

Quote:
Originally Posted by matsi View Post
new player = cmd_target(id, arg, 7)

I'm not sure about this but is there even flag 7 ?
Quote:
Originally Posted by AmxModX
Flags:
1 - obey immunity
2 - allow yourself
4 - must be alive
8 - can't be bot
__________________

floatman is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 12-31-2009 , 20:05   Re: Error with a simple plugin
Reply With Quote #10

Code:
7 = CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE
clarification.
__________________
fysiks 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 04:08.


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