CMD:rename(playerid,params[]){
if(PlayerInfo[playerid][Level] >= 6){
new Index;
new tmp[256]; tmp = strtok(params,Index);
new tmp2[256]; tmp2 = strtok(params,Index);
if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "Usage: /rename [playerid] [new name]");
new player1 = strval(tmp);
new length = strlen(tmp2);
new string[128];
if(udb_Exists(tmp2)) return SendClientMessage(playerid, COLOR_RED, "That Name is already in use!");
if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel])
return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
{
strmid(VehicleInfo[PlayerInfo[player1][vowned]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned2]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned3]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned4]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned5]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned6]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned7]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned8]][owner], tmp2, 0, strlen(tmp2), 255);
new str1[256];
new housenumber = dini_Int(str1, "Houseid");
format(str1, sizeof(str1), "SATDM/Houses/houseid%d", housenumber);
dini_Set(str1, "Name",tmp2);
strmid(HouseInfo[housenumber][Name],tmp2,sizeof(tmp2),255);
new hnowner[30];
format(hnowner,128,"%s",HouseInfo[housenumber][Name]);
if(strcmp(HouseInfo[housenumber][Name],DEFAULT_OWNER,false) == 0) {
format(hnowner,128,"Not Owned");
}
UpdateDynamic3DTextLabelText(HouseTextInfo[housenumber],0xFF0000FF,hnowner);
new BizID = PlayerInfo[player1][bowned];
strmid(BizInfo[BizID][owner], tmp2, 0, strlen(tmp2), 255);
new bizowner[30];
format(bizowner,128,"%s",BizInfo[BizID][owner]);
if(strcmp(BizInfo[BizID][owner],DEFAULT_OWNER,false) == 0) {
format(bizowner,128,"Not Owned");
}
UpdateDynamic3DTextLabelText(bizTextInfo[BizID],0xFF0000FF,bizowner);
DOF2_RenameFile(DOF2_File(PlayerName2(player1)), DOF2_File(tmp2));
SetPlayerName(player1, tmp2);
CMDMessageToAdmins(playerid,"RENAME");
format(string, sizeof(string), "|- You have set \"%s's\" Name to \"%s\" -|", PlayerName2(player1), tmp2);
SendClientMessage(playerid,blue,string);
if(player1 != playerid)
{
format(string,sizeof(string),"|- Administrator \"%s\" has set your Name to \"%s\" -|", pName(playerid), tmp2);
SendClientMessage(player1,blue,string);
}
return OnPlayerConnect(player1);
} else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
PHP код:
Admin levels, score, money transfered succesfuly. But, the old house and business are not transfered, still the old name. Please help me [REP+] Sorry for my bad english |
CMD:rename(playerid, params[])
{
if(PlayerInfo[playerid][Level] < 6) return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
new targetid, newname[MAX_PLAYER_NAME], string[128];
if(sscanf(params, "us[24]", targetid, newname)) return SendClientMessage(playerid, red, "Usage: /rename [playerid] [new name]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,red,"ERROR: Player is not connected");
if(strlen(newname) < 3 || strlen(inputtext) > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length");
if(PlayerInfo[targetid][Level] > PlayerInfo[playerid][Level]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on higher admin level than you.");
if(udb_Exists(newname)) return SendClientMessage(playerid, COLOR_RED, "That Name is already in use!");
SetPlayerName(targetid, newname);
// I haven't done any changes to this part because I'm not the best with Dini. I suggest you to move onto MySQL.
/*
strmid(VehicleInfo[PlayerInfo[player1][vowned]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned2]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned3]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned4]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned5]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned6]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned7]][owner], tmp2, 0, strlen(tmp2), 255);
strmid(VehicleInfo[PlayerInfo[player1][vowned8]][owner], tmp2, 0, strlen(tmp2), 255);
new str1[256];
new housenumber = dini_Int(str1, "Houseid");
format(str1, sizeof(str1), "SATDM/Houses/houseid%d", housenumber);
dini_Set(str1, "Name",tmp2);
strmid(HouseInfo[housenumber][Name],tmp2,sizeof(tmp2),255);
new hnowner[30];
format(hnowner,128,"%s",HouseInfo[housenumber][Name]);
if(strcmp(HouseInfo[housenumber][Name],DEFAULT_OWNER,false) == 0) {
format(hnowner,128,"Not Owned");
}
UpdateDynamic3DTextLabelText(HouseTextInfo[housenumber],0xFF0000FF,hnowner);
new BizID = PlayerInfo[player1][bowned];
strmid(BizInfo[BizID][owner], tmp2, 0, strlen(tmp2), 255);
new bizowner[30];
format(bizowner,128,"%s",BizInfo[BizID][owner]);
if(strcmp(BizInfo[BizID][owner],DEFAULT_OWNER,false) == 0) {
format(bizowner,128,"Not Owned");
}
UpdateDynamic3DTextLabelText(bizTextInfo[BizID],0xFF0000FF,bizowner);
DOF2_RenameFile(DOF2_File(PlayerName2(player1)), DOF2_File(tmp2));
*/
if(playerid == targetid)
format(string, sizeof(string), "You have changed your name to %s", newname);
else
format(string, sizeof(string), "Administrator %s has set your Name to %s", pName(playerid), newname);
SendClientMessage(targetid, red, string);
return 1;
}
PHP код:
|
cmd(rename,playerid,params[]) { if(PlayerInfo[playerid][Level] < 5) return ShowPlayerDialog(playerid, 199, DIALOG_STYLE_MSGBOX, "{FF0000}INFO: No Tienes level para este Comando", "\n{FF0000}ERROR: {FFFFFF}You are not a high enough level to use this command\n\n{FF0000}ERROR: {FFFFFF}No tienes level suficiente para usar este comando", "Aceptar", ""); new file[256],file2[256]; new Index; new tmp[256]; tmp = strtok(params,Index); new tmp2[256]; tmp2 = strtok(params,Index); if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "Usage: /rename [playerid] [new name]") && SendClientMessage(playerid, blue, "Function: Will change someone's account name!"); new player1 = strval(tmp); new length = strlen(tmp2); new string[128]; format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(pName(player1))); format(file2,sizeof(file2),"/ladmin/users/%s.sav",udb_encode(tmp2)); if(fexist(file2)) return SendClientMessage(playerid, red, "ERROR: Account already exists!"); if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length"); if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin"); if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) { if(PlayerInfo[player1][vowner] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner2] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned2]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner3] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned3]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner4] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned4]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner5] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned5]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner6] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned6]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner7] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned7]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner8] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned8]][owner], tmp2, 0, strlen(tmp2), 255); } #if defined EXTRA_V_SLOTS strmid(VehicleInfo[PlayerInfo[player1][vowned11]][owner], tmp2, 0, strlen(tmp2), 255); strmid(VehicleInfo[PlayerInfo[player1][vowned12]][owner], tmp2, 0, strlen(tmp2), 255); strmid(VehicleInfo[PlayerInfo[player1][vowned13]][owner], tmp2, 0, strlen(tmp2), 255); strmid(VehicleInfo[PlayerInfo[player1][vowned14]][owner], tmp2, 0, strlen(tmp2), 255); strmid(VehicleInfo[PlayerInfo[player1][vowned15]][owner], tmp2, 0, strlen(tmp2), 255); #endif new str1[256]; new housenumber = dini_Int(file, "Houseid"); if(housenumber != -255) { format(str1, sizeof(str1), "UGC/Houses/houseid%d", housenumber); dini_Set(str1, "Name",tmp2); strmid(hInfo[housenumber][Name], tmp2, 0, strlen(tmp2), 255); new hnowner[30]; format(hnowner,128,"%s",hInfo[housenumber][Name]); if(strcmp(hInfo[housenumber][Name],DEFAULT_OWNER,false) == 0) { format(hnowner,128,"%s",tmp2); } UpdateDynamic3DTextLabelText(hTextInfo[housenumber],0xFF0000FF,hnowner); } new BizID = PlayerInfo[player1][bowned]; if(BizID != 0) { strmid(BizInfo[BizID][owner], tmp2, 0, strlen(tmp2), 255); new bizowner[30]; format(bizowner,128,"%s",BizInfo[BizID][owner]); if(strcmp(BizInfo[BizID][owner],DEFAULT_OWNER,false) == 0) { format(bizowner,128,"Thiz Biz For Sale"); } UpdateDynamic3DTextLabelText(bizTextInfo[BizID],0xFF0000FF,bizowner); } strmid(PlayerInfo[player1][name], tmp2, 0, strlen(tmp2), 255); SavePlayer(player1); frename(file,file2); SetPlayerName(player1, tmp2); CMDMessageToAdmins(playerid,"rename"); format(string, sizeof(string), "|- You have set \"%s's\" Name to \"%s\" -|", PlayerName2(player1), tmp2); SendClientMessage(playerid,blue,string); if(housenumber != -255) if(player1 != playerid) { format(string,sizeof(string),"|- Administrator \"%s\" has set your Name to \"%s\" -|", pName(playerid), tmp2); SendClientMessage(player1,blue,string); } SavePlayer(player1); return OnPlayerConnect(player1); } else return SendClientMessage(playerid,red,"ERROR: User isn't online"); }
Код:
cmd(rename,playerid,params[]) { if(PlayerInfo[playerid][Level] < 5) return ShowPlayerDialog(playerid, 199, DIALOG_STYLE_MSGBOX, "{FF0000}INFO: No Tienes level para este Comando", "\n{FF0000}ERROR: {FFFFFF}You are not a high enough level to use this command\n\n{FF0000}ERROR: {FFFFFF}No tienes level suficiente para usar este comando", "Aceptar", ""); new file[256],file2[256]; new Index; new tmp[256]; tmp = strtok(params,Index); new tmp2[256]; tmp2 = strtok(params,Index); if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "Usage: /rename [playerid] [new name]") && SendClientMessage(playerid, blue, "Function: Will change someone's account name!"); new player1 = strval(tmp); new length = strlen(tmp2); new string[128]; format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(pName(player1))); format(file2,sizeof(file2),"/ladmin/users/%s.sav",udb_encode(tmp2)); if(fexist(file2)) return SendClientMessage(playerid, red, "ERROR: Account already exists!"); if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid,red,"ERROR: Incorrect Name Length"); if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin"); if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) { if(PlayerInfo[player1][vowner] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner2] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned2]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner3] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned3]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner4] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned4]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner5] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned5]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner6] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned6]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner7] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned7]][owner], tmp2, 0, strlen(tmp2), 255); } if(PlayerInfo[player1][vowner8] != 0) { strmid(VehicleInfo[PlayerInfo[player1][vowned8]][owner], tmp2, 0, strlen(tmp2), 255); } #if defined EXTRA_V_SLOTS strmid(VehicleInfo[PlayerInfo[player1][vowned11]][owner], tmp2, 0, strlen(tmp2), 255); strmid(VehicleInfo[PlayerInfo[player1][vowned12]][owner], tmp2, 0, strlen(tmp2), 255); strmid(VehicleInfo[PlayerInfo[player1][vowned13]][owner], tmp2, 0, strlen(tmp2), 255); strmid(VehicleInfo[PlayerInfo[player1][vowned14]][owner], tmp2, 0, strlen(tmp2), 255); strmid(VehicleInfo[PlayerInfo[player1][vowned15]][owner], tmp2, 0, strlen(tmp2), 255); #endif new str1[256]; new housenumber = dini_Int(file, "Houseid"); if(housenumber != -255) { format(str1, sizeof(str1), "UGC/Houses/houseid%d", housenumber); dini_Set(str1, "Name",tmp2); strmid(hInfo[housenumber][Name], tmp2, 0, strlen(tmp2), 255); new hnowner[30]; format(hnowner,128,"%s",hInfo[housenumber][Name]); if(strcmp(hInfo[housenumber][Name],DEFAULT_OWNER,false) == 0) { format(hnowner,128,"%s",tmp2); } UpdateDynamic3DTextLabelText(hTextInfo[housenumber],0xFF0000FF,hnowner); } new BizID = PlayerInfo[player1][bowned]; if(BizID != 0) { strmid(BizInfo[BizID][owner], tmp2, 0, strlen(tmp2), 255); new bizowner[30]; format(bizowner,128,"%s",BizInfo[BizID][owner]); if(strcmp(BizInfo[BizID][owner],DEFAULT_OWNER,false) == 0) { format(bizowner,128,"Thiz Biz For Sale"); } UpdateDynamic3DTextLabelText(bizTextInfo[BizID],0xFF0000FF,bizowner); } strmid(PlayerInfo[player1][name], tmp2, 0, strlen(tmp2), 255); SavePlayer(player1); frename(file,file2); SetPlayerName(player1, tmp2); CMDMessageToAdmins(playerid,"rename"); format(string, sizeof(string), "|- You have set \"%s's\" Name to \"%s\" -|", PlayerName2(player1), tmp2); SendClientMessage(playerid,blue,string); if(housenumber != -255) if(player1 != playerid) { format(string,sizeof(string),"|- Administrator \"%s\" has set your Name to \"%s\" -|", pName(playerid), tmp2); SendClientMessage(player1,blue,string); } SavePlayer(player1); return OnPlayerConnect(player1); } else return SendClientMessage(playerid,red,"ERROR: User isn't online"); } |