AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Still feeling like a real idiot... (https://forums.alliedmods.net/showthread.php?t=12474)

BioHazardousWaste 04-16-2005 16:00

Still feeling like a real idiot...
 
Ok guys, thanx for the help so far... but just wondering about the teleport menu, can't seem to get it working.

amx_teleportmenu does nothing

So, that is hopefully my only amxmodx stupid question. But I'm going to go write a script that allows me to heal myself (again, i'm not going to keep this, just trying to figure it all out lol.) So i'll probably have a few questions soon...

EDIT:
And what exactly is the id variable?

Oh yeah, and one more nub question I have... how do I have a multi line message. You know, the message you have shown in amxx.cfg every x seconds? I did this:

// Center typed colored messages (last parameter is a color in RRRGGGBBB format)
amx_imessage "Welcome to %hostname% - The one and only 1337CS Beta Server!" "000255100"
amx_imessage "Testing, Programming, and Brainstorming positions are open!" "000255100"
amx_imessage "For more info contact Smooth Criminal, or another admin! "000255100"

But what that did was play one every x seconds instead of 3 lines instead of displaying all 3 every x seconds.

v3x 04-16-2005 16:43

Fun module is required.

BioHazardousWaste 04-16-2005 17:24

ok, thanx, got that all figured out.. still wondering what the id variable is though? is it ALWAYS the person who typed the command?

v3x 04-16-2005 17:32

Yes.

XxAvalanchexX 04-16-2005 17:32

Quote:

Originally Posted by BioHazardousWaste
ok, thanx, got that all figured out.. still wondering what the id variable is though? is it ALWAYS the person who typed the command?

In the case of register_clcmd and register_concmd, the first parameter of your function to handle it (whether it be named "id", "index", "catwoman") will be the ID of the player that called the command.

BioHazardousWaste 04-16-2005 18:10

oh my god, now i really feel like an idiot.. it's the return of a function... wow... i'm speechless (almost)... *throws he at feet*

BioHazardousWaste 04-16-2005 19:35

Ok, I did pretty well I think.. wrote a heal script without posting and got it to compile :). Problem is it doesn't work... not sure what the hell is going on here! I did a debug and i got this error

Quote:

L 04/16/2005 - 19:23:42: [AMXX] Native error in "get_user_aiming" on line 18 (file "phpShJQLn.sma").
Here's the code:
Code:
//Include Files #include <amxmodx> #include <fun> #define MAX_PLAYERS 33 //Initializing Function (main) public plugin_init() {    register_plugin("Heal", "1.00", "Steve0")    register_concmd("17_Heal", "heal") //God damn broken! } public heal() {         new health     new target, bodypart, id         get_user_aiming(id, target, bodypart) //line 18     if (target = 0)     {         health = get_user_health(id)         if(health >= 100)         {             client_print(id, print_chat, "YOU ALREADY HAVE FULL HP!")             return PLUGIN_HANDLED         }         new health = get_user_health(id)         set_user_health(id,health + 10)                 if (get_user_health(id) > 100)          set_user_health(id, 100)         return PLUGIN_HANDLED     }         if ((0 < target <= 31) && (is_user_alive(id)) && (is_user_alive(target)))     {         new name[32], fname[32]         get_user_name(id, name, 31)         get_user_name(target, fname, 31)               health = (get_user_health(target))         if (health >= 100)         {                 client_print(id, print_chat, "%s does not have wounds to be mended at this time", fname)             return PLUGIN_HANDLED         }         health = (get_user_health(target))         set_user_health (target, health + 20)                 health = (get_user_health(target))                 if(health >= 100)         set_user_health (target, 100)                 return PLUGIN_HANDLED     } return PLUGIN_HANDLED     }

Please help.. thanx (for interests sake, I couldn't find that file in my steam directory and subdirectories)

v3x 04-16-2005 19:46

Try
Code:
public heal(id) {         new health     new target, bodypart     // .. }

BioHazardousWaste 04-16-2005 19:55

Ok, thanx that got rid of the error... but now nothing happens, or nothing appears to happen. Am I correct in assuming it's a logical coding error? On compile I got the following warnings:

/home/groups/amxmodx/tmp/phpkFBMfI.sma(19) : warning 211: possibly unintended assignment

and

/home/groups/amxmodx/tmp/phpkFBMfI.sma(27) : warning 219: local variable "health" shadows a variable at a preceding level

Would one of those two be causing the problem? Also, is there a way to get rid of /home/groups/amxmodx/tmp/phpkFBMfI.sma(57) : warning 217: loose indentation and does it really matter?

Thanx again

v3x 04-16-2005 20:05

Code:
// Line 19 if (target = 0) // Should be if (target == 0) // OR if (!target)
Code:
// Line 27 - You already created that variable new health = get_user_health(id) // So .. -> health = get_user_health(id)

As for your loose-indentation warnings, ignore them (or fix them). Also, you could use Avalanche's online-indenter. :)


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

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