new string[MAX_PLAYER_NAME];
GetPlayerName(playerid, string, sizeof(string));
format(string, sizeof(string), "%s.ini", PlayerName(playerid));
if(dini_Exists(string)) // This will check if the dini exists. returns true if exists.
{
//
// Your code here
}
else
{
//Use your code here if no dini exists.
}
CMD:changename(playerid, params[])
{
new string[128],
newname[24],
oldname[24],
location[254],
id;
if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
if(pData[playerid][Admin] < 3) return SendClientMessage(playerid, COLOR_RED, "*** You are not Junior Administrator ***");
if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename [playerid] [newname]");
format(location, 254, pPath, newname);
format(oldname, 24, "%s", dini_Get(DataPath(id), "Name"));
//i always get bug in this part >>>// if(strval(newname) == strval(oldname)) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change the old name to new name! ***");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
if(pData[playerid][Admin] < pData[id][Admin]) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change name higher administrator! ***");
if(!dini_Exists(DataPath(playerid)))
{
format(string, sizeof(string), "Administrator %s(%d) has change %s name to %s(%d)", GetpName(playerid), playerid, GetpName(id), newname, id);
SendClientMessageToAll(COLOR_GREEN, string);
format(string, sizeof(string), "*** You change %s name to %s(%d)", GetpName(id), newname, id);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "*** Administrator %s(%d) has change your name to %s", GetpName(playerid), playerid, newname);
SendClientMessage(id, COLOR_GREEN, string);
pData[id][Pass] = dini_Int(DataPath(id), "Password");
pData[id][NoPM] = dini_Int(DataPath(id), "NoPM");
pData[id][Banned] = dini_Int(DataPath(id), "Ban");
new banreason[92];
format(banreason, 92, "%s", dini_Get(DataPath(id), "Reason"));
new banby[24];
format(banby, 24, "%s", dini_Get(DataPath(id), "BanBy"));
pData[id][Admin] = dini_Int(DataPath(id), "Admin");
pData[id][VIP] = dini_Int(DataPath(id), "VIP");
pData[id][Score] = dini_Int(DataPath(id), "Score");
pData[id][Cash] = dini_Int(DataPath(id), "Cash");
pData[id][Freeze] = dini_Int(DataPath(id), "Freeze");
pData[id][Deaths] = dini_Int(DataPath(id), "Deaths");
pData[id][Kills] = dini_Int(DataPath(id), "Kills");
dini_Remove(DataPath(id));
dini_Create(location);
dini_Set(location, "Name", newname);
dini_Set(location, "IP", IP);
dini_IntSet(location, "Password", pData[id][Pass]);
dini_IntSet(location, "Ban", pData[id][Banned]);
dini_Set(location, "Reason", banreason);
dini_Set(location, "BanBy", banby);
dini_IntSet(location, "Admin", pData[id][Admin]);
dini_IntSet(location, "VIP", pData[id][VIP]);
dini_IntSet(location, "Score", pData[id][Score]);
dini_IntSet(location, "Cash", pData[id][Cash]);
dini_IntSet(location, "Freeze", pData[id][Freeze]);
dini_IntSet(location, "Deaths", pData[id][Deaths]);
dini_IntSet(location, "Kills", pData[id][Kills]);
SetPlayerName(id, newname);
}
else if(dini_Exists(DataPath(playerid)))
{
SendClientMessage(playerid, COLOR_RED, "*** That player name exists! ***");
}
return 1;
}
CMD:changename(playerid, params[])
{
new string[128],
newname[MAX_PLAYER_NAME],
oldname[MAX_PLAYER_NAME],
location[254],
id;
if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
if(pData[playerid][Admin] < 3) return SendClientMessage(playerid, COLOR_RED, "*** You are not Junior Administrator ***");
if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename [playerid] [newname]");
format(location, 254, pPath, newname);
format(oldname, 24, "%s", dini_Get(DataPath(id), "Name"));
if(newname, oldname, true, 34) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change the old name to new name! ***");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
if(pData[playerid][Admin] < pData[id][Admin]) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change name higher administrator! ***");
if(dini_Exists(DataPath(playerid))) return SendClientMessage(playerid, COLOR_RED, "*** That player name exists! ***");
if(!dini_Exists(DataPath(playerid)))
{
format(string, sizeof(string), "Administrator %s(%d) has change %s name to %s(%d)", GetpName(playerid), playerid, GetpName(id), newname, id);
SendClientMessageToAll(COLOR_GREEN, string);
format(string, sizeof(string), "*** You change %s name to %s(%d)", GetpName(id), newname, id);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "*** Administrator %s(%d) has change your name to %s", GetpName(playerid), playerid, newname);
SendClientMessage(id, COLOR_GREEN, string);
pData[id][Pass] = dini_Int(DataPath(id), "Password");
pData[id][NoPM] = dini_Int(DataPath(id), "NoPM");
pData[id][Banned] = dini_Int(DataPath(id), "Ban");
new banreason[92];
format(banreason, 92, "%s", dini_Get(DataPath(id), "Reason"));
new banby[24];
format(banby, 24, "%s", dini_Get(DataPath(id), "BanBy"));
pData[id][Admin] = dini_Int(DataPath(id), "Admin");
pData[id][VIP] = dini_Int(DataPath(id), "VIP");
pData[id][Score] = dini_Int(DataPath(id), "Score");
pData[id][Cash] = dini_Int(DataPath(id), "Cash");
pData[id][Freeze] = dini_Int(DataPath(id), "Freeze");
pData[id][Deaths] = dini_Int(DataPath(id), "Deaths");
pData[id][Kills] = dini_Int(DataPath(id), "Kills");
dini_Remove(DataPath(id));
dini_Create(location);
dini_Set(location, "Name", newname);
dini_Set(location, "IP", IP);
dini_IntSet(location, "Password", pData[id][Pass]);
dini_IntSet(location, "Ban", pData[id][Banned]);
dini_Set(location, "Reason", banreason);
dini_Set(location, "BanBy", banby);
dini_IntSet(location, "Admin", pData[id][Admin]);
dini_IntSet(location, "VIP", pData[id][VIP]);
dini_IntSet(location, "Score", pData[id][Score]);
dini_IntSet(location, "Cash", pData[id][Cash]);
dini_IntSet(location, "Freeze", pData[id][Freeze]);
dini_IntSet(location, "Deaths", pData[id][Deaths]);
dini_IntSet(location, "Kills", pData[id][Kills]);
SetPlayerName(id, newname);
}
return 1;
}
You cannot change the old name to new name!
>>>>>>>>>>>>>>>>>>> if(strval(newname) == strval(oldname)) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change the old name to new name! ***");
I always get bug
like Код:
You cannot change the old name to new name! let me put it again pawn Код:
|
*** That player name exists! ***
CMD:changename(playerid, params[])
{
new string[128],
newname[MAX_PLAYER_NAME],
oldname[MAX_PLAYER_NAME],
location[254],
id;
if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
if(pData[playerid][Admin] < 3) return SendClientMessage(playerid, COLOR_RED, "*** You are not Junior Administrator ***");
if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename [playerid] [newname]");
format(location, 254, pPath, newname);
format(oldname, 24, "%s", dini_Get(DataPath(id), "Name"));
if(!strcmp(newname, oldname, true)) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change the old name to new name! ***");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
if(pData[playerid][Admin] < pData[id][Admin]) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change name higher administrator! ***");
if(dini_Exists(DataPath(playerid))) return SendClientMessage(playerid, COLOR_RED, "*** That player name exists! ***");
else if(!dini_Exists(DataPath(playerid)))
{
format(string, sizeof(string), "Administrator %s(%d) has change %s name to %s(%d)", GetpName(playerid), playerid, GetpName(id), newname, id);
SendClientMessageToAll(COLOR_GREEN, string);
format(string, sizeof(string), "*** You change %s name to %s(%d)", GetpName(id), newname, id);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "*** Administrator %s(%d) has change your name to %s", GetpName(playerid), playerid, newname);
SendClientMessage(id, COLOR_GREEN, string);
pData[id][Pass] = dini_Int(DataPath(id), "Password");
pData[id][NoPM] = dini_Int(DataPath(id), "NoPM");
pData[id][Banned] = dini_Int(DataPath(id), "Ban");
new banreason[92];
format(banreason, 92, "%s", dini_Get(DataPath(id), "Reason"));
new banby[24];
format(banby, 24, "%s", dini_Get(DataPath(id), "BanBy"));
pData[id][Admin] = dini_Int(DataPath(id), "Admin");
pData[id][VIP] = dini_Int(DataPath(id), "VIP");
pData[id][Score] = dini_Int(DataPath(id), "Score");
pData[id][Cash] = dini_Int(DataPath(id), "Cash");
pData[id][Freeze] = dini_Int(DataPath(id), "Freeze");
pData[id][Deaths] = dini_Int(DataPath(id), "Deaths");
pData[id][Kills] = dini_Int(DataPath(id), "Kills");
dini_Remove(DataPath(id));
dini_Create(location);
dini_Set(location, "Name", newname);
dini_Set(location, "IP", IP);
dini_IntSet(location, "Password", pData[id][Pass]);
dini_IntSet(location, "Ban", pData[id][Banned]);
dini_Set(location, "Reason", banreason);
dini_Set(location, "BanBy", banby);
dini_IntSet(location, "Admin", pData[id][Admin]);
dini_IntSet(location, "VIP", pData[id][VIP]);
dini_IntSet(location, "Score", pData[id][Score]);
dini_IntSet(location, "Cash", pData[id][Cash]);
dini_IntSet(location, "Freeze", pData[id][Freeze]);
dini_IntSet(location, "Deaths", pData[id][Deaths]);
dini_IntSet(location, "Kills", pData[id][Kills]);
SetPlayerName(id, newname);
}
return 1;
}
CMD:changename(playerid, params[])
{
new string[128],
newname[MAX_PLAYER_NAME],
oldname[MAX_PLAYER_NAME],
location[254],
id;
if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
if(pData[playerid][Admin] < 3) return SendClientMessage(playerid, COLOR_RED, "*** You are not Junior Administrator ***");
if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename [playerid] [newname]");
format(location, 254, pPath, newname);
format(oldname, 24, "%s", dini_Get(DataPath(id), "Name"));
if(strcmp(newname, oldname, true)) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change the old name to new name! ***");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
if(pData[playerid][Admin] < pData[id][Admin]) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change name higher administrator! ***");
if(dini_Exists(DataPath(playerid))) return SendClientMessage(playerid, COLOR_RED, "*** That player name exists! ***");
else if(!dini_Exists(DataPath(playerid)))
{
format(string, sizeof(string), "Administrator %s(%d) has change %s name to %s(%d)", GetpName(playerid), playerid, GetpName(id), newname, id);
SendClientMessageToAll(COLOR_GREEN, string);
format(string, sizeof(string), "*** You change %s name to %s(%d)", GetpName(id), newname, id);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "*** Administrator %s(%d) has change your name to %s", GetpName(playerid), playerid, newname);
SendClientMessage(id, COLOR_GREEN, string);
pData[id][Pass] = dini_Int(DataPath(id), "Password");
pData[id][NoPM] = dini_Int(DataPath(id), "NoPM");
pData[id][Banned] = dini_Int(DataPath(id), "Ban");
new banreason[92];
format(banreason, 92, "%s", dini_Get(DataPath(id), "Reason"));
new banby[24];
format(banby, 24, "%s", dini_Get(DataPath(id), "BanBy"));
pData[id][Admin] = dini_Int(DataPath(id), "Admin");
pData[id][VIP] = dini_Int(DataPath(id), "VIP");
pData[id][Score] = dini_Int(DataPath(id), "Score");
pData[id][Cash] = dini_Int(DataPath(id), "Cash");
pData[id][Freeze] = dini_Int(DataPath(id), "Freeze");
pData[id][Deaths] = dini_Int(DataPath(id), "Deaths");
pData[id][Kills] = dini_Int(DataPath(id), "Kills");
dini_Remove(DataPath(id));
dini_Create(location);
dini_Set(location, "Name", newname);
dini_Set(location, "IP", IP);
dini_IntSet(location, "Password", pData[id][Pass]);
dini_IntSet(location, "Ban", pData[id][Banned]);
dini_Set(location, "Reason", banreason);
dini_Set(location, "BanBy", banby);
dini_IntSet(location, "Admin", pData[id][Admin]);
dini_IntSet(location, "VIP", pData[id][VIP]);
dini_IntSet(location, "Score", pData[id][Score]);
dini_IntSet(location, "Cash", pData[id][Cash]);
dini_IntSet(location, "Freeze", pData[id][Freeze]);
dini_IntSet(location, "Deaths", pData[id][Deaths]);
dini_IntSet(location, "Kills", pData[id][Kills]);
SetPlayerName(id, newname);
}
return 1;
}
if(strcmp(newname, oldname, true)) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change the old name to new name! ***");
*** You cannot change old name to new name ***
if(!strcmp(newname, oldname, true)) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change the old name to new name! ***");
*** That player name exists ***
I don't quite understand you bring back the old bug
when you edit my strcmp and made this pawn Код:
Код:
*** You cannot change old name to new name *** pawn Код:
Код:
*** That player name exists *** |
CMD:changename(playerid, params[])
{
new string[128],
newname[MAX_PLAYER_NAME],
oldname[MAX_PLAYER_NAME],
location[254],
id;
if(pData[playerid][Login] == 0) return SendClientMessage(playerid, COLOR_RED, "*** Please login first! ***");
if(pData[playerid][Admin] < 3) return SendClientMessage(playerid, COLOR_RED, "*** You are not Junior Administrator ***");
if(sscanf(params, "us[24]", id, newname)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /changename [playerid] [newname]");
format(location, 254, pPath, newname);
format(oldname, 24, "%s", dini_Get(DataPath(id), "Name"));
if(dini_Exists(DataPath(playerid))) return SendClientMessage(playerid, COLOR_RED, "*** That player name exists! or you're changing the newname to a oldname. ***");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
if(pData[playerid][Admin] < pData[id][Admin]) return SendClientMessage(playerid, COLOR_RED, "*** You cannot change name higher administrator! ***");
else if(!dini_Exists(DataPath(playerid)))
{
format(string, sizeof(string), "Administrator %s(%d) has change %s name to %s(%d)", GetpName(playerid), playerid, GetpName(id), newname, id);
SendClientMessageToAll(COLOR_GREEN, string);
format(string, sizeof(string), "*** You change %s name to %s(%d)", GetpName(id), newname, id);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "*** Administrator %s(%d) has change your name to %s", GetpName(playerid), playerid, newname);
SendClientMessage(id, COLOR_GREEN, string);
pData[id][Pass] = dini_Int(DataPath(id), "Password");
pData[id][NoPM] = dini_Int(DataPath(id), "NoPM");
pData[id][Banned] = dini_Int(DataPath(id), "Ban");
new banreason[92];
format(banreason, 92, "%s", dini_Get(DataPath(id), "Reason"));
new banby[24];
format(banby, 24, "%s", dini_Get(DataPath(id), "BanBy"));
pData[id][Admin] = dini_Int(DataPath(id), "Admin");
pData[id][VIP] = dini_Int(DataPath(id), "VIP");
pData[id][Score] = dini_Int(DataPath(id), "Score");
pData[id][Cash] = dini_Int(DataPath(id), "Cash");
pData[id][Freeze] = dini_Int(DataPath(id), "Freeze");
pData[id][Deaths] = dini_Int(DataPath(id), "Deaths");
pData[id][Kills] = dini_Int(DataPath(id), "Kills");
dini_Remove(DataPath(id));
dini_Create(location);
dini_Set(location, "Name", newname);
dini_Set(location, "IP", IP);
dini_IntSet(location, "Password", pData[id][Pass]);
dini_IntSet(location, "Ban", pData[id][Banned]);
dini_Set(location, "Reason", banreason);
dini_Set(location, "BanBy", banby);
dini_IntSet(location, "Admin", pData[id][Admin]);
dini_IntSet(location, "VIP", pData[id][VIP]);
dini_IntSet(location, "Score", pData[id][Score]);
dini_IntSet(location, "Cash", pData[id][Cash]);
dini_IntSet(location, "Freeze", pData[id][Freeze]);
dini_IntSet(location, "Deaths", pData[id][Deaths]);
dini_IntSet(location, "Kills", pData[id][Kills]);
SetPlayerName(id, newname);
}
return 1;
}