Raised This Month: $ Target: $400
 0% 

Simple Script but help needed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
strikerx22
Junior Member
Join Date: Apr 2005
Old 06-25-2006 , 14:38   Simple Script but help needed
Reply With Quote #1

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.
__________________
Padme:Obi-Wan told me you killed my husband, the father of my child...
Vader:No! I am your babies Daddy!
Padme: *GASP*!?!?!?!?!?!?!
strikerx22 is offline
strikerx22
Junior Member
Join Date: Apr 2005
Old 06-26-2006 , 13:46   Re: Simple Script but help needed
Reply With Quote #2

I think my main problem is that I do not understand how to use Natives. Please help.
__________________
Padme:Obi-Wan told me you killed my husband, the father of my child...
Vader:No! I am your babies Daddy!
Padme: *GASP*!?!?!?!?!?!?!
strikerx22 is offline
Deadman0o06
Member
Join Date: Jun 2006
Old 06-26-2006 , 14:08   Re: Simple Script but help needed
Reply With Quote #3

I am a newbie to but for low gravity i saw you can use the fun engine something like set_user_gravity()
__________________
Deadman0o06 is offline
strikerx22
Junior Member
Join Date: Apr 2005
Old 06-26-2006 , 14:36   Re: Simple Script but help needed
Reply With Quote #4

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?
__________________
Padme:Obi-Wan told me you killed my husband, the father of my child...
Vader:No! I am your babies Daddy!
Padme: *GASP*!?!?!?!?!?!?!
strikerx22 is offline
BetaX
Member
Join Date: Nov 2005
Old 06-26-2006 , 14:50   Re: Simple Script but help needed
Reply With Quote #5

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.

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.

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.

Last edited by BetaX; 06-26-2006 at 14:57.
BetaX is offline
strikerx22
Junior Member
Join Date: Apr 2005
Old 06-26-2006 , 15:06   Re: Simple Script but help needed
Reply With Quote #6

Well, I honestly just started scripting 2 days ago, so any explanation for anything would help.
__________________
Padme:Obi-Wan told me you killed my husband, the father of my child...
Vader:No! I am your babies Daddy!
Padme: *GASP*!?!?!?!?!?!?!
strikerx22 is offline
strikerx22
Junior Member
Join Date: Apr 2005
Old 06-26-2006 , 16:31   Re: Simple Script but help needed
Reply With Quote #7

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.
__________________
Padme:Obi-Wan told me you killed my husband, the father of my child...
Vader:No! I am your babies Daddy!
Padme: *GASP*!?!?!?!?!?!?!
strikerx22 is offline
Deadman0o06
Member
Join Date: Jun 2006
Old 06-26-2006 , 17:01   Re: Simple Script but help needed
Reply With Quote #8

Sorry first time using it 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 i been coding for like 2 days too lol

It looks like i used the right format... not sure what went wrong.
__________________
Deadman0o06 is offline
strikerx22
Junior Member
Join Date: Apr 2005
Old 06-26-2006 , 17:45   Re: Simple Script but help needed
Reply With Quote #9

Yay xD thx. It would be cool if we worked together.
__________________
Padme:Obi-Wan told me you killed my husband, the father of my child...
Vader:No! I am your babies Daddy!
Padme: *GASP*!?!?!?!?!?!?!
strikerx22 is offline
BetaX
Member
Join Date: Nov 2005
Old 06-26-2006 , 20:09   Re: Simple Script but help needed
Reply With Quote #10

Oooooooook, let me break it down for you.

Here we have your code in whole:

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
}
Now there are some really... really... wrong things here, lol.

First of all, let's start with plugin_init();

Code:
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!")
}
OK, now, in the entry for register_concmd on http://amxmodx.org/funcwiki.php it says...

Code:
register_concmd ( const cmd[],const function[],flags=-1, info[]="" )
cmd[] = the command that you are going to put into the console, function[] is what function it is going to use, flags is where you put what access you need to use the command, and info is what you see whenever a player types it in without any arguments.

Let me say this clearly, IF YOU SET THE FLAGS AS ADMIN_KICK, YOU CANNOT USE THE COMMAND IF YOU DO NOT HAVE UP TO ADMIN_KICK ADMIN ACCESS.

YOU DO NOT NEED TO FIND OUT THEIR ACCESS.

xD

So, let's look at do_sm();

Code:
	if (!(get_user_flags(id) &ADMIN_KICK) ) {
		console_print(id,"[Striker's RP] Get Admin douche!")
		return PLUGIN_HANDLED
[/code]
OK, we can get rid of that...

Now, the next if statement,

Code:
	if (read_argc () == 0) {
		console_print (id, "[Striker's RP] Who the fuck am I supposed to turn into Superman?")
		return PLUGIN_HANDLED
	}
Alright, I see where you are going with this, but it is still very, very wrong lol.

AMXX kinda does this for you. If you were to enter no arguments, it would do nothing, so do not worry about this.

Now, we are assuming you want to type in rp_superman player'snamehere and have them be turned into superman. Well, this is kinda the wrong way to go with it.

So, instead, try this:

Code:
new arg1[256];
read_argv(1,arg1,255);

new pNum = get_playersnum(0);
new pName[256];

for (new i; i < pNum; ++i) {
         get_user_name(i,pName,255);
         
         if (equali(pName,arg1)) {
                  HEALTH(i);
         }
}

return PLUGIN_HANDLED;
PM me with specific questions, or whatever you guys are planning to do.

(Also, try to go read over the Wiki again xD )

Edit: Forgot to fix Health for you.

Code:
new HEALTH(id) {
	get_user_health(id)
	set_user_health(id, 200)

	client_cmd (id,"name Superman")
        set_hudmessage (200,100,0,-1.0,0.35,0,6.0,12.0,0.1,0.2,4);
        show_hudmessage(0,"HOMGSUPERMAN!(gaben)");        

	console_print (id,"User Is now Superman.")
	return PLUGIN_HANDLED;
}

Last edited by BetaX; 06-26-2006 at 20:13.
BetaX is offline
Reply


Thread Tools
Display Modes

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 08:03.


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