Jump to content
  • 0

Help on this script - strings


Ninja

Question


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

query_sql("update `char` SET name='[HC]"+strcharinfo(0)+"' WHERE name='"+strcharinfo(0)+"'");

basically,this attaches "[HC]" in someone's name.

how do you reverse this process in a later time? @_@

Edited by jezznar
Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  19
  • Topics Per Day:  0.00
  • Content Count:  713
  • Reputation:   70
  • Joined:  11/08/11
  • Last Seen:  

easy one: save the old name in a perm variable or a new table then just revert

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  39
  • Reputation:   2
  • Joined:  08/19/12
  • Last Seen:  

Better suggestion(cause this will use less ressources than the other solution):

Just do this:

set @oldname$, replacestr(strcharinfo(0), "[HC]", ""); // Would delete all [HC]s so if the name is [HC]Marvin_s[HC] it would be Marvin_s

If you just want to delete the [HC] at beginning, do this:

set @oldname$, substr(strcharinfo(0), 4, getstrlen(strcharinfo(0)); //Skips the first 4 Characters ([HC]) and just returns the part after the 4th character.

EDIT:

Uses now strcharinfo(0) instead of var.

Edited by skyleo
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

easy one: save the old name in a perm variable or a new table then just revert

this is actually what I did but I think there's a better way :)

Better suggestion(cause this will use less ressources than the other solution):

Just do this:

set @oldname$, replacestr(strcharinfo(0), "[HC]", ""); // Would delete all [HC]s so if the name is [HC]Marvin_s[HC] it would be Marvin_s

If you just want to delete the [HC] at beginning, do this:

set @oldname$, substr(strcharinfo(0), 4, getstrlen(strcharinfo(0)); //Skips the first 4 Characters ([HC]) and just returns the part after the 4th character.

EDIT:

Uses now strcharinfo(0) instead of var.

just a question, will this remain even if I restart the server? or should I use oldname$ instead? I do want to revert names at a later time..

please educate me >_< I suck at scripting.

Edited by jezznar
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  39
  • Reputation:   2
  • Joined:  08/19/12
  • Last Seen:  

It's temporary, but you don't have to save it, since you can just create this variable exactly at the point where you're deleting the [HC].

As I said in my post, it's a loss of ressources when you save things like that.

Edited by skyleo
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  54
  • Topics Per Day:  0.01
  • Content Count:  513
  • Reputation:   83
  • Joined:  08/11/12
  • Last Seen:  

i see. thanks! i missed that point. :) that's definitely a good one.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...