Blockland Forums > Modification Help
onMount function not working
Monty:
Thats a good point, i was missing out the Image.
But still no activity at all.
i got some console readout on it.
--- Code: ---function swordEImage::onMount(%this,%obj,%slot)
{
if %user.##c##lient.bl_id = 159
{
//If you are Monty (ID 159)
messageClient(%obj.client,"","ID approved! You are Monty after all!");
>>> Error report complete.
Executing Add-Ons/Weapon_SwordElect.cs.
Add-Ons/Weapon_SwordElect.cs Line: 311 - Syntax error.
>>> Advanced script error report. Line 621.
>>> Some error context, with ## on sides of error halt:
function swordEImage::onMount(%this,%obj,%slot)
{
if %user.##c##lient.bl_id = 159
{
//If you are Monty (ID 159)
messageClient(%obj.client,"","ID approved! You are Monty after all!");
>>> Error report complete.
--- End code ---
Sticky:
You got that error because in the code you put in you put
--- Code: ---if %user.client.bl_id = 159
--- End code ---
Where you should have put
--- Code: ---if(%obj.client.bl_id==159)
--- End code ---
Thanks to MrPickel for picking up the %user problem.
Take note of the double equals means you're checking to an integer, wheras a $= means you're comparing it to a string. Also be aware that it is good practice (I'm not sure if it's required) to use brackets around the condition in the if statement, so where
--- Code: ---if %pie $= "yum" {}
--- End code ---
would fail,
--- Code: ---if(%pie $= "yum") {}
--- End code ---
would work.
EDIT:
Also, open the .cs file in an editor which allows you to goto lines or has the line numbers on the side, so you can check lines #311 and #621, as the console reports there are errors on at least those lines. Also, I'm not sure if the reason there is only a single equals and no brackets is the console error formatting's fault or yours, but just check anyway to make sure it's not yours.
Sticky
MrPickle:
Can you use %user even though its not in the list of arguments.
Sticky:
That's true, %user should be %obj. Updating my post, I wasn't even paying attention when I did that. Thanks.
Sticky
MrPickle:
Yey im a genius! (sarcasm)