ChineZeu

member
Scor reacție
37
Acum cateva zile din nevoie am intrat pe TW Mentor pentru faimosul script Power farmer
dar surpriza... vad ca ultimele lumi nu sunt trecute in lista
totusi am reusit sa obtin scriptul folosind lumea 20
dar vad in script...
Cod:
<br />
<b>Warning</b>:  sort() expects parameter 1 to be array, null given in <b>/var/www/twmentor/stable/htdocs/tools/power.php</b> on line <b>736</b><br />
asa ca m-am apucat sa o fac pe scripterul
putin de aici, putin de acolo... imi merge

dar din una in alta am dat si de un Bug pe care il avea inca de la inceputuri
acesta fiind motivul pentru care am deschis aceasta tema
sper ca nu am gresit...

Cod:
{
	case :
		coords = '';
		break;
	default:
		alert('No farm plan for this village (' + v_id + ')');
		show_ajax_inline_popup('group_popup', '/game.php?village=' + v_id + '&screen=groups&mode=overview&ajax=load_groups', null, 'ds_body', $('popup_close').value, '100px', '100px', '320px', null, true, 'handle_group_list');
		exit;
	}
dupa eroarea ”No farm plan for this village” ar trebui sa apara un popup cu satele din grupa
dar apare asta...
captura.png

se pare ca e popup-ul care ar trebui sa arate satele, dar e gol:(

daca deschid popup-ul manual si dupa dau click pe script il incarca corect...

Cod:
javascript: function o(a)
{
	b = location.search;
	c = new RegExp("\\b" + a + "\\b");
	if(b.match(c))
	{
		return 1;
	}
	else
	{
		location.search = b.replace(/.*?(\bvillage=\d+).*/i, '?$1&' + a);
		return 0;
	}
}
if(o('screen=place'))
{
	sp = 0;
	sw = 0;
	ax = 0;
	lc = 0;
	hc = 0;
	var doc = document;
	var v_id;
	twgameCookie = document.cookie.match('(^|;) ?global_village_id=([^;]*)(;|$)');
	v_id = parseInt(twgameCookie[2]);
	switch(v_id)
	{
	case :
		lc = 10;
		coords = 'xxx|yyy';
		break;
	default:
		alert('No farm plan for this village (' + v_id + ')');
		show_ajax_inline_popup('group_popup', '/game.php?village=' + v_id + '&screen=groups&mode=overview&ajax=load_groups', null, 'ds_body', $('popup_close').value, '100px', '100px', '320px', null, true, 'handle_group_list');
		exit;
	}
	if(window.frames.length > 0) doc = window.main.document;
	url = document.URL;
	if(url.indexOf('screen=place') == -1) alert('This script needs to be run from the Rally Point');
	coords = coords.split(" ");
	index = 0;
	farmcookie = document.cookie.match('(^|;) ?TWMentor=([^;]*)(;|$)');
	var newCookie = "";
	if(farmcookie != null)
	{
		farmStopLog = farmcookie[2].split("#");
		var x = 1;
		var found = -1;
		while(x < farmStopLog.length)
		{
			farmStopLogCase = farmStopLog[x - 1].split("@");
			if(v_id == farmStopLogCase[0])
			{
				found = 1;
				index = parseInt(farmStopLogCase[1]);
				if(index >= coords.length)
				{
					alert('End reached, starting over');
					index = 0;
					index = parseInt(index);
				}
				coords = coords[index];
				coords = coords.split("|");
				index = index + 1;
				newCookie = newCookie + v_id + "@" + index + "#";
			}
			else
			{
				newCookie = newCookie + farmStopLogCase[0] + "@" + farmStopLogCase[1] + "#";
			}
			x++;
		}
		if(found != 1)
		{
			newCookie = newCookie + v_id + "@0#";
			index = 0;
			index = parseInt(index);
			coords = coords[index];
			coords = coords.split("|");
		}
	}
	else
	{
		newCookie = newCookie + v_id + "@1#";
		index = 1;
		index = parseInt(index);
		coords = coords[index];
		coords = coords.split("|");
	}
	cookie_date = new Date(2019, 11, 11);
	document.cookie = "TWMentor=" + newCookie + "; expires=" + cookie_date.toGMTString();
	doc.forms[0].x.value = coords[0];
	doc.forms[0].y.value = coords[1];
	insertUnit(doc.forms[0].spear, sp);
	insertUnit(doc.forms[0].sword, sw);
	insertUnit(doc.forms[0].axe, ax);
	insertUnit(doc.forms[0].spy, 1);
	insertUnit(doc.forms[0].light, lc);
	insertUnit(doc.forms[0].heavy, hc);
}

Va rog pe voi cei care cunoasteti jocul si cateva despre scripturi sa ma ajutati daca puteti
 

DeletedUser

Jackass poate ne ajuti un pic pentru ca o sa avem mare nevoie pentru urmatoarea lume :) .
Multumesc .
 

