[SOLVED] How do I create a variable thing like (!VER)? |
Author: |
Message: |
Agret
Junior Member
Posts: 23
35 / / –
Joined: Dec 2003
|
O.P. [SOLVED] How do I create a variable thing like (!VER)?
How do I create a variable thing like (!VER)?
I want it so that when a person writes (!MEH) it's auto-replaced by a variable from my script, how can I accomplish this?
This post was edited on 12-01-2006 at 02:17 PM by Agret.
(¯`·._¤²°°²Agret²°°²¤_.·´¯)
¸.-~·*'˜¨¯Ï”m_†hê_ôñë_åñd_õñl¥_Åg®ê†¨˜'*·~-.¸
|
|
12-01-2006 07:43 AM |
|
|
markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
Joined: Jan 2006
|
RE: How do I create a variable thing like (!VER)?
code: function OnEvent_ChatWndSendMessage(Wnd,Msg){
...
Msg = Msg.replace(/\(\!MEH\)/g,variable);//replace (!MEH) with string in variable
..
}
If you want it to be case insensitive then use gi rather than just g. This just uses regular expressions, which I highly recommend for all scripters to learn.
|
|
12-01-2006 07:48 AM |
|
|
Agret
Junior Member
Posts: 23
35 / / –
Joined: Dec 2003
|
O.P. RE: How do I create a variable thing like (!VER)?
Thanks a lot markee, you have been helpful. This forum should get a thanks mod installed
(¯`·._¤²°°²Agret²°°²¤_.·´¯)
¸.-~·*'˜¨¯Ï”m_†hê_ôñë_åñd_õñl¥_Åg®ê†¨˜'*·~-.¸
|
|
12-01-2006 08:03 AM |
|
|
NiteMare
Veteran Member
Giga-Byte me
Posts: 2497 Reputation: 37
37 / /
Joined: Aug 2003
|
RE: How do I create a variable thing like (!VER)?
quote: Originally posted by markee
This just uses regular expressions, which I highly recommend for all scripters to learn.
thats like a whole nother language in itself
|
|
12-01-2006 08:17 AM |
|
|
Agret
Junior Member
Posts: 23
35 / / –
Joined: Dec 2003
|
O.P. RE: How do I create a variable thing like (!VER)?
Heh, i've gotten somewhat used to regular expressions although they vary in usage. UltraEdit and PHP have different regular expressions and now I'll have to learn the JavaScript ones
I think it's better to just look up a cheat sheet for regular expressions rather than try and learn them, it'll drive you insane trying to remember which one to use between which language / program.
(¯`·._¤²°°²Agret²°°²¤_.·´¯)
¸.-~·*'˜¨¯Ï”m_†hê_ôñë_åñd_õñl¥_Åg®ê†¨˜'*·~-.¸
|
|
12-01-2006 08:28 AM |
|
|
Ezra
Veteran Member
Forgiveness is between them and God
Posts: 1960 Reputation: 31
37 / /
Joined: Mar 2003
|
|
12-01-2006 09:09 AM |
|
|
Agret
Junior Member
Posts: 23
35 / / –
Joined: Dec 2003
|
O.P. RE: How do I create a variable thing like (!VER)?
markee I finally got around to testing your code and although it replaces the Message thing alright it doesn't actually replace the message that is sent to your recipient, I can only access the new value from a script
(¯`·._¤²°°²Agret²°°²¤_.·´¯)
¸.-~·*'˜¨¯Ï”m_†hê_ôñë_åñd_õñl¥_Åg®ê†¨˜'*·~-.¸
|
|
12-01-2006 12:38 PM |
|
|
markee
Veteran Member
Posts: 1622 Reputation: 50
36 / /
Joined: Jan 2006
|
RE: How do I create a variable thing like (!VER)?
quote: Originally posted by Agret
markee I finally got around to testing your code and although it replaces the Message thing alright it doesn't actually replace the message that is sent to your recipient, I can only access the new value from a script
Sorry, you have to return the Msg variable, I just put in ... for if you wanted to do more in the script. If you just want to do that one thing then here is the script.
code: function OnEvent_ChatWndSendMessage(Wnd,Msg){
Msg = Msg.replace(/\(\!MEH\)/g,variable);//replace (!MEH) with string in variable
return Msg;
}
Btw you can still add more than you want, I just wanted to give you an example or snippet of the code first rather than writing something fully.
|
|
12-01-2006 12:44 PM |
|
|
Felu
Veteran Member
Posts: 2223 Reputation: 72
30 / /
Joined: Apr 2006
Status: Away
|
RE: How do I create a variable thing like (!VER)?
Markee forgot to return the message .
code: var meh = "meh"
function OnEvent_ChatWndSendMessage(ChatWnd,Message){
Message = Message.replace(/\(\!MEH\)/gi,meh);
return Message;
}
Edit : Beaten by markee .
This post was edited on 12-01-2006 at 12:48 PM by Felu.
|
|
12-01-2006 12:46 PM |
|
|
Agret
Junior Member
Posts: 23
35 / / –
Joined: Dec 2003
|
O.P. RE: How do I create a variable thing like (!VER)?
Yeah, I figured it out myself. Forgot to delete my post lol Thanks for replying anyway guys.
The script is pretty much finished now, just gotta do some usability improvements to it
(¯`·._¤²°°²Agret²°°²¤_.·´¯)
¸.-~·*'˜¨¯Ï”m_†hê_ôñë_åñd_õñl¥_Åg®ê†¨˜'*·~-.¸
|
|
12-01-2006 02:17 PM |
|
|
Pages: (2):
« First
[ 1 ]
2
»
Last »
|
|