Jump to content
  • 0

Help on this script - strings


Question

Posted (edited)

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

5 answers to this question

Recommended Posts

Posted (edited)

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
Posted (edited)

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
Posted (edited)

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

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...