SA-MP Forums Archive
Changenick bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Changenick bug (/showthread.php?tid=131055)



Changenick bug - BuLLeT[LTU] - 01.03.2010

Hello. I need help with this. My nick name in game is [_FFG_]BuLLeT and i try to change nick to [_FFG_]BuLLet (with t small) and then my nick isn't changed, but my file account is changed to [_FFG_]BuLLet and i lose statistic. How to fix it?

pawn Код:
dcmd_changenick( playerid, params[ ] ){
if ( params[ 0 ] == '\0' ) return ChangenickUsage(playerid);
new
tName[ MAX_PLAYER_NAME ],
idx;
tName = strtok4(params, idx );
if ( IsNumeric( tName ) ){
new
nameid  = strval( tName ),
namelen = strlen( params[ idx + 1 ] );
if ( !IsPlayerConnected( nameid ) )
return WrongID(playerid);
if(nameid < 0) return WrongID(playerid);
GetPlayerName( nameid, tName, MAX_PLAYER_NAME );
new otherplayer = ReturnUser(tName);
if(otherplayer != playerid) return OnlyYourNick(playerid);
if ( !namelen )
return ChangenickUsage(playerid);
if ( namelen < 3 || namelen > 20 )
return NameLengh(playerid);
namelen += ( idx + 1 );
for (new i = idx + 1; i < namelen; i++ ){
if ( isalnum( params[ i ] ) || params[ i ] == '_' || params[ i ] == '[' || params[ i ] == ']' )
continue;
else
return Characters(playerid);
}
if(dini_Exists(params[ idx + 1 ])) return SendClientMessage(playerid,COLOR_GRAD1,"*[INFO]: Љis vartotojo vardas jau naudojamas!");
if(udb_Exists(params[ idx + 1 ])){
SendClientMessage(playerid,COLOR_GRAD1,"*[INFO]: Љis vartotojo vardas jau naudojamas!");
}else{
if(dini_Int(accountfile(playerid),"HasCar") == 1){
dini_Set(carfile(dini_Int(accountfile(playerid),"BCar")), "Owner",params[ idx + 1 ]);
}
for(new i=0;i<MAX_HOUSES;i++){
if(strcmp(dini_Get(housefile(i), "Owner"), PlayerName2(playerid), true) == 0){
dini_Set(housecarfile(i), "Owner",params[ idx + 1 ]);
dini_Set(housefile(i), "Owner", params[ idx + 1 ]);
}
}
new nameaa[MAX_PLAYER_NAME];
GetPlayerName(playerid, nameaa, MAX_PLAYER_NAME);
for(new propid; propid < PropertiesAmount; propid++){
if(PropInfo[propid][PropIsBought] == 1){
if(strcmp(PropInfo[propid][PropOwner], nameaa, true)==0){
format(PropInfo[propid][PropOwner], MAX_PLAYER_NAME, params[ idx + 1 ]);
}
}
}
new oldfname3[MAX_STRING];
new newfname3[MAX_STRING];
format(oldfname3,sizeof(oldfname3),"AccountPasswords/%s.dudb.sav",PlayerName2(playerid));
format(newfname3,sizeof(newfname3),"AccountPasswords/%s.dudb.sav",params[ idx + 1 ]);
frenametextfile(oldfname3,newfname3);
format(bstring2,256,"/VIP/%s.txt",PlayerName2(playerid));
if(!dini_Exists(bstring2))
{dini_Create(bstring2);}
new oldfname2[MAX_STRING];
new newfname2[MAX_STRING];
format(oldfname2,sizeof(oldfname2),"VIP/%s.txt",PlayerName2(playerid));
format(newfname2,sizeof(newfname2),"VIP/%s.txt",params[ idx + 1 ]);
frenametextfile(oldfname2,newfname2);
new oldfname[MAX_STRING];
new newfname[MAX_STRING];
format(oldfname,sizeof(oldfname),"Accounts/%s.txt",PlayerName2(playerid));
format(newfname,sizeof(newfname),"Accounts/%s.txt",params[ idx + 1 ]);
frenametextfile(oldfname,newfname);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
new string[256]; format(string, sizeof(string),"*[INFO]: Vartotojo vardas pakeistas į \"%s\"",params[ idx + 1 ]);
SendClientMessage(playerid,COLOR_GRAD1,string);
SetPlayerName(playerid,params[ idx + 1 ]);
}
}
return 1;
}



Re: Changenick bug - bajskorv123 - 01.03.2010

Quote:
Originally Posted by Teh Wiki >_>
Important Note: If you set the player's name to the same name, expect different case latters (ie "heLLO" to "hello") it will not work.



Re: Changenick bug - BuLLeT[LTU] - 01.03.2010

How to do that player cant change nick if it is same but not words?


Re: Changenick bug - bajskorv123 - 01.03.2010

Use the check:
pawn Код:
if(strval(params) == tName)
Then return 0 or something...


Re: Changenick bug - BuLLeT[LTU] - 01.03.2010

it is writting that tName must be indexed..


Re: Changenick bug - Sergei - 01.03.2010

You couldn't complicate moe with your command? That command could be a few lines long ...

First set name with SetPlayerName and depending on result (if it returns 0) don't change file names.
Quote:
Returns 1 if the name was changed, 0 if the player is already using that name or -1 when the name cannot be changed (it's in use, too long or has invalid characters)