Skocz do zawartości

  • Zaloguj korzystając z Facebooka Zaloguj korzystając z Twittera Zaloguj przez Steam Zaloguj poprzez Google      Logowanie »   
  • Rejestracja

Witamy w Nieoficjalnym polskim support'cie AMX Mod X

Witamy w Nieoficjalnym polskim support'cie AMX Mod X, jak w większości społeczności internetowych musisz się zarejestrować aby móc odpowiadać lub zakładać nowe tematy, ale nie bój się to jest prosty proces w którym wymagamy minimalnych informacji.

  • Rozpoczynaj nowe tematy i odpowiedaj na inne
  • Zapisz się do tematów i for, aby otrzymywać automatyczne uaktualnienia
  • Dodawaj wydarzenia do kalendarza społecznościowego
  • Stwórz swój własny profil i zdobywaj nowych znajomych
  • Zdobywaj nowe doświadczenia

Dołączona grafika Dołączona grafika

Guest Message by DevFuse
 

Zdjęcie

Dziwny błąd przy edycji pluginu


  • Nie możesz napisać tematu
  • Zaloguj się, aby dodać odpowiedź
2 odpowiedzi w tym temacie

#1 Gasior

    Zaawansowany

  • Użytkownik

Reputacja: 9
Nowy

  • Postów:105
  • Imię:Maciek
  • Lokalizacja:Lublin
Offline

Napisano 25.03.2012 14:21

Witam,
Edytowałem plugin poly_rtv, żeby w przypadku rozpoczęcia głosowania ustawiał czas mapy na 4 minuty. Przy kompilacji obyło się bez błędów, jednak na serwerze po wpisaniu rtv mapa zmieniła się od razu, a na następnej mapie cały czas pojawiał się komunikat z pojedynku na noże.

