CMD:setname(playerid,params[]){ if(admin[playerid]<4) return SendClientMessage(playerid,COLOR_RED,"ERROR:{FFFFFF}You need admin level 4 to use this command"); new id,name[28], text[500], newpw[500]; if(sscanf(params,"uss",id,name,newpw)) return SendClientMessage(playerid,COLOR_RED,"USAGE:{FFFFFF}/setname [id] [name] [password]"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"ERROR:{FFFFFF}Player not connected"); new pw[129]; WP_Hash(pw,sizeof(pw),newpw); if(!dini_Exists(Account(name))) { SetPlayerName(id,name); dini_Create(Account(id)); dini_Set(Account(id),"password",pw); dini_IntSet(Account(id),"money",0); dini_IntSet(Account(id),"color",GetPlayerColor(playerid)); dini_IntSet(Account(id),"score",0); dini_IntSet(Account(id),"admin",0); } else if(dini_Exists(Account(name))) { } return 1; }
CMD:setname(playerid,params[]){ if(admin[playerid]<4) return SendClientMessage(playerid,COLOR_RED,"ERROR:{FFFFFF}You need admin level 4 to use this command"); GetPlayerName(id, name, MAX_PLAYER_NAME); new id,name[28], text[500], newpw[500]; if(sscanf(params,"uss",id,name,newpw)) return SendClientMessage(playerid,COLOR_RED,"USAGE:{FFFFFF}/setname [id] [name] [password]"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"ERROR:{FFFFFF}Player not connected"); new pw[129]; WP_Hash(pw,sizeof(pw),newpw); if(!dini_Exists(Account(name))) { SetPlayerName(id,name); dini_Create(Account(id)); dini_Set(Account(id),"password",pw); dini_IntSet(Account(id),"money",0); dini_IntSet(Account(id),"color",GetPlayerColor(playerid)); dini_IntSet(Account(id),"score",0); dini_IntSet(Account(id),"admin",0); } else if(dini_Exists(Account(name))) { } return 1; }
new fileName[90];
format(fileName, sizeof(fileName), "Accounts/%s.ini", name);
if(dini_Exists(fileName))
{
continue...
}
else
{
continue...
}
because if it exists, it should not allow the admin to use this command because the name would be already taken
|
CMD:setname(playerid,params[]){ new id ,name[28], newpw[500]; if(admin[playerid]<4) return SendClientMessage(playerid,COLOR_RED,"ERROR:{FFFFFF}You need admin level 4 to use this command"); GetPlayerName(id, name, MAX_PLAYER_NAME); new fileName[90]; format(fileName, sizeof(fileName), "users/%s.ini", name); if(sscanf(params,"uss",id,name, newpw)) return SendClientMessage(playerid,COLOR_RED,"USAGE:{FFFFFF}/setname [id] [name] [password]"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"ERROR:{FFFFFF}Player not connected"); new pw[129]; WP_Hash(pw,sizeof(pw), newpw); if(!dini_Exists(fileName)) { SetPlayerName(id,name); dini_Create(Account(id)); dini_Set(Account(id),"password", pw); dini_IntSet(Account(id),"money",0); dini_IntSet(Account(id),"color",GetPlayerColor(playerid)); dini_IntSet(Account(id),"score",0); dini_IntSet(Account(id),"admin",0); } else if(dini_Exists(fileName)) { SCM(pid, -1, "username already taken"); } return 1;}