20.05.2018, 12:49
PHP код:
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;
}