View difference between Paste ID: szFVjmDc and 4qiNBnyT
SHOW: | | - or go back to the newest paste.
1
CMD:nrn(playerid, params[])
2
{
3
	if (PlayerInfo[playerid][pAdmin] >= 2 || PlayerInfo[playerid][pSMod] == 1)
4
	{
5
		new string[128], giveplayerid;
6
		if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /nrn [player]");
7
8
		if(IsPlayerConnected(giveplayerid))
9
		{
10
			if (PlayerInfo[giveplayerid][pAdmin] >= 2)
11
			{
12
				SendClientMessageEx(playerid, COLOR_GRAD2, "You can not use that command on admins!");
13
				return 1;
14
			}
15
			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));
16
			if(PlayerInfo[playerid][pSMod] == 1) SendClientMessage(playerid, COLOR_YELLOW, string);
17
			ABroadCast( COLOR_YELLOW, string, 2);
18
			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" );
19
		}
20
	}
21
	else
22
	{
23
		SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command.");
24
	}
25
	return 1;
26
}
27
28
29
	else if( dialogid == DIALOG_NAMECHANGE )
30
	{
31
	    if(!response || strlen(inputtext) == 0) return SendClientMessageEx(playerid, COLOR_WHITE, "You have prevented yourself from changing your name." );
32
	    if(strlen(inputtext) > 20)
33
	    {
34
	        SendClientMessageEx( playerid, COLOR_WHITE, "You can't select a name that's above 20 characters." );
35
	    }
36
	    else
37
	    {
38
	        if( strlen(inputtext) >= 1 )
39
	        {
40
	            if(!response)
41
	            {
42
	                SendClientMessageEx(playerid, COLOR_WHITE, "You have prevented yourself from changing your name." );
43
	            }
44
	            else
45
	            {
46
		            for(new i = 0; i < strlen( inputtext ); i++)
47
					{
48
					    if (inputtext[i] == ' ') return SendClientMessageEx(playerid, COLOR_GRAD2, "Please use the '_'(underscore) instead of the ' '(space)");
49
					}
50
					if( strfind( inputtext, "_", true) == -1 )
51
					{
52
						SendClientMessageEx( playerid, COLOR_WHITE, "Name change rejected. Please choose a name in the correct format: Firstname_Lastname." );
53
						return 1;
54
					}
55
					new namechangecost;
56
					namechangecost = (PlayerInfo[playerid][pLevel]) * 15000;
57
58
                    new tmpName[MAX_PLAYER_NAME];
59
					mysql_real_escape_string(inputtext, tmpName);
60
					if(strcmp(inputtext, tmpName, false) != 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "Unacceptable characters used in namechange, try again");
61
					if(PlayerInfo[playerid][pMember] == 2 || PlayerInfo[playerid][pMember] == 8 || PlayerInfo[playerid][pMember] == 16)
62
					{
63
					    if(GetPVarType(playerid, "HasReport")) {
64
							SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
65
							return 1;
66
						}
67
	    				new String[128];
68
						SetPVarInt(playerid, "RequestingNameChange", 1);
69
						SetPVarString(playerid, "NewNameRequest", inputtext);
70
						SetPVarInt(playerid, "NameChangeCost", 0);
71
						new playername[MAX_PLAYER_NAME];
72
						GetPlayerName(playerid, playername, sizeof(playername));
73
		            	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);
74
		            	SendClientMessageEx( playerid, COLOR_YELLOW, String );
75
		            //	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);
76
		            //	ABroadCast( COLOR_YELLOW, String, 3 );
77
	           	 		SendReportToQue(playerid, "Name Change Request", 2, 4);
78
		            	return 1;
79
					}
80
					if(PlayerInfo[playerid][pAdmin] == 1 && PlayerInfo[playerid][pSMod] > 0)
81
					{
82
					    if(GetPVarType(playerid, "HasReport")) {
83
							SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
84
							return 1;
85
						}
86
	    				new String[128];
87
						SetPVarInt(playerid, "RequestingNameChange", 1);
88
						SetPVarString(playerid, "NewNameRequest", inputtext);
89
						new playername[MAX_PLAYER_NAME];
90
						GetPlayerName(playerid, playername, sizeof(playername));
91
		            	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);
92
		            	SendClientMessageEx( playerid, COLOR_YELLOW, String );
93
		            //	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);
94
		            //	ABroadCast( COLOR_YELLOW, String, 3 );
95
		                SendReportToQue(playerid, "Name Change Request", 2, 4);
96
		            	return 1;
97
					}
98
99
					if(GetPlayerCash(playerid) >= namechangecost)
100
					{
101
					    if(GetPVarType(playerid, "HasReport")) {
102
							SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
103
							return 1;
104
						}
105
					    new String[128];
106
						SetPVarInt(playerid, "RequestingNameChange", 1);
107
						SetPVarString(playerid, "NewNameRequest", inputtext);
108
						SetPVarInt(playerid, "NameChangeCost", namechangecost);
109
						new playername[MAX_PLAYER_NAME];
110
						GetPlayerName(playerid, playername, sizeof(playername));
111
		            	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);
112
		            	SendClientMessageEx( playerid, COLOR_YELLOW, String );
113
		            //	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);
114
		            //	ABroadCast( COLOR_YELLOW, String, 3 );
115
		            	SendReportToQue(playerid, "Name Change Request", 2, 4);
116
					}
117
					else
118
					{
119
					    SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have enough money for the name change.");
120
					}
121
	            }