Tutaj kod do sma
/*<br>*&nbsp;&nbsp;&nbsp;&nbsp;RockTheVote for Polymorph<br>*&nbsp;&nbsp;&nbsp;&nbsp;Requires Polymorph v0.8.2 or later<br>*<br>*/<br><br>#include &lt;amxmodx&gt;<br>#include &lt;amxmisc&gt;<br>// #include &lt;polymorph&gt;<br><br>native polyn_votemod()<br><br>new bool:g_rockedVote[33], g_rockedVoteCnt<br>new bool:g_hasbeenrocked = false<br><br>// Cvars<br>new cvar_rtv_enabled<br>new cvar_rtv_ratio<br>new cvar_rtv_wait<br>new cvar_rtv_show<br><br>public plugin_init()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;register_plugin("Polymorph: RockTheVote", "1.0", "Fysiks")<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;register_clcmd("amx_rtv","cmdAdminRTV", ADMIN_MAP, " Manually RockTheVote")<br>&nbsp;&nbsp;&nbsp;&nbsp;register_clcmd("admin_rtv","cmdAdminRTV", ADMIN_MAP, " Manually RockTheVote")<br>&nbsp;&nbsp;&nbsp;&nbsp;register_clcmd("say rtv", "cmdSayRTV")<br>&nbsp;&nbsp;&nbsp;&nbsp;register_clcmd("say rockthevote", "cmdSayRTV")<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;// Cvars<br>&nbsp;&nbsp;&nbsp;&nbsp;cvar_rtv_enabled = register_cvar("rtv_enable", "1")&nbsp;&nbsp;&nbsp;&nbsp;// &lt;0|1&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;cvar_rtv_ratio = register_cvar("rtv_ratio", "0.51")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Use amx_votemap_ratio?<br>&nbsp;&nbsp;&nbsp;&nbsp;cvar_rtv_wait = register_cvar("rtv_wait", "1")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Minutes after mapstart you can rtv<br>&nbsp;&nbsp;&nbsp;&nbsp;cvar_rtv_show = register_cvar("rtv_show", "1")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Display how many more votes needed to rtv<br>}<br><br>public cmdAdminRTV(id, level, cid)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;if(!cmd_access(id,level,cid,1))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return PLUGIN_HANDLED<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if(g_hasbeenrocked)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(id,print_console,"[RTV] Vote has already been rocked")<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_hasbeenrocked = true<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new admin_name[32]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;get_user_name(id, admin_name, 31)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;show_activity(id, admin_name, "has RockedTheVote")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(id,print_console, "[RTV] You have RockedTheVote")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set_task(3.5,"announce_vote")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set_task(5.0,"startRockVote")<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;// Add functionality to cancel rocked vote.<br>&nbsp;&nbsp;&nbsp;&nbsp;return PLUGIN_HANDLED<br>}<br><br>public client_connect(id)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;g_rockedVote[id] = false<br>}<br><br>public client_disconnect(id)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;if(g_rockedVote[id])<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_rockedVote[id] = false<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_rockedVoteCnt--<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>public cmdSayRTV(id)<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;if(!get_pcvar_num(cvar_rtv_enabled))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return PLUGIN_CONTINUE // PLUGIN_HANDLED<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if(g_hasbeenrocked)<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(id, print_chat, "[RTV] Vote has already been Rocked.")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return PLUGIN_HANDLED<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if(g_rockedVote[id])<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(id, print_chat, "[RTV] You already voted.")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rtv_remind()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return PLUGIN_CONTINUE&nbsp;&nbsp;// PLUGIN_HANDLED for blind?<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;new Float:vote_wait = get_pcvar_float(cvar_rtv_wait)<br>&nbsp;&nbsp;&nbsp;&nbsp;new Float:time_elapsed = get_cvar_float("mp_timelimit") - (float( get_timeleft() ) / 60.0) // Use get_gametime<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if( time_elapsed &lt; vote_wait )<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// Can replace all this content with "You cannot RockTheVote yet."<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;// which would require no if statement or calculations.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new Float:time_til_votebegin =&nbsp;&nbsp;vote_wait - time_elapsed<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if(time_til_votebegin &gt; 1.0)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new min_to_vote = clamp(floatround(time_til_votebegin),1,floatround(vote_wait))<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(id, print_chat, "[RTV] You cannot RockTheVote for %d more minute%s.", min_to_vote, min_to_vote &gt; 1 ? "s" : "" )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else // time_til_votebegin &lt;= 1 minute<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(id, print_chat, "[RTV] You cannot RockTheVote for %d more seconds.", floatround(time_til_votebegin * 60) )<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return PLUGIN_HANDLED<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if(get_timeleft() &lt; 240 ) // don't allow rtv 4 minutes before map ends<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(id, print_chat, "[RTV] Too Late to RockTheVote.")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return PLUGIN_HANDLED<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;// You (id) just voted to rock.<br>&nbsp;&nbsp;&nbsp;&nbsp;g_rockedVote[id] = true<br>&nbsp;&nbsp;&nbsp;&nbsp;g_rockedVoteCnt++<br>&nbsp;&nbsp;&nbsp;&nbsp;client_print(id,print_chat, "[RTV] You chose to RockTheVote")<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;if( g_rockedVoteCnt &gt;= get_RocksNeeded() )&nbsp;&nbsp;&nbsp;&nbsp; // Decide if we rock the vote<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;g_hasbeenrocked = true<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(0,print_chat, "[RTV] The Vote has been Rocked!")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;server_cmd("mp_timelimit 4") // jedyna komenda dopisana przezemnie<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set_task(3.5,"announce_vote")<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;set_task(5.0,"startRockVote")<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;{<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rtv_remind()<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;return PLUGIN_CONTINUE<br>}<br><br>public startRockVote()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;polyn_votemod()<br>}<br><br>get_RocksNeeded()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;return floatround(get_pcvar_float(cvar_rtv_ratio) * float(get_realplayersnum()), floatround_ceil);<br>}<br><br>stock get_realplayersnum()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;new players[32], playerCnt;<br>&nbsp;&nbsp;&nbsp;&nbsp;get_players(players, playerCnt, "ch");<br>&nbsp;&nbsp;&nbsp;&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;return playerCnt;<br>}<br><br>rtv_remind()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;if(get_pcvar_num(cvar_rtv_show))<br>&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;&nbsp;// Not tested yet.<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;client_print(0,print_chat, "[RTV] Need %d more players to RockTheVote.", get_RocksNeeded() - g_rockedVoteCnt)<br>&nbsp;&nbsp;&nbsp;&nbsp;}<br>}<br><br>public announce_vote()<br>{<br>&nbsp;&nbsp;&nbsp;&nbsp;client_cmd(0, "spk buttons/blip2")&nbsp;&nbsp;// Moved here from startRockVote to give heads up<br>}


