AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help (https://forums.alliedmods.net/showthread.php?t=26320)

CodeBreaker 03-30-2006 23:52

Help
 
I need help coding this, First time at AMXX *hides*

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "Client Gunz" #define VERSION "1.0" #define AUTHOR "CodeBreaker" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR) } public give_items(id,level,cid) {     if(!(get_user_access(id,&ADMIN_KICK)) {         client_print(id, print_center, "[AMXX] Access not granted.")         return PLUGIN_HANDLED     }     else     {         give_item(id,"weapon_m4a1")         give_item(id,"weapon_m4a1")         give_item(id,"weapon_m4a1")         give_item(id,"weapon_m4a1")         client_print(id,print_chat,"[AMXX] Added Weapon - M4A1")     }

I know there is some stuff missing, but why am I getting errors with that stuff?

capndurk 03-30-2006 23:58

Under the give_items function, put this

Code:
if(!cmd_access(id,level,cid,num) // replace num with the number of arguments (including command) {      return PLUGIN_HANDLED; }

instead of

Code:
if(!(get_user_access(id,&ADMIN_KICK)) {         client_print(id, print_center, "[AMXX] Access not granted.")         return PLUGIN_HANDLED     }

You also need a register_concmd function in plugin_init() to call the give_items function with a function in your console. ;)

CodeBreaker 03-31-2006 00:12

Ok, I updated my code, Still get errors.

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "Client Gunz" #define VERSION "1.0" #define AUTHOR "CodeBreaker" public give_items(id,level,cid) {     if(!cmd_access(id,level,cid,2) {         client_print(id,print_chat,"[AMXX] No access!")         return PLUGIN_HANDLED     }     give_item(id,"weapon_m4a1")     give_item(id,"weapon_m4a1")     give_item(id,"weapon_m4a1")     give_item(id,"weapon_m4a1")     client_print(id,print_center,"[AMXX] Weapon Added!") }     public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("amx_weapons","give_items","ADMIN_KICK"," : Gives you some weapons") }

Thanks for the fast help.

capndurk 03-31-2006 00:21

Post your errors.

CodeBreaker 03-31-2006 00:24

Noob question, how do I post my errors?

v3x 03-31-2006 00:27

Use the web compiler, compile the plugin, copy/paste->post the error messages that it outputs.

CodeBreaker 03-31-2006 00:27

/home/users/amxmodx/tmp3/phpftgCmc.sma(12) : error 001: expected token: ")", but found "{"
/home/users/amxmodx/tmp3/phpftgCmc.sma(21) : warning 209: function "give_items" should return a value
/home/users/amxmodx/tmp3/phpftgCmc.sma(25) : error 035: argument type mismatch (argument 3)

v3x 03-31-2006 00:27

Add "return PLUGIN_HANDLED" at the end of your give_items function.

And change 2 to 1 here:
Code:
if(!cmd_access(id,level,cid,2) {
That last parameter is for the # of arguments the command contains.

For a better understanding go here: http://ghw-amxx.com/images/args.gif

CodeBreaker 03-31-2006 00:32

Another error(s)...

Code:
Your plugin failed to compile! Read the errors below: Welcome to the AMX Mod X 1.70-300 Compiler. Copyright (c) 1997-2005 ITB CompuPhase, AMX Mod X Team /home/users/amxmodx/tmp3/phpDgHGST.sma(12) : error 001: expected token: ")", but found "{" /home/users/amxmodx/tmp3/phpDgHGST.sma(26) : error 035: argument type mismatch (argument 3) 2 Errors. Could not locate output file /home/groups/amxmodx/public_html/websc3/phpDgHGST.amx (compile failed). 51972 successful compiles to date. 28009 failed compiles to date. Old compiler: 101980 compiles before decommission. This tool by: David "BAILOPAN" Anderson.

CodeBreaker 03-31-2006 00:39

I found one problem, One error now

Code:

/home/users/amxmodx/tmp3/phpeBNxUi.sma(11) : error 001: expected token: ")", but found "{"

Here is my code
Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "Client Gunz" #define VERSION "1.0" #define AUTHOR "CodeBreaker" public give_items(id,level,cid){     if(!cmd_access(id,level,cid,1) {         client_print(id,print_chat,"[AMXX] No access!")         return PLUGIN_HANDLED     }     give_item(id,"weapon_m4a1")     give_item(id,"weapon_m4a1")     give_item(id,"weapon_m4a1")     give_item(id,"weapon_m4a1")     client_print(id,print_center,"[AMXX] Weapon Added!")     return PLUGIN_HANDLED }     public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_concmd("amx_weapons","give_items",ADMIN_KICK," : Gives you some weapons") }


All times are GMT -4. The time now is 16:37.

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