AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   First Plug. Need Help. Be Gentle. (https://forums.alliedmods.net/showthread.php?t=10389)

smdobay 02-18-2005 00:03

First Plug. Need Help. Be Gentle.
 
So then, I recently switched over my cs server from AMX mod to AMXX. However, some of the old plugs I used to have weren't available for amxx, and since I like a challenge, I decided to write some of them myself rather than converting them (which I don't know how to do anyway 8) ).

The first plugin I was trying to make was an amx_money command for admins of level h. Example:

amx_money Player 16000 ;Entered into the console.

So I read a bunch of stickes (this is my first small coding, but by no means my first time coding) and a few tutorials and came up with this:

Code:
#include <amxmodx> #include <amxmisc> #include <cstrike> #include <fun> public plugin_init() {    register_plugin("AmxxMoney","0.1","smdobay")    register_concmd("amx_money","money",ADMIN_LEVEL_H,"amx_money") } public money(id,level,cid) {      if (!cmd_access(id, level, cid, 0)) {       if (read_argc() < 2) {             console_print(id,"[AMXX] You must specify a user")             return PLUGIN_HANDLED           }       new user[32], amount, uid       read_argv(1,user,32)      read_argv(2,amount)       uid = find_player("bh",user)       if (uid == 0) {           console_print(id,"[AMXX] Invalid User Id")           return PLUGIN_HANDLED       }       client_cmd(id,"echo Player Granted Funds")                   cs_set_user_money(id,amount)           return PLUGIN_HANDLED      }       }

(In the preview my indentations aren't correct, but they are in the .sma file. I'm not that sloppy :wink: )

However, when I compiled it (no errors, just a warning about not returning a value), the server doesn't recognize amx_money as a command. And yes, before you ask, I did put it into my plugins.ini.

Thoughts? Help? Suggestions?

P.S. Rather than simply setting their money, it would be cool if I could set it to add on, but I don't know the funtion for returning a player's funds.

knekter 02-18-2005 00:09

Try using this:

Code:
new target = cmd_target(id,user,31)

Oops and also, amount needs to be indexed. Use amount[5].

smdobay 02-18-2005 00:16

I feel a little stupid. Use that line in place of what? :oops:

smdobay 02-18-2005 00:25

I feel a little stupid. Use that line in place of what? :oops:
[Edit] For some reason this posted twice....[/edit]

knekter 02-18-2005 00:25

Here
 
1 Attachment(s)
Take a look at my code.

smdobay 02-18-2005 00:27

Ah, I see now. Many thanks.

knekter 02-18-2005 00:28

NP
 
No problem, if you need any more help with anything, just post it :)

smdobay 02-18-2005 00:44

Heh. It's still not registering the command, but I don't think it's a code issue. All you need to do is put the amxx file in plugins, and add it to plugins.ini, right?

knekter 02-18-2005 00:57

lol yes do that, but I just realized, change this line:

Code:
if (!cmd_access(id, level, cid, 0)) {

to this:

Code:
if (cmd_access(id, level, cid, 0)) {

the ! says if the don't have access let them use the command... lol sorry

smdobay 02-18-2005 01:12

You da man, it recognizes the command :D

I hope by now I'm not being a bother, but somethin's still wrong. It can never find the player.

Since I don't 100% understand the code you gave me, I can't tell whether I need to input a name or ID number. But I tried it both ways with and without quotes. Still no ID found.

I'm assuming that this:
Code:
new target_id = cmd_target(id, user, 32)
is a boolean function that returns whether the user exists or something along those lines, considering the !target usage, but then why would you use it like an integer later if that were the case :?

*Needs to Brush Up on his Small*


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

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