122
	        }
123
	        else
124
	        {
125
	            SendClientMessageEx( playerid, COLOR_WHITE, "Your name must be longer than 1 character." );
126
	        }
127
	    }
128
	}
129
130
131
CMD:approvename(playerid, params[])
132
{
133
	new query[128], giveplayerid;
134
	if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /approvename [player]");
135
136
	if(IsPlayerConnected(giveplayerid))
137
	{
138
		if (PlayerInfo[playerid][pAdmin] >= 3)
139
		{
140
			if(GetPVarInt(giveplayerid, "RequestingNameChange") == 0)
141
			{
142
				SendClientMessageEx(playerid, COLOR_GRAD2, "That person isn't requesting a namechange!");
143
				return 1;
144
			}
145
			new newname[MAX_PLAYER_NAME], tmpName[24];
146
			GetPVarString(giveplayerid, "NewNameRequest", newname, MAX_PLAYER_NAME);
147
			mysql_real_escape_string(newname, tmpName);
148
			SetPVarString(giveplayerid, "NewNameRequest", tmpName);
149
150
			format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `Username`='%s'", tmpName);
151
			mysql_function_query(MainPipeline, query, true, "OnApproveName", "ii", playerid, giveplayerid);
152
		}
153
		else
154
		{
155
			SendClientMessageEx(playerid, COLOR_GRAD2, "You aren't authorized to use this command.");
156
		}
157
	}
158
	else
159
	{
160
		SendClientMessageEx(playerid, COLOR_GRAD2, "No Such Player");
161
	}
162
	return 1;
163
} 
164
165
forward OnApproveName(index, extraid);
166
public OnApproveName(index, extraid)
167
{
168
	if(IsPlayerConnected(extraid))
169
	{
170
		new string[128];
171
		new rows, fields;
172
		cache_get_data(rows, fields, MainPipeline);
173
		if(rows < 1)
174
		{
175
			new newname[24], oldname[24];
176
			GetPVarString(extraid, "NewNameRequest", newname, 24);
177
			GetPlayerName(extraid, oldname, sizeof(oldname));
178
179
			if(PlayerInfo[extraid][pPhousekey] != INVALID_HOUSE_ID && strcmp(oldname, HouseInfo[PlayerInfo[extraid][pPhousekey]][hOwner], true) == 0)
180
			{
181
				format(HouseInfo[PlayerInfo[extraid][pPhousekey]][hOwner], MAX_PLAYER_NAME, "%s", newname);
182
				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]);
183
				UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[extraid][pPhousekey]][hTextID], COLOR_GREEN, string);
184
				SaveHouses();
185
			}
186
187
			if(PlayerInfo[extraid][pPhousekey2] != INVALID_HOUSE_ID && strcmp(oldname, HouseInfo[PlayerInfo[extraid][pPhousekey2]][hOwner], true) == 0)
188
			{
189
				format(HouseInfo[PlayerInfo[extraid][pPhousekey2]][hOwner], MAX_PLAYER_NAME, "%s", newname);
190
				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]);
191
				UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[extraid][pPhousekey2]][hTextID], COLOR_GREEN, string);
192
				SaveHouses();
193
			}
194
195
			if(PlayerInfo[extraid][pDonateRank] >= 1)
196
			{
197
				format(string, sizeof(string), "[VIP NAMECHANGES] %s has changed their name to %s.", GetPlayerNameEx(extraid), newname);
198
				Log("logs/vipnamechanges.log", string);
199
			}
