Think I am doing something wrong not sure what
#1

Hi I get no warnings or errors but I have a feeling I screwed up.






Код:
enum {
	EAdminDialog_ModifyAdmin,
	EAdminDialog_SetAdminFlag,
	EAdminDialog_AdminHelp,
	EAdminDialog_AdminCmdHelp,
}
Код:
CMD:makeadmin(playerid, params[], help) {
	new playa;
	if(help) {
		SendClientMessage(playerid, COLOR_WHITE, "Manage a players admin flags");
		return 1;
	}
	if(!sscanf(params, "u", playa)) {
		if(!IsPlayerConnected(playa)) {
			SendClientMessage(playerid, COLOR_RED, "Player not connected");
			return 1;
		}
		if(EAdminCMD:GetPVarInt(playa, "AdminFlags") & EAdminCMD_makeadmin && ~EAdminCMD:GetPVarInt(playerid, "AdminFlags") & EAdminCMD_makeadmin && GetPVarInt(playa, "AdminHidden") == 0) {
			SendClientMessage(playerid, COLOR_LIGHTRED, "You cannot use this command on this person!");
			return 1;
		}
		ShowAdminFlagsMenu(playerid, playa);
	} else {
		SendClientMessage(playerid, COLOR_WHITE, "USAGE: /makeadmin [id]");
	}
	return 1;
}

Код:
ShowAdminFlagsMenu(playerid, playa) {
	tempstr[0] = 0;
	dialogstr[0] = 0;
	new EAdminCMD:aflags = EAdminCMD:GetPVarInt(playa, "AdminFlags");
	new EAdminCMD:setterflags = EAdminCMD:GetPVarInt(playerid, "AdminFlags");
	new statustext[32]; 
	for(new i=0;i<sizeof(AdminFlagDescription);i++) {
		if(aflags&AdminFlagDescription[i][EAFIFlag] || (AdminFlagDescription[i][EAFIFlag] == EAdminCMD_None && aflags == EAdminCMD_None)) {
			statustext = "{00FF00}YES";
		} else {
			statustext = "{FF0000}NO";
		}
		format(tempstr,sizeof(tempstr),"{FFFFFF}%s - %s\n",AdminFlagDescription[i][EAFIDesc],statustext);
		strcat(dialogstr,tempstr,sizeof(dialogstr));
	}
	if(setterflags & EAdminCMD_makeadmin) {
		new title[64];
		format(title,sizeof(title),"AND NOT AdminFlag\nAND AdminFlag\nSet AdminFlags(%d)",_:aflags);
		strcat(dialogstr,title,sizeof(dialogstr));
	}
	SetPVarInt(playerid, "AdminEdit", playa);
	SetPVarInt(playerid, "AdminEditFlags", GetPVarInt(playa, "AdminFlags"));
	ShowPlayerDialog(playerid, EAdminDialog_ModifyAdmin, DIALOG_STYLE_LIST, "Modify Admin Permissions",dialogstr,"Toggle", "Done");
}
Код:
new editingadmin = GetPVarInt(playerid, "AdminEdit");
	if(dialogid == EAdminDialog_ModifyAdmin)
	{
		if(GetPVarType(playerid,"AdminEdit") == PLAYER_VARTYPE_NONE) return 0;
			if(response) {
			new EAdminCMD:aflags = EAdminCMD:GetPVarInt(editingadmin, "AdminFlags");
			new EAdminCMD:setterflags = EAdminCMD:GetPVarInt(playerid, "AdminFlags");
			if(GetPVarInt(editingadmin, "AdminHidden") == 2 && ~setterflags & EAdminCMD_makeadmin) {
				aflags = EAdminCMD_None;
			}
			if(listitem < sizeof(AdminFlagDescription)) {
			if(~setterflags & EAdminCMD_makeadmin) {
				if(~setterflags & AdminFlagDescription[listitem][EAFIFlag]) {
					ShowAdminFlagsMenu(playerid, editingadmin);
					SendClientMessage(playerid, COLOR_LIGHTRED, "You cannot elevate your privileges.");
					return 1;
				}
			}
			if(AdminFlagDescription[listitem][EAFIFlag] == EAdminCMD_None) {
				aflags = EAdminCMD_None;
			} else if(aflags & AdminFlagDescription[listitem][EAFIFlag]) {
					aflags &= ~AdminFlagDescription[listitem][EAFIFlag];
				} else {
					aflags |= AdminFlagDescription[listitem][EAFIFlag];
				}
			SetPVarInt(editingadmin,"AdminFlags",_:aflags);
			format(query,sizeof(query),"UPDATE `accounts` SET `adminlevel` = %d WHERE `id` = %d",GetPVarInt(editingadmin,"AdminFlags"), GetPVarInt(editingadmin,"AccountID"));
			mysql_function_query(MySQLCon, query, true, "EmptyCallback", "");
			ShowAdminFlagsMenu(playerid, editingadmin);
			} else {
				listitem -= sizeof(AdminFlagDescription);
				SetPVarInt(playerid, "AdminModType", listitem);
				ShowPlayerDialog(playerid,EAdminDialog_SetAdminFlag,DIALOG_STYLE_INPUT,"Enter Modification Value","Enter the value to perform the operation with:","Ok","Cancel");
				}
			} else {
				if(GetPVarInt(playerid, "AdminEditFlags") != GetPVarInt(editingadmin, "AdminFlags")) {
					format(query, sizeof(query), "* %s has edited %s's admin flags to be: %d",GetPlayerNameEx(playerid, ENameType_AccountName), GetPlayerNameEx(editingadmin, ENameType_AccountName),GetPVarInt(editingadmin,"AdminFlags"));
					SendAdminMessage(COLOR_YELLOW, query);
				}
				DeletePVar(playerid, "AdminEdit");
				DeletePVar(playerid, "AdminEditFlags");
			}
	}
	if(dialogid == EAdminDialog_SetAdminFlag)
	{
		if(GetPVarType(playerid,"AdminEdit") == PLAYER_VARTYPE_NONE) return 0;
			if(response) {
				new EAdminFlags:aflags = EAdminFlags:GetPVarInt(editingadmin, "AdminFlags");
				new type = GetPVarInt(playerid, "AdminModType");
				new EAdminFlags:value = EAdminFlags:strval(inputtext);
				switch(type) {
					case 0: {
						aflags &= ~value;
					}
					case 1: {
						aflags &= value;
					}
					case 2: {
						aflags = value;
					}
				
				}
				SetPVarInt(editingadmin,"AdminFlags",_:aflags);
				format(query,sizeof(query),"UPDATE `accounts` SET `adminlevel` = %d WHERE `id` = %d",GetPVarInt(editingadmin,"AdminFlags"), GetPVarInt(editingadmin,"AccountID"));
				mysql_function_query(MySQLCon, query, true, "EmptyCallback", "");
				ShowAdminFlagsMenu(playerid, editingadmin);
			}
			DeletePVar(playerid, "AdminModType");
	}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)