DeletedUser

chinezule - proiectul tw mentor nu face parte din INNO , un fost player a facut site-ul dar din pacate a abandonat proiectul ...
 

ChineZeu

member
Scor reacție
37
da,stiu ca nu face parte din INNO
am incercat sa contactez autorul scriptului, dar nimic
de 3 zile caut peste tot solutii, dar tot la fel... nimic

am gasit totusi ceva care cred eu ca poate fi de ajutor
partea de script al jocului care ar trebui sa raspunda la comanda scriptului PowerFarmer
dar nu stiu daca e din versiunea 8.2

la o privire de inexpert ce sunt pare ca e totul in regula, exceptie facand ”height” care vad ca lipseste in scriptul PowerFarmer
Cod:
/** ** game/dialogs.js *** */
/* 39716ff69ca45f7d4854d327ca86e348 */

function show_ajax_inline_popup(popup_id, content_url, content_existing, target, close_text, x, y, width, height, global, display_handler, html_request)
{
	var width_css = width !== null ? "width: " + width + ";" : "",
		height_css = height !== null ? "height: " + height + ";" : "";
	height_css += ' max-height:95%;';
	target = $("#" + target);
	if(!x) x = 100;
	if(!y) y = 100;
	if(popup_id !== null)
	{
		var popup = $("<div>").addClass('popup_style').attr("style", "overflow:auto; top:" + y + ";left:" + x + ";" + width_css + height_css).attr("id", "" + popup_id),
			menu = $("<div>").addClass('popup_menu').attr("id", popup_id + "_menu").attr("style", "position:relative;z-index: 9999; top:'" + y + "';left:'" + x + "';'" + width_css + "'margin-top: -17px;"),
			href = "javascript:toggle_element('#" + popup_id + "');";
		if(global) href += "closePopup();";
		menu.append($("<a>").attr('href', href).attr('style', 'float: right; padding-right: 3px; padding-left:3px;').html(close_text));
		var content = $("<div>").attr("id", popup_id + '_content').addClass("popup_content");
		popup.append(menu).append(content);
		target.append(popup);
		var offset = popup.offset();
		popup.draggable(
		{
			handle: menu,
			stop: function (event, ui)
			{
				if(global) $.cookie("global_popups", {
					popup_id: popup_id,
					content_url: content_url,
					content_existing: content_existing,
					target: target,
					close_text: close_text,
					x: offset.left,
					y: offset.top,
					width: width,
					height: height,
					global: true,
					display_handler: display_handler,
					mode: "overview",
					html_request: html_request
				});
			}
		});
		if(global) $.cookie("global_popups", {
			popup_id: popup_id,
			content_url: content_url,
			content_existing: content_existing,
			target: target,
			close_text: close_text,
			x: offset.left,
			y: offset.top,
			width: width,
			height: height,
			global: true,
			display_handler: display_handler,
			mode: "overview",
			html_request: html_request
		});
	};
	if(content_existing !== null)
	{
		var content = $("#" + content_existing).clone();
		content.attr("id", null);
		$("#" + popup_id + '_content').empty();
		content.css('display', 'block');
		$("#" + popup_id + '_content').append(content);
	};
	$.ajax(
	{
		type: 'GET',
		url: content_url,
		dataType: 'json',
		success: display_handler
	});
	$("#" + popup_id + "_menu").show();
	$("#" + popup_id + "_content").show();
	$("#" + popup_id).show();
}

function add_slider(elements, target, source_element)
{
	var slide = new Fx.Slide($(target), {
		mode: 'vertical'
	});
	source_element.setProperty('onclick', '');
	source_element.addEvent('click', function ()
	{
		slide.toggle();
		return false;
	});
}

function handle_village_to_group_from_overview_mobile(data, target, source_element)
{
	display_village_to_groups_assigments(data, target, true, "handle_village_overview_reload_mobile");
}

function handle_village_overview_reload_mobile(data, target, form_id)
{
	show_assigned_groups(data, target);
	toggle_element(target);
}

function handle_group_list(data, target)
{
	$.cookie("group_popup_content_data", data);
	display_group_selection(data, target);
}