Co może powodować takie błędy ?

Użytkownik Gasior edytował ten post 25.03.2012 14:22

  • +
  • -
  • 0

#2 CheQ

    Nie wiem, nie znam się, nie orientuję się, zarobiony jestem.

  • Junior Admin

Reputacja: 1984
Godlike

  • Postów:5534
  • Imię:Adaś
  • Lokalizacja:Glinianka
Offline

Napisano 25.03.2012 15:27

daj sma w [ code ] a nie w [s m a]
  • +
  • -
  • 0

b_560_95_1.png


#3 Gasior

    Zaawansowany

  • Autor tematu
  • Użytkownik

Reputacja: 9
Nowy

  • Postów:105
  • Imię:Maciek
  • Lokalizacja:Lublin
Offline

Napisano 25.03.2012 16:10

Tylko, żebym za to znowu warna nie wyłapał.
Już naprawiłem ten błąd, tylko jest teraz taki czysto kosmetyczny. Gdy x osób wpisze rtv i zaczyna się głosowanie to czas ustawia się na 240 minut. No niby spełnia to swoją rolę i po vote jest normalnie zmiana bez czekania tych 240 minut, ale chciałbym aby pisało 4 minuty, a nie 240.
Troche nagmatwałem... Chodzi o to że jak ustawie server_cmd("mp_timelimit 240") to timeleft jest 240 minut, a jak ustawie server_cmd("mp_timelimit 4") to czas jest na 4 sekundy... Co to się dzieje ?
/*
*	RockTheVote for Polymorph
*	Requires Polymorph v0.8.2 or later
*
*/

#include <amxmodx>
#include <amxmisc>
// #include <polymorph>

native polyn_votemod()

new bool:g_rockedVote[33], g_rockedVoteCnt
new bool:g_hasbeenrocked = false

// Cvars
new cvar_rtv_enabled
new cvar_rtv_ratio
new cvar_rtv_wait
new cvar_rtv_show

public plugin_init()
{
	register_plugin("Polymorph: RockTheVote", "1.0", "Fysiks")
	
	register_clcmd("amx_rtv","cmdAdminRTV", ADMIN_MAP, " Manually RockTheVote")
	register_clcmd("admin_rtv","cmdAdminRTV", ADMIN_MAP, " Manually RockTheVote")
	register_clcmd("say rtv", "cmdSayRTV")
	register_clcmd("say rockthevote", "cmdSayRTV")
	
	// Cvars
	cvar_rtv_enabled = register_cvar("rtv_enable", "1")	// <0|1>
	cvar_rtv_ratio = register_cvar("rtv_ratio", "0.51")		// Use amx_votemap_ratio?
	cvar_rtv_wait = register_cvar("rtv_wait", "1")			// Minutes after mapstart you can rtv
	cvar_rtv_show = register_cvar("rtv_show", "1")		// Display how many more votes needed to rtv
}

public cmdAdminRTV(id, level, cid)
{
	if(!cmd_access(id,level,cid,1))
		return PLUGIN_HANDLED
	
	if(g_hasbeenrocked)
	{
		client_print(id,print_console,"[RTV] Vote has already been rocked")
	}
	else
	{
		g_hasbeenrocked = true
		new admin_name[32]
		get_user_name(id, admin_name, 31)
		show_activity(id, admin_name, "has RockedTheVote")
		client_print(id,print_console, "[RTV] You have RockedTheVote")
		set_task(3.5,"announce_vote")
		set_task(5.0,"startRockVote")
	}
	// Add functionality to cancel rocked vote.
	return PLUGIN_HANDLED
}

