AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Simple Script but help needed (https://forums.alliedmods.net/showthread.php?t=40263)

strikerx22 06-25-2006 14:38

Simple Script but help needed
 
Code:

#include <amxmodx>
#include <fun>

public plugin_init ( ) {
        register_plugin("Striker's Superman Plugin","0.1","Ryan 'Striker' Davis")
        register_concmd("rp_superman","do_sm",ADMIN_KICK, " Sets user to Superman!")
}
public do_sm(id) {
        if (!(get_user_flags(id) &ADMIN_KICK) ) {
                console_print(id,"[Striker's RP] Get Admin douche!")
                return PLUGIN_HANDLED
        }
        if (read_argc () == 0) {
                console_print (id, "[Striker's RP] Who the fuck am I supposed to turn into Superman?")
                return PLUGIN_HANDLED
        }
                new user[32], uid
                read_argv(1,user,32)
        uid = find_player ("bh",user)
        if (uid == 0) {
                console_print (id, "[Striker's RP] Hey, asshole, nobody here goes by that!")
                return PLUGIN_HANDLED
        }
new HEALTH(id) {
        get_user_health(id)
        set_user_health(id, 200)
}               
        client_cmd (uid,"name Superman")
        console_print (id,"User Is now Superman.")
        return PLUGIN_HANDLED
}

Basically, I just started scripting last night and it is not as easy as I thought, I am attemptying to make a plugin where, when you type in the command, the player turns into "Superman", giving him low-grav and more HP. This, as you can tell, didn't work. Please help.

strikerx22 06-26-2006 13:46

Re: Simple Script but help needed
 
I think my main problem is that I do not understand how to use Natives. Please help.

Deadman0o06 06-26-2006 14:08

Re: Simple Script but help needed
 
I am a newbie to but for low gravity i saw you can use the fun engine something like set_user_gravity()

strikerx22 06-26-2006 14:36

Re: Simple Script but help needed
 
I understand that the command is set_user_gravity, but the problem is, I dont know where to input that command, and how would I make their gravity go back to normal after they die?

BetaX 06-26-2006 14:50

Re: Simple Script but help needed
 
Code:

#include <amxmodx>
#include <fun>

public plugin_init ( ) {
        register_plugin("Striker's Superman Plugin","0.1","Ryan 'Striker' Davis")
        register_concmd("rp_superman","do_sm",ADMIN_KICK, " Sets user to Superman!")
}
public do_sm(id) {
  new user[256];
  read_argv(1,user,255);
  // The computer does not know who you are asking about. You must tell it.
  // Try looking over the natives: www.amxmodx.org/funcwiki.php?
  // (Note, I changed this to check if the player is alive. ID is your id in the server.
        if (!is_user_alive(id)) {
                console_print(id,"[Striker's RP] You must be alive to use this command.")
                return PLUGIN_HANDLED
        }

  /* This is not needed... Plus, there would be no command here.
  read_argc returns the amount of commands, and if it returned 2, the amount
  of arguments would really be 1, because it counts the command itself (in this case
  that is do_sm).
 
  If you do not enter anything, it repeats the help command.
 
  if (read_argc () == 0) {
                console_print (id, "[Striker's RP] Who the fuck am I supposed to turn into Superman?")
                return PLUGIN_HANDLED
        }*/

  // I am now telling it to go to HEALTH now, forwarding the 'id' of the player.
  HEALTH(id);
  return PLUGIN_HANDLED;
}
new HEALTH(id) {
        //get_user_health(id) We don't need to find their health if we're just gonna rewrite it. :P
        set_user_health(id, 200)
//} We don't want this. O: It'll close HEALTH before it has done its job.
        client_cmd (uid,"name Superman")
        client_print(id,print_chat,"YOU ARE NOW SUPERMAN! O:");

  new i;
  do {
    ++i;
    if (i != id) {
          client_print(i,print_chat,"Watch out! Superman is here!");
          }
        } while (i <= 32);
       
        return PLUGIN_HANDLED

}

Nice attempt, but please, read the documentation over again. :x

And keep IE or FireFox or whatever you use open so you can access amxmodx.org/funcwiki.php for whenever you need to do something creative. :D

Edit: DeathMsg byte, byte, byte, string 1: Killer ID, 2: Victim ID, 3: Headshot, 4:Weapon Name

Leeeeeeeeeeeeeeeeeeeeeeeeearn. o_o

register_event ( const event[], const function[], const flags[], [ cond=[], ... ] )

So, something along the lines of...

Code:

register_event("DeathMsg","SETNORM")
Try figuring out what to do in the function SETNORM, and post it here, we'll see how ya did.

strikerx22 06-26-2006 15:06

Re: Simple Script but help needed
 
Well, I honestly just started scripting 2 days ago, so any explanation for anything would help.

Deadman0o06 06-26-2006 16:14

Re: Simple Script but help needed
 
Quote:

Originally Posted by strikerx22
Well, I honestly just started scripting 2 days ago, so any explanation for anything would help.

Here i attempted to rewrite what you did.

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "Superman" #define VERSION ".01" #define AUTHOR "AUTHOR" public plugin_init() {  register_plugin(PLUGIN, VERSION, AUTHOR)  register_concmd("amx_superman","superman",ADMIN_KICK," :Creates a superman") } public superman(id) {  if(!(get_user_flags(id)&ADMIN_KICK)) {   console_print(id,"[SUPERMAN] You do not have access fool.")   return PLUGIN_HANDLED  }  if(read_argc() == 0) {   console_print(id,"[SUPERMAN] You did not select a user!")   return PLUGIN_HANDLED  }  new user[32], uid  read_argv(1,user,32)  uid = find_player("bh",user)  if(uid == 0) {   console_print(id,"[SUPERMAN] There is no such user!")   return PLUGIN_HANDLED  }  client_cmd(uid,"name Superman!")  set_user_gravity(uid,"0.4")  set_user_health(uid,"250")  set_user_maxpseed(uid,"2.0")  return PLUGIN_HANDLED }

No idea if it compiles or not.

strikerx22 06-26-2006 16:31

Re: Simple Script but help needed
 
Yeah, it didn't compile, I think there is something more to do with the "set_user_whatever". That's what my main dilehma is.

Deadman0o06 06-26-2006 17:01

Re: Simple Script but help needed
 
Sorry first time using it :P Hold i will go take a look at this other tutorial about set HP and i will let you know. Me and you shoudl get together and learn :P i been coding for like 2 days too lol

It looks like i used the right format... not sure what went wrong.

strikerx22 06-26-2006 17:45

Re: Simple Script but help needed
 
Yay xD thx. It would be cool if we worked together.


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

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