| Blockland Forums > Modification Help |
| If Strstr Syntax Error in client-side script |
| (1/2) > >> |
| frogger3140:
Please fix this script problem... --- Code: (Console Log) ---Client checking Add-On: Client_FrogCM Loading Add-On: Client_FrogCM (CRC:-606936464) Add-Ons/Client_FrogCM/client.cs Line: 57 - Syntax error. >>> Some error context, with ## on sides of error halt: ^^^commandtoserver('messagesent', "FrogCM Math: Calculates the square root of X and returns the result."); ^^} ^^else ^^{ ^^^commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent"); ^^} ^} ^if(##s##trstr("%msg","@math") == 0) ^{ ^^commandtoserver('messagesent', "FrogCM Math: Calculating..."); ^^{ ^^if(strstr("%msg","trig") == 1) ^^^commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2"); ^^} ^^else if(strstr("%msg","add") == 1) ^^{ ^^^commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "+" @ getword(%msg, 3) SPC "=" @ getword(%msg, 2) + getword(%msg, 3)); >>> Error report complete. ADD-ON "Client_FrogCM" CONTAINS SYNTAX ERRORS --- End code --- --- Code: (TorqueScript) ---warn("Loading FrogCM v0.1.2 (Unstable)"); package FrogCM { function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg) //srs chat mod here bro { if(%msg $= "@about") commandtoserver('messagesent', "FrogCM v0.1.2: Made by Frogger3140."); if(%msg $= "@cake") commandtoserver('messagesent', "You," SPC %name @ ", deserve" SPC getrandom(10, 99) SPC "cakes!"); if(strstr("%msg","@mhelp") == 0) commandtoserver('messagesent', "FrogCM Math: Looking for help topic..."); if(strstr("%msg","trig") == 1) { commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2"); } else if(strstr("%msg","add") == 1) { commandtoserver('messagesent', "FrogCM Math: @math add x y"); commandtoserver('messagesent', "FrogCM Math: Adds X and Y and returns the result."); } else if(strstr("%msg","subtract") == 1) { commandtoserver('messagesent', "FrogCM Math: @math subtract x y"); commandtoserver('messagesent', "FrogCM Math: Subtracts X and Y and returns the result."); } else if(strstr("%msg","multiply") == 1) { commandtoserver('messagesent', "FrogCM Math: @math multiply x y"); commandtoserver('messagesent', "FrogCM Math: Multiplies X and Y and returns the result."); } else if(strstr("%msg","divide") == 1) { commandtoserver('messagesent', "FrogCM Math: @math divide x y"); commandtoserver('messagesent', "FrogCM Math: Divides X and Y and returns the result."); } else if(strstr("%msg","intdivide") == 1) { commandtoserver('messagesent', "FrogCM Math: @math intdivide x y"); commandtoserver('messagesent', "FrogCM Math: Divides X and Y and returns the result with its remainder."); } else if(strstr("%msg","exponent") == 1) { commandtoserver('messagesent', "FrogCM Math: @math exponent x y"); commandtoserver('messagesent', "FrogCM Math: Calculates X to the power of Y and returns the result."); } else if(strstr("%msg","squareroot") == 1) { commandtoserver('messagesent', "FrogCM Math: @math squareroot x"); commandtoserver('messagesent', "FrogCM Math: Calculates the square root of X and returns the result."); } else { commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent"); } } if(strstr("%msg","@math") == 0) { commandtoserver('messagesent', "FrogCM Math: Calculating..."); { if(strstr("%msg","trig") == 1) commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2"); } else if(strstr("%msg","add") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "+" @ getword(%msg, 3) SPC "=" @ getword(%msg, 2) + getword(%msg, 3)); } else if(strstr("%msg","subtract") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "-" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) - getword(%msg, 3)); } else if(strstr("%msg","multiply") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "*" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) * getword(%msg, 3)); } else if(strstr("%msg","divide") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "/" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) / getword(%msg, 3)); } else if(strstr("%msg","intdivide") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "/" @ getword(%msg, 3) SPC "=" SPC mFloor(getword(%msg, 2) / getword(%msg, 3)) SPC "r" @ getword(%msg, 2) % getword(%msg, 3)); } else if(strstr("%msg","exponent") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "^" @ getword(%msg, 3) SPC "=" SPC mPow(getword(%msg, 2), getword(%msg, 3))); } else if(strstr("%msg","squareroot") == 1) { commandtoserver('messagesent', "FrogCM Math: sqrt" SPC getword(%msg, 2) SPC "=" SPC mSqrt(getword(%msg, 2))); } else { commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent"); } } if(%msg $= "@help") { commandtoserver('messagesent', "FrogCM Commands: @about: About FrogCM. @help: FrogCM Help. @cake: CAKE."); commandtoserver('messagesent', "FrogCM Math: Use @mhelp Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, or Exponent"); } parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg); } }; activatepackage(FrogCM); echo("FrogCM Load Success!"); --- End code --- |
| ZSNO:
Fixed, added correct spacing: --- Code: ---package FrogCM { function clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg) //srs chat mod here bro { if(%msg $= "@about") commandtoserver('messagesent', "FrogCM v0.1.2: Made by Frogger3140."); if(%msg $= "@cake") commandtoserver('messagesent', "You," SPC %name @ ", deserve" SPC getrandom(10, 99) SPC "cakes!"); if(strstr("%msg","@mhelp") == 0) { commandtoserver('messagesent', "FrogCM Math: Looking for help topic..."); if(strstr("%msg","trig") == 1) { commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2"); } else if(strstr("%msg","add") == 1) { commandtoserver('messagesent', "FrogCM Math: @math add x y"); commandtoserver('messagesent', "FrogCM Math: Adds X and Y and returns the result."); } else if(strstr("%msg","subtract") == 1) { commandtoserver('messagesent', "FrogCM Math: @math subtract x y"); commandtoserver('messagesent', "FrogCM Math: Subtracts X and Y and returns the result."); } else if(strstr("%msg","multiply") == 1) { commandtoserver('messagesent', "FrogCM Math: @math multiply x y"); commandtoserver('messagesent', "FrogCM Math: Multiplies X and Y and returns the result."); } else if(strstr("%msg","divide") == 1) { commandtoserver('messagesent', "FrogCM Math: @math divide x y"); commandtoserver('messagesent', "FrogCM Math: Divides X and Y and returns the result."); } else if(strstr("%msg","intdivide") == 1) { commandtoserver('messagesent', "FrogCM Math: @math intdivide x y"); commandtoserver('messagesent', "FrogCM Math: Divides X and Y and returns the result with its remainder."); } else if(strstr("%msg","exponent") == 1) { commandtoserver('messagesent', "FrogCM Math: @math exponent x y"); commandtoserver('messagesent', "FrogCM Math: Calculates X to the power of Y and returns the result."); } else if(strstr("%msg","squareroot") == 1) { commandtoserver('messagesent', "FrogCM Math: @math squareroot x"); commandtoserver('messagesent', "FrogCM Math: Calculates the square root of X and returns the result."); } else { commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent"); } } if(strstr("%msg","@math") == 0) { commandtoserver('messagesent', "FrogCM Math: Calculating..."); { if(strstr("%msg","trig") == 1) commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2"); } else if(strstr("%msg","add") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "+" @ getword(%msg, 3) SPC "=" @ getword(%msg, 2) + getword(%msg, 3)); } else if(strstr("%msg","subtract") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "-" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) - getword(%msg, 3)); } else if(strstr("%msg","multiply") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "*" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) * getword(%msg, 3)); } else if(strstr("%msg","divide") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "/" @ getword(%msg, 3) SPC "=" SPC getword(%msg, 2) / getword(%msg, 3)); } else if(strstr("%msg","intdivide") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "/" @ getword(%msg, 3) SPC "=" SPC mFloor(getword(%msg, 2) / getword(%msg, 3)) SPC "r" @ getword(%msg, 2) % getword(%msg, 3)); } else if(strstr("%msg","exponent") == 1) { commandtoserver('messagesent', "FrogCM Math:" SPC getword(%msg, 2) @ "^" @ getword(%msg, 3) SPC "=" SPC mPow(getword(%msg, 2), getword(%msg, 3))); } else if(strstr("%msg","squareroot") == 1) { commandtoserver('messagesent', "FrogCM Math: sqrt" SPC getword(%msg, 2) SPC "=" SPC mSqrt(getword(%msg, 2))); } else { commandtoserver('messagesent', "FrogCM Math: Invalid Function: Functions are Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, and Exponent"); } } if(%msg $= "@help") { commandtoserver('messagesent', "FrogCM Commands: @about: About FrogCM. @help: FrogCM Help. @cake: CAKE."); commandtoserver('messagesent', "FrogCM Math: Use @mhelp Trig, Add, Subtract, Multiply, Divide, Intdivide, SquareRoot, or Exponent"); } parent::clientcmdChatMessage(%client,%b,%c,%all,%PreTag,%name,%postTag,%msg); } }; activatepackage(FrogCM); --- End code --- |
| phflack:
you could've edited the first post and also, the ##(letter)## means that there is an error before it, i think and in this case, you had an extra { right above it commandtoserver('messagesent', "FrogCM Math: Calculating..."); { if(strstr("%msg","trig") == 1) commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2"); } should turn into commandtoserver('messagesent', "FrogCM Math: Calculating..."); if(strstr("%msg","trig") == 1) { commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2"); } or commandtoserver('messagesent', "FrogCM Math: Calculating..."); if(strstr("%msg","trig") == 1) commandtoserver('messagesent', "FrogCM Trig: Will be added in v0.2"); |
| MegaScientifical:
--- Quote from: phflack on December 12, 2010, 09:42:19 PM ---you could've edited the first post --- End quote --- ZNSO can edit frogger3140's posts? Is he some kind of hacker? |
| Bauklotz:
You should really use some kind of command system, like --- Code: ---package FrogCM { function clientCmdChatMessage(%cl,%a,%b,%line,%pre,%name,%suf,%msg,%x) { Parent::clientCmdChatMessage(%cl,%a,%b,%line,%pre,%name,%suf,%msg,%x); if(getSubStr(%msg,0,1) $= "@") { %msg = getSubStr(%msg,1,strLen(%msg)); %cmd = firstWord(%msg); %arg = restWords(%msg); if(isFunction(%func = "frogCmd" @ %cmd)) call(%func, %name, %arg); } } }; function frogCmdDie(%name, %arg) { if(%arg $= "horribly") crash(); else quit(); } --- End code --- |
| Navigation |
| Message Index |
| Next page |