Liberty Unleashed
Scripting => Script Help => Topic started 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.
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?
-
Error in onPlayerCommand, is pPlayer. View the line 7, 8 and 9. You put pPlayer, is player, ( view the onPlayerCommand )
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 );
}
}
}
-
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'
-
Still not working..
-
Still not working..
You need put pPlayer not player. BadEnglish :P
-
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'
-
Try This >>
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 );
}
}
}
-
Still not working for some reason.
-
Still not working for some reason.
??? man it works fine . ??? ??? ???
-
Strange, let me see if the script file is loading it.
<script file="armour.nut" client="0"/>
Thats what is in the script.xml, I made sure the script is called "armour.nut" as well.
-
Try This >>
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 );
}
}
}
-
Yes, that worked. Thanks man.
So basically my issue was "<" should have been "!=" ?
-
8) Any Time Man 8) 8)
-
Yea, looking back the only difference is the spaces and the '<' was replaced by !=
Correct?
-
Yea, looking back the only difference is the spaces and the '<' was replaced by !=
Correct?
:-\ :(
-
Can you please tell me what I did wrong so I don't do it again?
-
Can someone tell me what I did wrong?
-
:( Man, You Can see The Error By Using Your Eyes :(
-
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:
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!
-
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:
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?
-
Yes, it should've worked the whole time.
-
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
-
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. :)