Raised This Month: $ Target: $400
 0% 

Help out a nooby - Not quite grasping something


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pandaking
Senior Member
Join Date: Jun 2006
Old 11-09-2007 , 13:51   Help out a nooby - Not quite grasping something
Reply With Quote #1

Hi there, just trying to learn and I have got a long way to go.
I just have a question from reading the wiki:

Code:
register_concmd("amx_hp", "cmd_hp", ADMIN_SLAY, "<target> ")
So that registers the command "amx_hp" to be typed in the console, it runs the public function "cmd_hp", it checks the user has "admin_slay" access, and the "target" performs the action on the user that runs it.

If I was to type the command "amx_hp 1" in the console, how would I be able to access the "1"?
So for instance in my case, I want to check to see if an admin has already performed said command on him/herself.

So I would assume I use a kind of IF statement like:
Code:
IF amx_hp = 1 THEN
........ ELSE
........
My question I guess, is would it work like that, or do I need to know the location that the command is stored?
__________________

Last edited by pandaking; 11-10-2007 at 06:58.
pandaking is offline
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 11-09-2007 , 18:29   Re: Help out a nooby - Not quite grasping something
Reply With Quote #2

First, the "<target>" is nothing other than help. In other words, when you do amx_help blah blah, or just type amx_hp (without anything else) it would say Usage: amx_hp <target>. If I changed <target> to player (in the register_concmd line), then in the help menu, it would say: Usage: amx_hp <player>. It's only to help users understand how to use it, and can be omitted altogether.

Also, to find out about the value of HP, you do something with read_argv. You can read-in the value of the parameter passed and do things with it. For example:

PHP Code:
new Arg1[24]
new 
Arg2[4]
 
//Get the command arguments from the console
read_argv(1Arg123// <--- this reads the first parameter (the player)
read_argv(2Arg23// <--- this is the value of health

new Health str_to_num(Arg2)

if (
Health 1) {
    
// you have 1

BTW: The command is amx_hp <player> <health>, so <player> is argument 1, and <player is argument 2>. In the code above you wil see arg1 and arg2, so you know what is referring to what

Sorry if I explained this horribly
__________________
M249-M4A1 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 01:22.


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