Blockland Forums > Modification Help
If Containing
(1/4) > >>
jes00:
How would I check to see if a variable contains something like if(%var Something "@Pig ") and then check the thing after it not using variables.
Port:
if( strPos( %var, "@Pig ") => 0 )

If you want case-insensitivity, use striPos instead.
Also, if you want to get the text after the occurrence of "@Pig ", use:
if( ( %pos = strPos( %var, "@Pig ") ) => 0 )
    %after = getSubStr( %var, %pos + strLen( "@Pig " ), strLen( %var ) )
jes00:

--- Quote from: Port on December 10, 2011, 08:30:25 AM ---if( strPos( %var, "@Pig ") => 0 )

If you want case-insensitivity, use striPos instead.
Also, if you want to get the text after the occurrence of "@Pig ", use:
if( ( %pos = strPos( %var, "@Pig ") ) => 0 )
    %after = getSubStr( %var, %pos + strLen( "@Pig " ), strLen( %var ) )

--- End quote ---
Syntax error in if( strPos( %var, "@Pig ") => 0 )
Port:
Uh, what. Make sure there isn't any extra/missing parenthesis or brackets above.
jes00:

--- Quote from: Port on December 10, 2011, 10:07:29 AM ---Uh, what. Make sure there isn't any extra/missing parenthesis or brackets above.

--- End quote ---

--- Code: ---package atCommands {


function clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg)
{
parent::clientCmdChatMessage(%a, %b, %c, %fmsg, %cp, %name, %cs, %msg);

if(strPos(%msg,"@Test ") => 0))
{
%Word = getSubStr( %msg, %pos + strLen( "@Test " ), strLen( %var ) )
if(%Word $= "a")
{
commandToServer('messageSent',"Test: Success!");
}
}
}


}; activatePackage(atCommands);

--- End code ---
Navigation
Message Index
Next page

Go to full version