Solved Checking player names

Question that is answered or resolved.

O Ilusionista

Captain 100K
hi,
I am trying to make a code to check if there is a specific character playing and, if so, the entity should go to a specific animation. The code doesn't crashes, but it does nothing

here is what I have:

@script
      if(frame ==1)
        {
void self = getlocalvar("self");
int P1 = getplayerproperty(0, "entity");
        int P2 = getplayerproperty(1, "entity");
  int P1Name = getentityproperty(P1,"model");
int P2Name = getentityproperty(P2,"model");
if (P1Name == "wolverine" || P2Name == "wolverine")
          {
          performattack(self, openborconstant("ani_follow1"));
  }
        }
@end_script

What I am doing wrong?
 
I've found the problem: the player name is "Wolverine" not "wolverine". So its case senstive (as it should be)
Its working now ;)
 
case sensitive search in openBOR:

Code:
char getchar(char str, int index) {

    if ( index >= strlength(str) ) index = strlength(str)-1;
    else if ( index < 0 ) index = 0;

    if ( strlength(str) > 0 ) {
        str = strright(str, index);
        if ( strlength(str) > 1 ) {
            index = 1;
            str = strleft(str, index);
        }
    }

    return str;
}

char uppercase(char str) {
    int i = 0;
    char cstr = "";

    for ( i = 0; i < strlength(str); ++i ) {
        char ch = getchar(str,i);

             if ( ch == "a" ) ch = "A";
        else if ( ch == "b" ) ch = "B";
        else if ( ch == "c" ) ch = "C";
        else if ( ch == "d" ) ch = "D";
        else if ( ch == "e" ) ch = "E";
        else if ( ch == "f" ) ch = "F";
        else if ( ch == "g" ) ch = "G";
        else if ( ch == "h" ) ch = "H";
        else if ( ch == "i" ) ch = "I";
        else if ( ch == "j" ) ch = "J";
        else if ( ch == "k" ) ch = "K";
        else if ( ch == "l" ) ch = "L";
        else if ( ch == "m" ) ch = "M";
        else if ( ch == "n" ) ch = "N";
        else if ( ch == "o" ) ch = "O";
        else if ( ch == "p" ) ch = "P";
        else if ( ch == "q" ) ch = "Q";
        else if ( ch == "r" ) ch = "R";
        else if ( ch == "s" ) ch = "S";
        else if ( ch == "t" ) ch = "T";
        else if ( ch == "u" ) ch = "U";
        else if ( ch == "v" ) ch = "V";
        else if ( ch == "x" ) ch = "X";
        else if ( ch == "y" ) ch = "Y";
        else if ( ch == "w" ) ch = "W";
        else if ( ch == "z" ) ch = "Z";

        cstr += ch;
    }

    return cstr;
}

char lowercase(char str) {
    int i = 0;
    char cstr = "";

    for ( i = 0; i < strlength(str); ++i ) {
        char ch = getchar(str,i);

             if ( ch == "A" ) ch = "a";
        else if ( ch == "B" ) ch = "b";
        else if ( ch == "C" ) ch = "c";
        else if ( ch == "D" ) ch = "d";
        else if ( ch == "E" ) ch = "e";
        else if ( ch == "F" ) ch = "f";
        else if ( ch == "G" ) ch = "g";
        else if ( ch == "H" ) ch = "h";
        else if ( ch == "I" ) ch = "i";
        else if ( ch == "J" ) ch = "j";
        else if ( ch == "K" ) ch = "k";
        else if ( ch == "L" ) ch = "l";
        else if ( ch == "M" ) ch = "m";
        else if ( ch == "N" ) ch = "n";
        else if ( ch == "O" ) ch = "o";
        else if ( ch == "P" ) ch = "p";
        else if ( ch == "Q" ) ch = "q";
        else if ( ch == "R" ) ch = "r";
        else if ( ch == "S" ) ch = "s";
        else if ( ch == "T" ) ch = "t";
        else if ( ch == "U" ) ch = "u";
        else if ( ch == "V" ) ch = "v";
        else if ( ch == "X" ) ch = "x";
        else if ( ch == "Y" ) ch = "y";
        else if ( ch == "W" ) ch = "w";
        else if ( ch == "Z" ) ch = "z";

        cstr += ch;
    }

    return cstr;
}

void search_str(char str, char sub, int case_flag) {
    char substr;

    if ( str == NULL() || sub == NULL() ) return -1;
    if ( case_flag == NULL() ) case_flag = 0;

    if ( case_flag ) substr = strinfirst(lowercase(str), lowercase(sub));
    else substr = strinfirst(str, sub);

    return substr;
}

Example:
search_str("Wolverine","WolVEriNe",1) return a success string!

EDIT: added chetchar() function
 
thanks! But I am a follower of the KISS principle, and I think its too much for something I should NOT forget :)
Thanks anyway.

Edit: your code had answered some questions I had in mind, like working strings manipulation. Thanks!
 
If you try to attain model, you'll get different result when player changes weapon model BUT if you attain name, you'll get same result even if player is in certain weapon model

I can't say which one is bad or good cause it depends on what you are trying to achieve here. The script you posted above seems to only check player's name instead of model. But who knows, maybe you have certain enemies/bosses reacting to certain modes (i.e Emma's diamond mode and Brand's gun mode) ;)
 
O Ilusionista said:
so it would be like this?
int P1Name = getentityproperty(P1,"name");
  int P2Name = getentityproperty(P2,"name");

or "defaultmodel" ?

Use getentityproperty(player_index,"model") if you want to take the weapon name.
Use getentityproperty(player_index,"defaultmodel") if you want to take the man name of the player

Ex.:
Wolverine (MAIN NAME)
Wolverine_Shotgun (WEAPON NAME)

getentityproperty(player_index,"model") returns Wolverine_Shotgun (if u using the weapon) or Wolverine
getentityproperty(player_index,"defaultmodel") returns Wolverine ever!
 
Back
Top Bottom