AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   this plugin keeps killing everyone :( help (https://forums.alliedmods.net/showthread.php?t=45830)

Da_sk8rboy 10-12-2006 16:13

this plugin keeps killing everyone :( help
 
Okay, the plugin works out so far, im half way done with it,

Desciption:

First Part: (Finished) Sets health on the target typed in console by an Admin.

Second Part: (Still working on) When the command is used, the target gets #1 health, and #2 a Spider-man.mdl (YES IT MAKES NO SENSE! SPIDER-MAN??) its just for fun. when i am finished this will not be advertised.

Problem with the plugin so far:

#1 when i use the command, it does not give the target health, instead it kills everyone on the team the target is on.

I dont know what to do. Here is the Script:

Code:

/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
#define PLUGIN "Admin_health"
#define VERSION "1.0"
#define AUTHOR "HeadxShot"
 
 // Add your code here...
public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_concmd("amx_hp", "cmd_hp", ADMIN_SLAY, "<target> <hp>")
}
 
public cmd_hp(id, level, cid)
{
    if (!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED
 
    new Arg1[24]
    new Arg2[4]
 
    //Get the command arguments from the console
    read_argv(1, Arg1, 23)
    read_argv(2, Arg2, 3)
 
    //Convert the health from a string to a number
    new Health = str_to_num(Arg2)
 
    //Is the first character the @ symbol?
    if (Arg1[0] == '@')
    {
          new Team = 0
          if (equali(Arg1[1], "CT"))
          {
              Team = 2
          } else if (equali(Arg1[1], "T")) {
              Team = 1
          }
          new players[32], num
          get_players(players, num)
          new i
          for (i=0; i<num; i++)
          {
              if (!Team)
              {
                    set_user_health(players[i], Health)
              } else {
                    if (get_user_team(players[i]) == Team)
                    {
                        set_user_health(players[i], Health)
                    }
              }
          }
    } else {
          new player = cmd_target(id, Arg1, 1)
          if (!player)
          {
              console_print(id, "Sorry, player %s could not be found or targetted!", Arg1)
              return PLUGIN_HANDLED
          } else {
              set_user_health(player, Health)
          }
    }
 
    return PLUGIN_HANDLED
   
  }


MaximusBrood 10-12-2006 17:07

Re: this plugin keeps killing everyone :( help
 
Appearantly your plugin is setting health to 0.
You need to learn to debug. Just put in a line of debug code, to see if argument handling and str_to_num() is done correctly.

You also might want to check if the health that was given is valid.

Code:
if( !(0 < Health <= 100) )      return PLUGIN_HANDLED;

---

Here is your code with the debug line in it:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> #define PLUGIN "Admin_health" #define VERSION "1.0" #define AUTHOR "HeadxShot"    // Add your code here... public plugin_init() {      register_plugin(PLUGIN, VERSION, AUTHOR)      register_concmd("amx_hp", "cmd_hp", ADMIN_SLAY, "<target> <hp>") }   public cmd_hp(id, level, cid) {      if (!cmd_access(id, level, cid, 3))         return PLUGIN_HANDLED        new Arg1[24]      new Arg2[4]        //Get the command arguments from the console      read_argv(1, Arg1, 23)      read_argv(2, Arg2, 3)        //Convert the health from a string to a number      new Health = str_to_num(Arg2)      client_print(id, print_console, "The health that was recieved was -> String: '%s' -> Integer: '%d'", Arg2, Health);        //Is the first character the @ symbol?      if (Arg1[0] == '@')      {           new Team = 0           if (equali(Arg1[1], "CT"))           {                Team = 2           } else if (equali(Arg1[1], "T")) {                Team = 1           }           new players[32], num           get_players(players, num)           new i           for (i=0; i<num; i++)           {                if (!Team)                {                     set_user_health(players[i], Health)                } else {                     if (get_user_team(players[i]) == Team)                     {                          set_user_health(players[i], Health)                     }                }           }      } else {           new player = cmd_target(id, Arg1, 1)           if (!player)           {                console_print(id, "Sorry, player %s could not be found or targetted!", Arg1)                return PLUGIN_HANDLED           } else {                set_user_health(player, Health)           }      }        return PLUGIN_HANDLED          }

MaximusBrood 10-12-2006 17:18

Re: this plugin keeps killing everyone :( help
 
newbie1233, your whole post is rubbish. Not a single statement in it is correct.

EDIT: Oh, I see you removed it...

MaximusBrood 10-12-2006 17:27

Re: this plugin keeps killing everyone :( help
 
I'm not your "mate".
When you want to help someone please help yourself and everyone here by not posting anything.
You think you know how to script, but you don't.

I'm not asking for a discussion, just don't react.

---

If anyone is wondering what he posted, this is it:

Quote:

Originally Posted by newbie1233
Code:
#include <amxmodx> #include <amxmisc> #include <engine> //Needs a engine to set user the health #include <fun> #include <cstrike> #define PLUGIN "Admin_health" #define VERSION "1.0" #define AUTHOR "HeadxShot"

make sure there is a space for each one as include and define is different


Code:
cmd_hp needs to be cmdhp

Code:
public cmdhp(id, level, cid) {     if (!cmd_access(id, level, cid, 3))        return PLUGIN_HANDLED     new Arg1[2] //needs to be 2     new Arg2[3]  //needs to be 3     //Get the command arguments from the console     read_argv(1, Arg1, 2)  //needs to be 2     read_argv(2, Arg2, 3)   //same as it is

Code:
    register_concmd("amx_hp", "cmd_hp", ADMIN_LEVEL_A, "<target> <hp>")


newbie1233 10-12-2006 17:37

Re: this plugin keeps killing everyone :( help
 
dont triple post plz ur making that bull shit up fuck head

MaximusBrood 10-12-2006 17:38

Re: this plugin keeps killing everyone :( help
 
Pathetic. I look like I'm tripple posting because you are constantly deleting your posts.

LittleDude 10-12-2006 20:45

Re: this plugin keeps killing everyone :( help
 
newbie1233 apparently you can't see the parts where it says "Post deleted by newbie1233..." or whatever, log out as a user and come back to this forum and you'll see it, so you're just being a jackass, no wonder you have negative karma

newbie1233 10-13-2006 04:03

Re: this plugin keeps killing everyone :( help
 
Does it matter about karma no i dont give a fuck u jackass up urs

MaximusBrood 10-13-2006 09:15

Re: this plugin keeps killing everyone :( help
 
SHUT UP. Now. Thank you.


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

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