Author Topic: function SoldierMe  (Read 997 times)

Hi guys,

need a little help at my script.
It's a function that should change your datablock into a Army Men Soldier datablock.
It shouldn't work if your datablock already is a Army Men Soldier datablock

My script so far:
Code: [Select]
function serverCmdSoldierMe(%client)
{
if(isObject(%client.player))
{
if[%client.player.getdatablock().getID() == playerArmyMenSoldier.getID()
{
return;
}else{
%Player = %Client.player;
%Player.setDataBlock("ArmyMenSoldierArmor)
}
}
}

My problem:

The script does nothing so far

I hate to say this but I suggest looking at FFC AND the army man soldier player. You must have gotten the armor name wrong or something but that is a wild guess.

change where it says ArmyMenSoldier to armymansoldier and it should work.

function serverCmdSoldierMe(%client)
{
   if(isObject(%client.player))
   {
      if[%client.player.getdatablock().getID() == playerArmyMenSoldier.getID() There's no parenthesis over here and the datablock check should be different
      {
         return;
      }else{
      %Player = %Client.player;
      %Player.setDataBlock("ArmyMenSoldierArmor"); forgot other " over here and an ending ";"
      }
   }
}
------------------------------------------------
There are multiple syntaxes. Here, let me fix this...
Code: [Select]
function serverCmdSoldierMe(%client)
{
if(isObject(%client.player))
{
if(%client.player.getdatablock().getName() $= "ArmyMenSoliderArmor")
{
return;
}else{
%Player = %Client.player;
%Player.setDataBlock("ArmyMenSoldierArmor");
}
}
}
That is untested, but it should work. I don't believe you that Torque didn't explode from all that.

Code: [Select]
function serverCmdSoldierMe(%client)
{
if(isObject(%client.player))
{
if(%client.player.getdatablock().getName() $= "ArmyMenSoliderArmor")
{
return;
}else{
%Player = %Client.player;
%Player.setDataBlock("ArmyMenSoldierArmor");
}
}
}
That is untested, but it should work. I don't believe you that Torque didn't explode from all that.

Fail spelling of Soldier. Also you don't need quotes around a datablock. Its an object not a string.

But you can have quotes around it. (I'm going to paraphrase Ephialtes here) Oh no! One spelling mistake! I must be off my rocker.
I'm comparing the Name of the datablock to the String, so in this case, it's not an object, it is a string. But I still don't need the quotes, but I can have them

I'm sure you can fix that spelling mistake on "soldier" yourself

 :cookieMonster:

But you can have quotes around it. (I'm going to paraphrase Ephialtes here) Oh no! One spelling mistake! I must be off my rocker.
I'm comparing the Name of the datablock to the String, so in this case, it's not an object, it is a string. But I still don't need the quotes, but I can have them

I'm sure you can fix that spelling mistake on "soldier" yourself

 :cookieMonster:

I just pointed it out because it breaks the script. And I meant in the setDatablock, the quotes are not required (and probably shouldn't be used either because it's less efficient)


Code: [Select]
function serverCmdSoldierMe(%client)
{
if(isObject(%client.player))
{
if(%client.player.getdatablock().getName() $= "ArmyMenSoliderArmor")
{
return;
}else{
%Player = %Client.player;
%Player.setDataBlock("ArmyMenSoldierArmor");
}
}
}
Will try this, thanks
Tried it, doesn't work D:
« Last Edit: July 14, 2009, 09:51:07 AM by chilmans »

Will try this, thanks
Tried it, doesn't work D:
But you can have quotes around it. (I'm going to paraphrase Ephialtes here) Oh no! One spelling mistake! I must be off my rocker.
I'm comparing the Name of the datablock to the String, so in this case, it's not an object, it is a string. But I still don't need the quotes, but I can have them

I'm sure you can fix that spelling mistake on "soldier" yourself

 :cookieMonster:
Fix what is wrong.

I told you to replace the ArmyMenSoldier with something else. Here just try this:

function serverCmdSoldierMe(%client)
{
   if(isObject(%client.player))
   {
      if(%client.player.getdatablock().getName() $= "armymansoldierArmor")
      {
         return;
      }else{
      %Player = %Client.player;
      %Player.setDataBlock("armymansoldierArmor");
      }
   }
}

I told you to replace the ArmyMenSoldier with something else. Here just try this:

function serverCmdSoldierMe(%client)
{
   if(isObject(%client.player))
   {
      if(%client.player.getdatablock().getName() $= "armymansoldierArmor")
      {
         return;
      }else{
      %Player = %Client.player;
      %Player.setDataBlock("armymansoldierArmor");
      }
   }
}
We said no quotes around "armymansoldierArmor"

%Player.setDataBlock(armymansoldierArmor);
if(%client.player.getdatablock().getName() $= armymansoldierArmor)

I don't know if $= belongs there

We said no quotes around "armymansoldierArmor"
It will work either way, but yeah do take them off.

Fix what is wrong.
Fixed it before trying, but I think I know the problem:

I wrote ArmyMenSoldierArmor instead of armymensoldierArmor

will change this and see if it works

oh yea sorry about the quotes lol.

and its armymansoldier not men.