public client_connect(id)
{
	g_rockedVote[id] = false
}

public client_disconnect(id)
{
	if(g_rockedVote[id])
	{
		g_rockedVote[id] = false
		g_rockedVoteCnt--
	}
}

public cmdSayRTV(id)
{
	if(!get_pcvar_num(cvar_rtv_enabled))
		return PLUGIN_CONTINUE // PLUGIN_HANDLED
	
	if(g_hasbeenrocked)
	{
		client_print(id, print_chat, "[RTV] Vote has already been Rocked.")
		return PLUGIN_HANDLED
	}
	
	if(g_rockedVote[id])
	{
		client_print(id, print_chat, "[RTV] You already voted.")
		rtv_remind()
		return PLUGIN_CONTINUE  // PLUGIN_HANDLED for blind?
	}
	
	new Float:vote_wait = get_pcvar_float(cvar_rtv_wait)
	new Float:time_elapsed = get_cvar_float("mp_timelimit") - (float( get_timeleft() ) / 60.0) // Use get_gametime
	
	if( time_elapsed < vote_wait )
	{
		// Can replace all this content with "You cannot RockTheVote yet."
		// which would require no if statement or calculations.
		
		new Float:time_til_votebegin =  vote_wait - time_elapsed
		if(time_til_votebegin > 1.0)
		{
			new min_to_vote = clamp(floatround(time_til_votebegin),1,floatround(vote_wait))
			client_print(id, print_chat, "[RTV] You cannot RockTheVote for %d more minute%s.", min_to_vote, min_to_vote > 1 ? "s" : "" )
		}
		else // time_til_votebegin <= 1 minute
		{
			client_print(id, print_chat, "[RTV] You cannot RockTheVote for %d more seconds.", floatround(time_til_votebegin * 60) )
		}
		
		return PLUGIN_HANDLED
	}
	
	if(get_timeleft() < 240 ) // don't allow rtv 4 minutes before map ends
	{
		client_print(id, print_chat, "[RTV] Too Late to RockTheVote.")
		return PLUGIN_HANDLED
	}
	
	// You (id) just voted to rock.
	g_rockedVote[id] = true
	g_rockedVoteCnt++
	client_print(id,print_chat, "[RTV] You chose to RockTheVote")
	
	if( g_rockedVoteCnt >= get_RocksNeeded() )	 // Decide if we rock the vote
	{
		g_hasbeenrocked = true
		client_print(0,print_chat, "[RTV] The Vote has been Rocked!")
	    server_cmd("mp_timelimit 240")
		set_task(3.5,"announce_vote")
		set_task(5.0,"startRockVote")
	}
	else
	{
		rtv_remind()
	}
	
	return PLUGIN_CONTINUE
}

public startRockVote()
{
	polyn_votemod()
}

get_RocksNeeded()
{
	return floatround(get_pcvar_float(cvar_rtv_ratio) * float(get_realplayersnum()), floatround_ceil);
}

stock get_realplayersnum()
{
	new players[32], playerCnt;
	get_players(players, playerCnt, "ch");
	
	return playerCnt;
}

rtv_remind()
{
	if(get_pcvar_num(cvar_rtv_show))
	{  // Not tested yet.
		client_print(0,print_chat, "[RTV] Need %d more players to RockTheVote.", get_RocksNeeded() - g_rockedVoteCnt)
	}
}

public announce_vote()
{
	client_cmd(0, "spk buttons/blip2")  // Moved here from startRockVote to give heads up
}

Użytkownik Gasior edytował ten post 25.03.2012 16:14

  • +
  • -
  • 0




Użytkownicy przeglądający ten temat: 0

0 użytkowników, 0 gości, 0 anonimowych