Blockland Forums > Modification Help
onMount function not working
Monty:
I can't see whats wrong with the code in the onMount function.
It's supposed to unmount itself if the wrong person attempts to equipt the sword.
--- Code: ---function swordE::onMount(%this,%user,%obj,%slot)
{
//If your monty
Parent::onMount(%this,%obj,%slot);
if %user.bl_id = 159
{
//You are 100% monty so i'll mount myself
%user.mountimage(%this.image, %mountPoint);
messageClient(%user,"","ID approved! You are monty after all!");
}
else
//If yer not
{
//What the?! Your not monty! I'm dismounting!
%user.unMountImage(%mountPoint);
//%user.kill($DamageType::Misuse);
messageClient(%user,"","Wrong user");
}
}
--- End code ---
Space Guy:
--- Code: ---function swordE::onMount(%this,%obj,%slot)
{
if %user.client.bl_id = 159
{
//If you are Monty (ID 159)
messageClient(%obj.client,"","ID approved! You are Monty after all!");
Parent::onMount(%this,%obj,%slot);
}
else
{
//You aren't Monty
%obj.kill($DamageType::Self Delete);
messageClient(%obj.client,"","Only Monty (BL_ID 159) can use this sword.");
}
}
--- End code ---
Try that. Unsure whether it works.
-=>RR<=-MasterCE:
--- Code: --- if %user.client.bl_id = 159
--- End code ---
Should be
--- Code: --- if(%user.client.bl_id == 159)
--- End code ---
Monty:
neither seem to make any difference.
i don't get any messages when it mounts or anything.
Space Guy:
Wait, is the weaponImage "swordE" or "swordEImage"? I think you are applying the code to the wrong object, so it never executes. Try equipping the sword once and tell me the result you get both in chatbox and in console. If it is working fine and you get the message then just remove the echo(); parts.
--- Code: ---function swordE::onMount(%this,%obj,%slot)
{
if(%obj.client.bl_id == 159)
{
//If you are Monty (ID 159)
echo("ID Approved");
messageClient(%obj.client,"","ID approved! You are Monty after all!");
Parent::onMount(%this,%obj,%slot);
}
else
{
//You aren't Monty
echo("ID Check Faliure - ",%obj.client.bl_id);
%obj.kill($DamageType::Self Delete);
messageClient(%obj.client,"","Only Monty (BL_ID 159) can use this sword.");
}
}
--- End code ---