function handle_delete_response(data, target)
{
	toggle_group_select("show_group0");
	$('#' + target).remove();
}

function handle_group_membership(data, target, form_id)
{
	$(target).innerHTML = data;
}

function handle_reload_popups(popups, target)
{
	var popup_list = popups;
	if(!popup_list) return;
	show_ajax_inline_popup(popup_list.popup_id, popup_list.content_url, popup_list.content_existing, popup_list.target, popup_list.close_text, popup_list.x, popup_list.y, popup_list.width, popup_list.height, popup_list.global, popup_list.display_handler, popup_list.html_request);
};
var last_toggle_source = null,
	current_toggle_source = null;

function set_toggle_source(source)
{
	last_toggle_source = current_toggle_source;
	current_toggle_source = source;
}

function toggle_group_toggle(element_id)
{
	var slide = new Fx.Slide(element_id, {
		mode: 'vertical',
		onComplete: function ()
		{}
	});
	if(last_toggle_source == current_toggle_source)
	{
		slide.toggle();
	}
	else slide.slideIn();
}

function toggle_names(name)
{
	var elements = document.getElementsByName(name);
	for(var i = 0; i < elements.length; i++) if(elements[i].getStyle('display') != 'none')
	{
		elements[i].setStyle('display', 'none');
	}
	else elements[i].setStyle('display', 'block');
}

function showError(json_error, target)
{
	$("error_div").empty();
	var to_display = new Element("table", {
		'class': 'error'
	}),
		table_row = new Element('tr'),
		table_col = new Element('td', {
			html: json_error
		});
	table_col.inject(table_row).inject(to_display);
	to_display.inject($("error_div"));
}

function closePopup()
{
	$.cookie("global_popups", "");
	$.cookie("group_popup_content_data", "");
}

function selectVillage(id, group_id)
{
	closePopup();
	var href = window.location.href;
	if(href.search(/village=\w*/) != -1)
	{
		href = href.replace(/village=\w*/, 'village=' + id);
	}
	else href += '&village=' + id;
	href = href.replace(/action=\w*/, '');
	if(href.search(/group=\w*/) != -1)
	{
		href = href.replace(/group=\w*/, 'group=' + group_id);
	}
	else href += '&group=' + group_id;
	window.location.href = encodeURI(href);
}

function resize_popup(target)
{
	var popup_menu = target + "_menu";
	if($(popup_menu).getStyle("width") === null)
	{
		var width = $(target).getScrollSize().x;
		$(popup_menu).setStyle("width", width + "px");
	}
}
 

DeletedUser

de cand numai joc pe l15 m-am lasat de prelucrat scripturi si am uitat :|
 

ChineZeu

member
Scor reacție
37
dupa cateva zile cu fum prin cap cred ca am gasit problema
din pacate nu e una pe care pot sa o rezolv eu
e un bug din joc, in scriptul care genereaza css-ul pentru acel popup
se pare ca prin comanda jvscript insereaza cateva caractere in plus, pe cand in alberul dom e totul ok...

aici errorile:

