Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CMD:nrn(playerid, params[])
- {
- if (PlayerInfo[playerid][pAdmin] >= 2 || PlayerInfo[playerid][pSMod] == 1)
- {
- new string[128], giveplayerid;
- if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /nrn [player]");
- if(IsPlayerConnected(giveplayerid))
- {
- if (PlayerInfo[giveplayerid][pAdmin] >= 2)
- {
- SendClientMessageEx(playerid, COLOR_GRAD2, "You can not use that command on admins!");
- return 1;
- }
- format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s has offered %s a free name change because their name is non-RP.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid));
- if(PlayerInfo[playerid][pSMod] == 1) SendClientMessage(playerid, COLOR_YELLOW, string);
- ABroadCast( COLOR_YELLOW, string, 2);
- ShowPlayerDialog(giveplayerid, DIALOG_NAMECHANGE2, DIALOG_STYLE_INPUT, "Free name change","This is a roleplay server where you must have a name in this format: Firstname_Lastname.\nFor example: John_Smith or Jimmy_Johnson\n\nAn admin has offered you to change your name to the correct format for free. Please enter your desired name below.\n\nNote: If you press cancel you will be kicked from the server.", "Change", "Cancel" );
- }
- }
- else
- {
- SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
- }
- return 1;
- }
- else if( dialogid == DIALOG_NAMECHANGE )
- {
- if(!response || strlen(inputtext) == 0) return SendClientMessageEx(playerid, COLOR_WHITE, "You have prevented yourself from changing your name." );
- if(strlen(inputtext) > 20)
- {
- SendClientMessageEx( playerid, COLOR_WHITE, "You can't select a name that's above 20 characters." );
- }
- else
- {
- if( strlen(inputtext) >= 1 )
- {
- if(!response)
- {
- SendClientMessageEx(playerid, COLOR_WHITE, "You have prevented yourself from changing your name." );
- }
- else
- {
- for(new i = 0; i < strlen( inputtext ); i++)
- {
- if (inputtext[i] == ' ') return SendClientMessageEx(playerid, COLOR_GRAD2, "Please use the '_'(underscore) instead of the ' '(space)");
- }
- if( strfind( inputtext, "_", true) == -1 )
- {
- SendClientMessageEx( playerid, COLOR_WHITE, "Name change rejected. Please choose a name in the correct format: Firstname_Lastname." );
- return 1;
- }
- new namechangecost;
- namechangecost = (PlayerInfo[playerid][pLevel]) * 15000;
- new tmpName[MAX_PLAYER_NAME];
- mysql_real_escape_string(inputtext, tmpName);
- if(strcmp(inputtext, tmpName, false) != 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "Unacceptable characters used in namechange, try again");
- if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pMember] == 16)
- {
- if(GetPVarType(playerid, "HasReport")) {
- SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
- return 1;
- }
- new String[128];
- SetPVarInt(playerid, "RequestingNameChange", 1);
- SetPVarString(playerid, "NewNameRequest", inputtext);
- SetPVarInt(playerid, "NameChangeCost", 0);
- new playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- format( String, sizeof( String ), "You have requested a namechange from %s to %s at no cost (hitman or FBI), please wait until a General Admin approves it.", playername, inputtext);
- SendClientMessageEx( playerid, COLOR_YELLOW, String );
- // format( String, sizeof( String ), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) requested a name change to %s for free - /approvename %d (accept), or /denyname %d (deny).", playername, playerid, inputtext, playerid, playerid);
- // ABroadCast( COLOR_YELLOW, String, 3 );
- SendReportToQue(playerid, "Name Change Request", 2, 4);
- return 1;
- }
- if(PlayerInfo[playerid][pAdmin] == 1 && PlayerInfo[playerid][pSMod] > 0)
- {
- if(GetPVarType(playerid, "HasReport")) {
- SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
- return 1;
- }
- new String[128];
- SetPVarInt(playerid, "RequestingNameChange", 1);
- SetPVarString(playerid, "NewNameRequest", inputtext);
- new playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- format( String, sizeof( String ), "You have requested a namechange from %s to %s at no cost (Senior Mod), please wait until a General Admin approves it.", playername, inputtext, namechangecost);
- SendClientMessageEx( playerid, COLOR_YELLOW, String );
- // format( String, sizeof( String ), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) requested a name change to %s for free - /approvename %d (accept), or /denyname %d (deny).", playername, playerid, inputtext, playerid, playerid);
- // ABroadCast( COLOR_YELLOW, String, 3 );
- SendReportToQue(playerid, "Name Change Request", 2, 4);
- return 1;
- }
- if(GetPlayerCash(playerid) >= namechangecost)
- {
- if(GetPVarType(playerid, "HasReport")) {
- SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
- return 1;
- }
- new String[128];
- SetPVarInt(playerid, "RequestingNameChange", 1);
- SetPVarString(playerid, "NewNameRequest", inputtext);
- SetPVarInt(playerid, "NameChangeCost", namechangecost);
- new playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid, playername, sizeof(playername));
- format( String, sizeof( String ), "You have requested a namechange from %s to %s for $%d, please wait until a General Admin approves it.", playername, inputtext, namechangecost);
- SendClientMessageEx( playerid, COLOR_YELLOW, String );
- // format( String, sizeof( String ), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) requested a name change to %s for $%d - /approvename %d (accept), or /denyname %d (deny).", playername, playerid, inputtext, namechangecost, playerid, playerid);
- // ABroadCast( COLOR_YELLOW, String, 3 );
- SendReportToQue(playerid, "Name Change Request", 2, 4);
- }
- else
- {
- SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have enough money for the name change.");
- }
- }
- }
- else
- {
- SendClientMessageEx( playerid, COLOR_WHITE, "Your name must be longer than 1 character." );
- }
- }
- }
- CMD:approvename(playerid, params[])
- {
- new query[128], giveplayerid;
- if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /approvename [player]");
- if(IsPlayerConnected(giveplayerid))
- {
- if (PlayerInfo[playerid][pAdmin] >= 3)
- {
- if(GetPVarInt(giveplayerid, "RequestingNameChange") == 0)
- {
- SendClientMessageEx(playerid, COLOR_GRAD2, "That person isn't requesting a namechange!");
- return 1;
- }
- new newname[MAX_PLAYER_NAME], tmpName[24];
- GetPVarString(giveplayerid, "NewNameRequest", newname, MAX_PLAYER_NAME);
- mysql_real_escape_string(newname, tmpName);
- SetPVarString(giveplayerid, "NewNameRequest", tmpName);
- format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `Username`='%s'", tmpName);
- mysql_function_query(MainPipeline, query, true, "OnApproveName", "ii", playerid, giveplayerid);
- }
- else
- {
- SendClientMessageEx(playerid, COLOR_GRAD2, "You aren't authorized to use this command.");
- }
- }
- else
- {
- SendClientMessageEx(playerid, COLOR_GRAD2, "No Such Player");
- }
- return 1;
- }
- forward OnApproveName(index, extraid);
- public OnApproveName(index, extraid)
- {
- if(IsPlayerConnected(extraid))
- {
- new string[128];
- new rows, fields;
- cache_get_data(rows, fields, MainPipeline);
- if(rows < 1)
- {
- new newname[24], oldname[24];
- GetPVarString(extraid, "NewNameRequest", newname, 24);
- GetPlayerName(extraid, oldname, sizeof(oldname));
- if(PlayerInfo[extraid][pPhousekey] != INVALID_HOUSE_ID && strcmp(oldname, HouseInfo[PlayerInfo[extraid][pPhousekey]][hOwner], true) == 0)
- {
- format(HouseInfo[PlayerInfo[extraid][pPhousekey]][hOwner], MAX_PLAYER_NAME, "%s", newname);
- format(string, sizeof(string), "This house is owned by\n %s\nLevel: %d\nID: %d",HouseInfo[PlayerInfo[extraid][pPhousekey]][hOwner],HouseInfo[PlayerInfo[extraid][pPhousekey]][hLevel],PlayerInfo[extraid][pPhousekey]);
- UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[extraid][pPhousekey]][hTextID], COLOR_GREEN, string);
- SaveHouses();
- }
- if(PlayerInfo[extraid][pPhousekey2] != INVALID_HOUSE_ID && strcmp(oldname, HouseInfo[PlayerInfo[extraid][pPhousekey2]][hOwner], true) == 0)
- {
- format(HouseInfo[PlayerInfo[extraid][pPhousekey2]][hOwner], MAX_PLAYER_NAME, "%s", newname);
- format(string, sizeof(string), "This house is owned by\n %s\nLevel: %d\nID: %d",HouseInfo[PlayerInfo[extraid][pPhousekey2]][hOwner],HouseInfo[PlayerInfo[extraid][pPhousekey2]][hLevel],PlayerInfo[extraid][pPhousekey2]);
- UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[extraid][pPhousekey2]][hTextID], COLOR_GREEN, string);
- SaveHouses();
- }
- if(PlayerInfo[extraid][pDonateRank] >= 1)
- {
- format(string, sizeof(string), "[VIP NAMECHANGES] %s has changed their name to %s.", GetPlayerNameEx(extraid), newname);
- Log("logs/vipnamechanges.log", string);
- }
- if(PlayerInfo[extraid][pMember] == 2 || PlayerInfo[extraid][pMember] == 8|| PlayerInfo[extraid][pMember] == 16)
- {
- if(strlen(newname) > 0)
- {
- format(string, sizeof(string), " Your name has been changed from %s to %s for free (hitman or FBI).", GetPlayerNameEx(extraid), newname);
- SendClientMessageEx(extraid,COLOR_YELLOW,string);
- format(string, sizeof(string), " You have changed %s's name to %s at no cost.", GetPlayerNameEx(extraid), newname);
- SendClientMessageEx(index,COLOR_YELLOW,string);
- format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for free (hitman or FBI).",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid));
- Log("logs/stats.log", string);
- format(string, sizeof(string), "%s has approved %s's name change to %s at no cost (hitman or FBI).",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
- ABroadCast(COLOR_YELLOW, string, 3);
- format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
- mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
- SetPlayerName(extraid, newname);
- DeletePVar(extraid, "RequestingNameChange");
- }
- }
- else if(PlayerInfo[extraid][pAdmin] == 1 && PlayerInfo[extraid][pSMod] > 0)
- {
- if(strlen(newname) > 0)
- {
- format(string, sizeof(string), " Your name has been changed from %s to %s for free (Senior Mod).", GetPlayerNameEx(extraid), newname);
- SendClientMessageEx(extraid,COLOR_YELLOW,string);
- format(string, sizeof(string), " You have changed %s's name to %s at no cost.", GetPlayerNameEx(extraid), newname);
- SendClientMessageEx(index,COLOR_YELLOW,string);
- format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for free (Senior Mod).",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid));
- Log("logs/stats.log", string);
- format(string, sizeof(string), "%s has approved %s's name change to %s at no cost (Senior Mod).",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
- ABroadCast(COLOR_YELLOW, string, 3);
- format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
- mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
- SetPlayerName(extraid, newname);
- DeletePVar(extraid, "RequestingNameChange");
- }
- }
- else
- {
- if(GetPVarInt(extraid, "NameChangeCost") == 0)
- {
- if(strlen(newname) > 0)
- {
- format(string, sizeof(string), " Your name has been changed from %s to %s for free (non-RP name).", GetPlayerNameEx(extraid), newname);
- SendClientMessageEx(extraid,COLOR_YELLOW,string);
- format(string, sizeof(string), " You have changed %s's name to %s for free (non-RP name).", GetPlayerNameEx(extraid), newname);
- SendClientMessageEx(index,COLOR_YELLOW,string);
- format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for free (non-RP name).",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid));
- Log("logs/stats.log", string);
- format(string, sizeof(string), "%s has approved %s's name change to %s for free (non-RP name).",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
- ABroadCast(COLOR_YELLOW, string, 3);
- format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
- mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
- SetPlayerName(extraid, newname);
- DeletePVar(extraid, "RequestingNameChange");
- }
- }
- else
- {
- if(strlen(newname) > 0)
- {
- GivePlayerCash(extraid, -GetPVarInt(extraid, "NameChangeCost"));
- format(string, sizeof(string), " Your name has been changed from %s to %s for $%d.", GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
- SendClientMessageEx(extraid,COLOR_YELLOW,string);
- format(string, sizeof(string), " You have changed %s's name to %s for $%d.", GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
- SendClientMessageEx(index,COLOR_YELLOW,string);
- format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for $%d",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid), GetPVarInt(extraid, "NameChangeCost"));
- Log("logs/stats.log", string);
- format(string, sizeof(string), "%s has approved %s's name change to %s for $%d",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
- ABroadCast(COLOR_YELLOW, string, 3);
- format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
- mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
- SetPlayerName(extraid, newname);
- DeletePVar(extraid, "RequestingNameChange");
- }
- }
- }
- }
- else
- {
- SendClientMessageEx(extraid, COLOR_GRAD2, "That name already exists, please choose a different one.");
- SendClientMessageEx(index, COLOR_GRAD2, "That name already exists.");
- DeletePVar(extraid, "RequestingNameChange");
- return 1;
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement