AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Error with a simple plugin (https://forums.alliedmods.net/showthread.php?t=113886)

r4ndomz 12-31-2009 01:14

Error with a simple plugin
 
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 ... 


stupok 12-31-2009 01:40

Re: Error with a simple plugin
 
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

worldspawn 12-31-2009 05:29

Re: Error with a simple plugin
 
solved

AppStore 12-31-2009 08:35

Re: Error with a simple plugin
 
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)
    



r4ndomz 12-31-2009 13:20

Re: Error with a simple plugin
 
Ahh i see now. Thanks guys for your help =)

matsi 12-31-2009 13:29

Re: Error with a simple plugin
 
Quote:

Originally Posted by AppStore (Post 1037647)
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? :lol:

AppStore 12-31-2009 17:33

Re: Error with a simple plugin
 
Quote:

Originally Posted by matsi (Post 1037971)
What's with the first code? :lol:

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

matsi 12-31-2009 17:52

Re: Error with a simple plugin
 
Quote:

Originally Posted by AppStore (Post 1037647)
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. :)

floatman 12-31-2009 18:36

Re: Error with a simple plugin
 
Quote:

Originally Posted by matsi (Post 1038366)
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


fysiks 12-31-2009 20:05

Re: Error with a simple plugin
 
Code:

7 = CMDTARGET_OBEY_IMMUNITY | CMDTARGET_ALLOW_SELF | CMDTARGET_ONLY_ALIVE
clarification.


All times are GMT -4. The time now is 04:08.

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