.attr("style",
"position:relative;
z-index: 9999;
top:'" + y + "';
left:'" + x + "';
'" + width_css + "'
margin-top: -17px;"),

rezultatul ar fi asta:
"position:relative;
z-index: 9999;
top:'100px';
left:'100px';
max-height:95%;
margin-top: -17px;"
...un css pe care saracul meu browser nu poate sa il descifreze

syntaxa corecta ar trebui sa arate cam asa:
.style.position="relative";z-index: "9999";top:" + y + ";left:" + x + ";" + width_css + ";margin-top:"-17px";

in fine
mi-am permis sa inlocuesc acel popup cu un alt script
daca pentru satul in care e rulat scriptul nu este nici un plan de farmare sare pe urmatorul sat

in spoiler e pus scriptul cu toate modificarile mele (sper ca sunt legale) :)
Cod:
javascript: function o(a)
{
	b = location.search;
	c = new RegExp("\\b" + a + "\\b");
	if (b.match(c))
	{
		return 1;
	}
	else
	{
		location.search = b.replace(/.*?(\bvillage=\d+).*/i, '?$1&' + a);
		return 0;
	}
}
if (o('screen=place'))
{
	lancii = 0;
	spade = 0;
	arcasi = 0;
	topoare = 0;
	caiusori = 0;
	caiarcasi = 0;
	caigrei = 0;
	berbeci = 0;
	catapulte = 0;
	paladin = 0;
	nobil = 0;
	var doc = document;
	var v_id;
	twgameCookie = document.cookie.match('(^|;) ?global_village_id=([^;]*)(;|$)');
	v_id = parseInt(twgameCookie[2]);
	switch (v_id)
	{
	case 24680:
		lancii = 0;
		spade = 0;
		arcasi = 0;
		topoare = 0;
		caiusori = 0;
		caiarcasi = 0;
		caigrei = 0;
		berbeci = 0;
		catapulte = 0;
		paladin = 0;
		nobil = 0;
		coords = 'xxx|yyy xxx|yyy';
	case 67890:
		lancii = 0;
		spade = 0;
		arcasi = 0;
		topoare = 0;
		caiusori = 0;
		caiarcasi = 0;
		caigrei = 0;
		berbeci = 0;
		catapulte = 0;
		paladin = 0;
		nobil = 0;
		coords = 'xxx|yyy xxx|yyy';
	case 12345:
		lancii = 0;
		spade = 0;
		arcasi = 0;
		topoare = 0;
		caiusori = 0;
		caiarcasi = 0;
		caigrei = 0;
		berbeci = 0;
		catapulte = 0;
		paladin = 0;
		nobil = 0;
		coords = 'xxx|yyy xxx|yyy';
		break;
	default:
		alert('Pentru acest sat (' + v_id + ') nu sunt ținte prestabilite');
		var jucator = window.game_data.player.id;
		var loctiitor = window.location.href.match(/t\=\d+/i);
		window.location = "game.php?village=n" + window.game_data.village.id + "&screen=" + window.game_data.screen + "&t='search_for'" + jucator + (loctiitor ? ("&" + loctiitor) : "");
		exit;
	}
	if (window.frames.length > 0) doc = window.main.document;
	url = document.URL;
	if (url.indexOf('screen=place') == -1) alert('Acest script trebuie rulat din Piața centrală');
	coords = coords.split(" ");
	index = 0;
	farmcookie = document.cookie.match('(^|;) ?TWMentor=([^;]*)(;|$)');
	var newCookie = "";
	if (farmcookie != null)
	{
		farmStopLog = farmcookie[2].split("#");
		var x = 1;
		var found = -1;
		while (x < farmStopLog.length)
		{
			farmStopLogCase = farmStopLog[x - 1].split("@");
			if (v_id == farmStopLogCase[0])
			{
				found = 1;
				index = parseInt(farmStopLogCase[1]);
				if (index >= coords.length)
				{
					alert('Am ajuns la ultima țintă, reluam de la început');
					index = 0;
					index = parseInt(index);
				}
				coords = coords[index];
				coords = coords.split("|");
				index = index + 1;
				newCookie = newCookie + v_id + "@" + index + "#";
			}
			else
			{
				newCookie = newCookie + farmStopLogCase[0] + "@" + farmStopLogCase[1] + "#";
			}
			x++;
		}
		if (found != 1)
		{
			newCookie = newCookie + v_id + "@0#";
			index = 0;
			index = parseInt(index);
			coords = coords[index];
			coords = coords.split("|");
		}
	}
	else
	{
		newCookie = newCookie + v_id + "@1#";
		index = 1;
		index = parseInt(index);
		coords = coords[index];
		coords = coords.split("|");
	}
	cookie_date = new Date(2019, 11, 11);
	document.cookie = "TWMentor=" + newCookie + "; expires=" + cookie_date.toGMTString();
	doc.forms[0].x.value = coords[0];
	doc.forms[0].y.value = coords[1];
	insertUnit(doc.forms[0].spear, lancii);
	insertUnit(doc.forms[0].sword, spade);
	insertUnit(doc.forms[0].archer, arcasi);
	insertUnit(doc.forms[0].axe, topoare);
	insertUnit(doc.forms[0].spy, 1);
	insertUnit(doc.forms[0].light, caiusori);
	insertUnit(doc.forms[0].marcher, caiarcasi);
	insertUnit(doc.forms[0].heavy, caigrei);
	insertUnit(doc.forms[0].ram, berbeci);
	insertUnit(doc.forms[0].catapult, catapulte);
	insertUnit(doc.forms[0].knight, paladin);
	insertUnit(doc.forms[0].snob, nobil);
}

rog moderatorul sa inchida topicul...
si daca e posibil sa raporteze acest bug
 

ChineZeu

member
Scor reacție
37
nu, nu am renuntat
ma rog... nu e ca aici
aia sunt la inceputuri, tot la romani e baza cand vine vorba de scripturi
 
Sus