AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help my noob code please! (https://forums.alliedmods.net/showthread.php?t=27884)

hlstriker 05-01-2006 16:20

Help my noob code please!
 
Hi, could someone tell me what I screwed up on here... I am new to coding like this, I know some Pascal, Java, and Visual Basic from school... so i'm not a total noob coder :D! Anyhow, this fails to compile... it is a plugin for the mod TFC and is supposed to check the super nailguns ammo, and if it goes below 50 ammo, it should keep the ammo at 50.

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <tfcx> #define PLUGIN "NoName" #define VERSION "1.0" #define AUTHOR "hlstriker" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     return PLUGIN_CONTINUE } public ammoCheck() {     tfc_getweaponbammo ( id, TFC_WPN_SUPERNG )     If (tfc_getweaponbammo < 50)    {         tfc_setweaponbammo ( id, TFC_WPN_SUPERNG, 50)     }     return PLUGIN_CONTINUE }

v3x 05-01-2006 16:22

You need to find a list of TFC events. Although they should be the same as regular HL events.

Xanimos 05-01-2006 16:23

You don't ever set up the variable "id"

I don't know if that function is a forward or not I don't know tfc.

but if you had
public ammoCheck(id)
it would compile

v3x 05-01-2006 16:28

Re: Help my noob code please!
 
You could try this:
Code:
#include <amxmodx> #include <amxmisc> #include <tfcx> #define PLUGIN "NoName" #define VERSION "1.0" #define AUTHOR "hlstriker" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_event("AmmoX" , "ammoCheck" , "b");     return PLUGIN_CONTINUE } public ammoCheck(id) {     new ammo = tfc_getweaponbammo ( id, TFC_WPN_SUPERNG )     if (ammo < 50) {         tfc_setweaponbammo ( id, TFC_WPN_SUPERNG, 50)     }     return PLUGIN_CONTINUE }

hlstriker 05-01-2006 16:51

Thanks for the replies. Even with what you posted v3x, it still compiles with errors.

Quote:

/home/users/amxmodx/tmp3/phpWfdBJ1.sma(20) : error 017: undefined symbol "id"
/home/users/amxmodx/tmp3/phpWfdBJ1.sma(20) : warning 215: expression has no effect
/home/users/amxmodx/tmp3/phpWfdBJ1.sma(20) : error 001: expected token: ";", but found ")"
/home/users/amxmodx/tmp3/phpWfdBJ1.sma(20) : error 029: invalid expression, assumed zero
/home/users/amxmodx/tmp3/phpWfdBJ1.sma(20) : fatal error 107: too many error messages on one line

v3x 05-01-2006 16:52

It compiles fine for me.

Xanimos 05-01-2006 17:00

I think he still left out the (id) in the function header.

hlstriker 05-01-2006 17:01

Hmm, i'm using the compiler on the amxmodx.org website. The AMXX-Studio doesn't seem to work for me.

I got the id in the function header too.

Zenith77 05-01-2006 17:13

post your current code

hlstriker 05-01-2006 17:20

I got it working, I tested exactly what v3x has posted to compile, and that didn't work. I guess my firefox doesn't like to upload the sma files, I had to copy and paste the code to compile it.

Anyhow, the plugin works, but sometimes I see the ammo go into the 40s then shoot back up to 50. Is there a way to make it always be at 50?

Thank you everyone for your help, i'm sure i'll be needing you all later on :D! I'm really motivated to learn this.


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

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