Liberty Unleashed

Scripting => Script Help => Topic started by: Peavy on June 05, 2013, 06:40:39 pm

Title: Armour restore script
Post by: Peavy on June 05, 2013, 06:40:39 pm
I have ran into another issue with scripting, I'm trying to make a command that restores armor however it won't even register ingame. I edited the "heal" script to work with armor but I don't think that I am using the right command.

Code: [Select]
function onPlayerCommand( player, cmd, text )
{
if ( cmd == "Armor" )
{

else if ( pPlayer.Armour < 100 )
{
Message( pPlayer + " Armour restored.", Colour( 0, 255, 0 ) );
pPlayer.Armour = 100;
}
else
{
MessagePlayer( "Your armour is full!", pPlayer );
}
}
}

Anyone know what I did wrong this time?
Title: Re: Armour restore script
Post by: Merkel on June 05, 2013, 06:54:44 pm
Error in onPlayerCommand, is pPlayer. View the line 7, 8 and 9. You put pPlayer, is player, ( view the onPlayerCommand )

Code: [Select]

function onPlayerCommand( pPlayer, cmd, text )
{
if ( cmd == "Armor" )
{

else if ( pPlayer.Armour < 100 )
{
Message( pPlayer + " Armour restored.", Colour( 0, 255, 0 ) );
pPlayer.Armour = 100;
}
else
{
MessagePlayer( "Your armour is full!", pPlayer );
}
}
}
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 07:16:16 pm
So basically I forgot the first 'p' in 'pPlayer' on the first line?
Edit:
Looking at another one of my scripts the first line is exactly the same, using 'player' not 'pPlayer'
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 07:22:23 pm
Still not working..
Title: Re: Armour restore script
Post by: Merkel on June 05, 2013, 07:37:31 pm
Still not working..

You need put pPlayer not player. BadEnglish :P
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 07:40:36 pm
Code: [Select]
function onPlayerCommand( pPlayer, cmd, text )
{
if ( cmd == "Armor" )
{
else if ( pPlayer.Armour )
{
Message( pPlayer + " Armour restored.", Colour( 0, 255, 0 ) );
pPlayer.Armour = 100;
}
}
}
This is what I used and it didn't work. I did replace 'player' with 'pPlayer'
Title: Re: Armour restore script
Post by: Mido_Pop on June 05, 2013, 07:50:11 pm
Try This >>
Code: [Select]
function onPlayerCommand( player, cmd, text )
{
if ( cmd == "Armor" )
{
          if ( player.Armour != 100 )
  {
      Message( player + " Armour restored.", Colour( 0, 255, 0 ) );
      player.Armour = 100;
  }
else
  {
MessagePlayer( "Your armour is full!", player );
  }
}
}
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 08:03:38 pm
Still not working for some reason.
Title: Re: Armour restore script
Post by: Mido_Pop on June 05, 2013, 08:05:21 pm
Still not working for some reason.

 ??? man it works fine .  ??? ??? ???
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 08:06:32 pm
Strange, let me see if the script file is loading it.

Code: [Select]
<script file="armour.nut" client="0"/>Thats what is in the script.xml, I made sure the script is called "armour.nut" as well.
Title: Re: Armour restore script
Post by: Mido_Pop on June 05, 2013, 08:17:47 pm
Try This >>
Code: [Select]
function onPlayerCommand( player, cmd, text )
{
if ( cmd == "armour" )
{
          if ( player.Armour != 100 )
  {
      Message( player + " Armour restored.", Colour( 0, 255, 0 ) );
      player.Armour = 100;
  }
else
  {
MessagePlayer( "Your armour is full!", player );
  }
}
}
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 08:32:39 pm
Yes, that worked. Thanks man.

So basically my issue was "<" should have been "!=" ?
Title: Re: Armour restore script
Post by: Mido_Pop on June 05, 2013, 08:34:45 pm
 8) Any Time Man  8) 8)
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 08:37:19 pm
Yea, looking back the only difference is the spaces and the '<' was replaced by !=
Correct?
Title: Re: Armour restore script
Post by: Mido_Pop on June 05, 2013, 08:40:11 pm
Yea, looking back the only difference is the spaces and the '<' was replaced by !=
Correct?

 :-\  :(
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 08:45:03 pm
Can you please tell me what I did wrong so I don't do it again?
Title: Re: Armour restore script
Post by: Peavy on June 05, 2013, 10:27:13 pm
Can someone tell me what I did wrong?
Title: Re: Armour restore script
Post by: Mido_Pop on June 06, 2013, 08:01:57 am
 :( Man, You Can see The Error By Using Your Eyes  :(
Title: Re: Armour restore script
Post by: Vortrex on June 06, 2013, 04:36:08 pm
Well, I see in your first example that you capitalized the "A" in the word "Armour". Because of this, the player would be required to enter /Armour exactly (with the capital A).

Here's a suggestion. Use the following snippet to allow case-insensitive commands:
Code: [Select]
if( cmd.tolower() == "armour" )Just be sure to make the command string that you are checking for is lowercase when you script it. ( Referring to the "armour" part ).

I'm not sure if this is your problem, but I hope this helps!
Title: Re: Armour restore script
Post by: Peavy on June 07, 2013, 09:26:24 pm
Well, I see in your first example that you capitalized the "A" in the word "Armour". Because of this, the player would be required to enter /Armour exactly (with the capital A).

Here's a suggestion. Use the following snippet to allow case-insensitive commands:
Code: [Select]
if( cmd.tolower() == "armour" )Just be sure to make the command string that you are checking for is lowercase when you script it. ( Referring to the "armour" part ).

I'm not sure if this is your problem, but I hope this helps!
Alright, thanks. I hadn't known that commands were so case sensitive.
So the entire time the command actually worked?
Title: Re: Armour restore script
Post by: Vortrex on June 08, 2013, 04:59:47 am
Yes, it should've worked the whole time.
Title: Re: Armour restore script
Post by: Peavy on June 08, 2013, 09:57:53 pm
Yes, it should've worked the whole time.
o
Oh wow, I feel dumb now.
Alright guys, thanks for the help. I'll be sure to note down that things are case sensitive
Title: Re: Armour restore script
Post by: SugarD on June 17, 2013, 05:15:44 am
Personally I would also recommend including an alias to the command also, as American players often spell that word as "armor", and British players spell it as "armour". The variation in the English dialects may throw some people off. :)