200
			if(PlayerInfo[extraid][pMember] == 2 || PlayerInfo[extraid][pMember] == 8|| PlayerInfo[extraid][pMember] == 16)
201
			{
202
				if(strlen(newname) > 0)
203
				{
204
					format(string, sizeof(string), " Your name has been changed from %s to %s for free (hitman or FBI).", GetPlayerNameEx(extraid), newname);
205
					SendClientMessageEx(extraid,COLOR_YELLOW,string);
206
					format(string, sizeof(string), " You have changed %s's name to %s at no cost.", GetPlayerNameEx(extraid), newname);
207
					SendClientMessageEx(index,COLOR_YELLOW,string);
208
					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));
209
					Log("logs/stats.log", string);
210
					format(string, sizeof(string), "%s has approved %s's name change to %s at no cost (hitman or FBI).",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
211
					ABroadCast(COLOR_YELLOW, string, 3);
212
213
					format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
214
					mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
215
216
					SetPlayerName(extraid, newname);
217
218
					DeletePVar(extraid, "RequestingNameChange");
219
				}
220
			}
221
			else if(PlayerInfo[extraid][pAdmin] == 1 && PlayerInfo[extraid][pSMod] > 0)
222
			{
223
				if(strlen(newname) > 0)
224
				{
225
					format(string, sizeof(string), " Your name has been changed from %s to %s for free (Senior Mod).", GetPlayerNameEx(extraid), newname);
226
					SendClientMessageEx(extraid,COLOR_YELLOW,string);
227
					format(string, sizeof(string), " You have changed %s's name to %s at no cost.", GetPlayerNameEx(extraid), newname);
228
					SendClientMessageEx(index,COLOR_YELLOW,string);
229
					format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for free (Senior Mod).",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid));
230
					Log("logs/stats.log", string);
231
					format(string, sizeof(string), "%s has approved %s's name change to %s at no cost (Senior Mod).",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
232
					ABroadCast(COLOR_YELLOW, string, 3);
233
234
					format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
235
					mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
236
237
					SetPlayerName(extraid, newname);
238
239
					DeletePVar(extraid, "RequestingNameChange");
240
				}
241
			}
242
			else
243
			{
244
				if(GetPVarInt(extraid, "NameChangeCost") == 0)
245
				{
246
					if(strlen(newname) > 0)
247
					{
248
						format(string, sizeof(string), " Your name has been changed from %s to %s for free (non-RP name).", GetPlayerNameEx(extraid), newname);
249
						SendClientMessageEx(extraid,COLOR_YELLOW,string);
250
						format(string, sizeof(string), " You have changed %s's name to %s for free (non-RP name).", GetPlayerNameEx(extraid), newname);
251
						SendClientMessageEx(index,COLOR_YELLOW,string);
252
						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));
253
						Log("logs/stats.log", string);
254
						format(string, sizeof(string), "%s has approved %s's name change to %s for free (non-RP name).",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
255
						ABroadCast(COLOR_YELLOW, string, 3);
256
257
						format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
258
						mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
259
260
						SetPlayerName(extraid, newname);
261
262
						DeletePVar(extraid, "RequestingNameChange");
263
					}
264
				}
265
				else
266
				{
267
					if(strlen(newname) > 0)
268
					{
269
						GivePlayerCash(extraid, -GetPVarInt(extraid, "NameChangeCost"));
270
						format(string, sizeof(string), " Your name has been changed from %s to %s for $%d.", GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
271
						SendClientMessageEx(extraid,COLOR_YELLOW,string);
272
						format(string, sizeof(string), " You have changed %s's name to %s for $%d.", GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
273
						SendClientMessageEx(index,COLOR_YELLOW,string);
274
						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"));
275
						Log("logs/stats.log", string);
276
						format(string, sizeof(string), "%s has approved %s's name change to %s for $%d",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
277
						ABroadCast(COLOR_YELLOW, string, 3);
278
279
						format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
280
						mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
281
282
						SetPlayerName(extraid, newname);
283
284
						DeletePVar(extraid, "RequestingNameChange");
285
					}
286
				}
287
			}
288
		}
289
		else
290
		{
291
			SendClientMessageEx(extraid, COLOR_GRAD2, "That name already exists, please choose a different one.");
292
			SendClientMessageEx(index, COLOR_GRAD2, "That name already exists.");
293
			DeletePVar(extraid, "RequestingNameChange");
294
			return 1;
295
		}
296
	}
297
	return 1;
298
}