Author Topic: Armour restore script  (Read 3807 times)

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Armour restore script
« 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?

Merkel

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +4/-10
    • View Profile
Re: Armour restore script
« Reply #1 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 );
}
}
}
« Last Edit: June 05, 2013, 07:02:37 pm by TheWarfare968 »
Westwood Studios

The best studios company in strategy videogames.

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Armour restore script
« Reply #2 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'
« Last Edit: June 05, 2013, 07:19:26 pm by Peavy »

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Armour restore script
« Reply #3 on: June 05, 2013, 07:22:23 pm »
Still not working..

Merkel

  • Jr. Member
  • **
  • Posts: 89
  • Karma: +4/-10
    • View Profile
Re: Armour restore script
« Reply #4 on: June 05, 2013, 07:37:31 pm »
Still not working..

You need put pPlayer not player. BadEnglish :P
Westwood Studios

The best studios company in strategy videogames.

Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Armour restore script
« Reply #5 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'

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Armour restore script
« Reply #6 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 );
  }
}
}



Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Armour restore script
« Reply #7 on: June 05, 2013, 08:03:38 pm »
Still not working for some reason.

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Armour restore script
« Reply #8 on: June 05, 2013, 08:05:21 pm »
Still not working for some reason.

 ??? man it works fine .  ??? ??? ???



Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Armour restore script
« Reply #9 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.
« Last Edit: June 05, 2013, 08:09:01 pm by Peavy »

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Armour restore script
« Reply #10 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 );
  }
}
}
« Last Edit: June 05, 2013, 08:19:56 pm by Mido_Pop »



Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Armour restore script
« Reply #11 on: June 05, 2013, 08:32:39 pm »
Yes, that worked. Thanks man.

So basically my issue was "<" should have been "!=" ?

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Armour restore script
« Reply #12 on: June 05, 2013, 08:34:45 pm »
 8) Any Time Man  8) 8)



Peavy

  • Newbie
  • *
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: Armour restore script
« Reply #13 on: June 05, 2013, 08:37:19 pm »
Yea, looking back the only difference is the spaces and the '<' was replaced by !=
Correct?

Mido_Pop

  • Full Member
  • ***
  • Posts: 168
  • Karma: +6/-20
  • The_Pops ( War )
    • View Profile
Re: Armour restore script
« Reply #14 on: June 05, 2013, 08:40:11 pm »
Yea, looking back the only difference is the spaces and the '<' was replaced by !=
Correct?

 :-\  :(



 

© Liberty Unleashed Team.