Jump to content
  • 0

How to deal with case sensitive ?


Question

Posted

Hi rAthena!

I'm trying to compare an input with rid2name(getcharid(3))

E.g

input @PlayerSpecInputName$;

set .@ownName$,( rid2name(getcharid(3)) );
	if( @PlayerSpecInputName$ == .@ownName$ ) {
		mes "You cant use your own name";
		close;

But the logic is only working if the player input his own name exactly how it is written (case-sensitive),

ex: If a player nick is 'XxXExAmPLE' and he inputs 'xxxexample', my if ( @PlayerSpecInputName$ == .@ownName$ ) wont work properly.

Does anybody know how to overcome that ?

Thanks in advance! ?

Best,
Gabriel.

5 answers to this question

Recommended Posts

  • 2
Posted (edited)
    input .@PlayerSpecInputName$;
    .@ownName$ = strcharinfo(0);
    if (compare(.@PlayerSpecInputName$, .@ownName$) && compare(.@ownName$, .@PlayerSpecInputName$)) {
        mes "You cant use your own name";
        close;
    }

 

Edited by AnnieRuru
  • 1
Posted
2 hours ago, klesler said:

Hi rAthena!

I'm trying to compare an input with rid2name(getcharid(3))

E.g


input @PlayerSpecInputName$;

set .@ownName$,( rid2name(getcharid(3)) );
	if( @PlayerSpecInputName$ == .@ownName$ ) {
		mes "You cant use your own name";
		close;

But the logic is only working if the player input his own name exactly how it is written (case-sensitive),

ex: If a player nick is 'XxXExAmPLE' and he inputs 'xxxexample', my if ( @PlayerSpecInputName$ == .@ownName$ ) wont work properly.

Does anybody know how to overcome that ?

Thanks in advance! ?

Best,
Gabriel.

You can do something like 

if ( .@PlayerSpecInputName$ == strcharinfo(0) ) {
  	mes "Mehh your using your name";
  	close;
  }

 

PS: I don't know if you intentionally use @PlayerSpecInputName$ which is a temporary variable attach to player? or is this a typo? Anyways, I used .@PlayerSpecInputName$ 
 

 

  • 1
Posted (edited)
11 minutes ago, klesler said:

Thank you for the quick answer guys! @AnnieRuru, @pajodex

I was using .@ before, but then I tried to use @ (thinking it was a global variable) to solve a problem.

I mean, I started a timer with initnpctimer; inside an event called proceed, then I stop this timer on the next event (N_paying) or if the timer reach 15000 (15 seconds) e.g:


Proceed:
    initnpctimer;
	goto N_paying;
end;

N_paying:
  stopnpctimer;
end;

OnTimer15000:
	stopnpctimer;
	attachrid( @PlayerSpecID );
	mes "The player is AFK or has disconnected...";
  	close2;
	attachrid( getcharid(3,@PlayerSpecInputName$) );
	close;
end;

But the attachrid( .@PlayerSpecID ); and attachrid( getcharid(3,.@PlayerSpecInputName$) ); inside OnTimer15000: was not working, the console was telling me that the player was not attached, then I changed from .@ to @ in order to solve that (I thought it was a scope thing), but it didn't work too HAhaha!

If you know how to overcome that too, I would really appreciate it! ? 

Thanks!
Gabriel.

You can use checkidle(); instead.. see how this is  scripted..

Just read https://github.com/rathena/rathena/blob/master/doc/script_commands.txt

You can see all alternative codes that you might need.. or ask here in forum..

 

As for variables... read these examples..

Examples:
  name  - permanent character integer variable
  name$ - permanent character string variable
 @name  - temporary character integer variable
 @name$ - temporary character string variable
 $name  - permanent global integer variable
 $name$ - permanent global string variable
$@name  - temporary global integer variable
$@name$ - temporary global string variable
 .name  - NPC integer variable
 .name$ - NPC string variable
.@name  - scope integer variable
.@name$ - scope string variable
 'name  - instance integer variable
 'name$ - instance string variable
 #name  - permanent local account integer variable
 #name$ - permanent local account string variable
##name  - permanent global account integer variable
##name$ - permanent global account string variable

 

Edited by pajodex
  • 0
Posted (edited)

Thank you for the quick answer guys! @AnnieRuru, @pajodex

I was using .@ before, but then I tried to use @ (thinking it was a global variable) to solve a problem.

I mean, I started a timer with initnpctimer; inside an event called proceed, then I stop this timer on the next event (N_paying) or if the timer reach 15000 (15 seconds) e.g:

Proceed:
    initnpctimer;
	goto N_paying;
end;

N_paying:
  stopnpctimer;
end;

OnTimer15000:
	stopnpctimer;
	attachrid( @PlayerSpecID );
	mes "The player is AFK or has disconnected...";
  	close2;
	attachrid( getcharid(3,@PlayerSpecInputName$) );
	close;
end;

But the

attachrid (.@PlayerSpecID );

and

attachrid( getcharid(3,.@PlayerSpecInputName$) );

inside

OnTimer15000:

was not working, the console was telling me that the player was not attached, then I changed from

.@

to

@

in order to solve that (I thought it was a scope thing), but it didn't work too HAhaha!

If you know how to overcome that too, I would really appreciate it! ? 

Thanks!
Gabriel.

Edited by klesler
grammar
  • 0
Posted

Hmmm, @pajodex

Seems interesting, but maybe wont cover all the scenarios of what I'm trying to do, if you are interested: 

 

Anyway I'll try to solve all my scenarios with checkidle();

Thanks buddy! ?

Best,
Gabriel.

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...