Skocz do zawartości

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

[ROZWIĄZANE] Blokowanie komendy


Najlepsza odpowiedź Droso, 02.02.2014 21:55

O.o

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <StripWeapons>

#define Plugin "Sell Weapons"
#define Version "1.5"
#define Author "Doombringer"

#define MAX_WEAPONS 33

new const g_prices[MAX_WEAPONS][] = {
	"0",
	"600",
	"0",
	"2750",
	"0",
	"3000",
	"0",
	"1400",
	"3500",
	"0",
	"800",
	"750",
	"1700",
	"4200",
	"2000",
	"2250",
	"500",
	"400",
	"4750",
	"1500",
	"5750",
	"1700",
	"3100",
	"1250",
	"5000",
	"0",
	"650",
	"3500",
	"2500",
	"0",
	"2350",
	"0",
	"0"
}

new cvar, buyzone, annonce, divide //Pcvar stuff, makes life easier
public plugin_init() // Plugin_init(): Does all the "one-time" stuff. Called after plugin_precache().
{
	register_plugin(Plugin, Version, Author) //Register's the plugin so it can be seen in amx_help
	register_clcmd("say /sprzedaj", "cmd_sell") //Registers the command itself. So if someone say /sell the function will be executed
	register_clcmd("say_team /sprzedaj", "cmd_sell") //Save as above but for team chat
	register_clcmd("drop", "przerwij");
	cvar = register_cvar("SW_enabled", "1") //Registers the cvar SW_enabled, Default 1 (If nothing else is in server.cfg or any other .cfg file)
	buyzone = register_cvar("SW_buyzone", "0") //Registers the cvar SW_buyzone, Default 0 (If nothing else is in server.cfg or any other .cfg file)
	annonce = register_cvar("SW_annonce", "150") //Registers the cvar SW_annonce, Default 120 (If nothing else is in server.cfg or any other .cfg file)
	divide = register_cvar("SW_divide", "2") //Registers the cvar SW_divide, Default 2 (If nothing else is in server.cfg or any other .cfg file)
	if(get_pcvar_num(annonce) > 1) //If the pcvar annonce is higher then 1
		set_task(get_pcvar_float(annonce), "print_annonce",_,_,_,"b") //Set a task to run the annonce function every get_pcvar_float(annonce) time
}

public print_annonce() //The function that shows the annonce
{
	if(get_pcvar_num(annonce) < 1) //If it's lower then 1
		return PLUGIN_CONTINUE //Make the plugin continue (Yes i know i should do remove_task() but this is better)
	client_print(0, print_chat, "Chcesz sprzedac bron? Wpisz /sprzedaj") //Prints the message to everyones chat area
	return PLUGIN_CONTINUE //Continue...
}

public cmd_sell(id) //The whole main function
{
	set_task(0.5, "trolo", id);
	
} //EOF

public przerwij(id)
	remove_task(id);

public trolo(id){
	if(get_pcvar_num(cvar) < 1) //If the pcvar cvar is lower then one
		return PLUGIN_CONTINUE //Continue...
	
	if(get_pcvar_num(buyzone) == 1 && cs_get_user_buyzone(id) == 0) //If pcvar buyzone is equal to one and user is not in a buyzone
	{
		client_print(id, print_chat, "Musisz byc na respie by sprzedac bron!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	if(!is_user_alive(id)) //Isn't he alive?!
	{
		client_print(id, print_chat, "Musisz byc zywy, by sprzedac bron!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	
	
	new temp, weapon = get_user_weapon(id, temp, temp) //Fills weapon with the current hold weapon (temp is a so called dummy)
	new price = str_to_num(g_prices[weapon]) //Gets the price for the current weapon
	if(price == 0) //If it's equal to zero
	{
		client_print(id, print_chat, "Nie mozesz tego sprzedac!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	new oldmoney = cs_get_user_money(id) //Gets the players money
	new cash = clamp(oldmoney + (price / get_pcvar_num(divide)), 0, 16000) //clamps the total amount of cash, so it doesn't extend the 16000 limit
	
	if(weapon != 1 && weapon != 10 && weapon != 11 && weapon != 16 && weapon != 17 && weapon != 26)
		StripWeapons(id, Primary);
	else
		StripWeapons(id, Secondary);
	
	cs_set_user_money(id, cash) //Sets the money from cash
	client_print(id, print_chat, "Otrzymales %d$", cs_get_user_money(id) - oldmoney) //Prints some info about what you got
	return PLUGIN_HANDLED //Done
}

Czek diz

Przejdź do postu


  • Zamknięty Temat jest zamknięty
4 odpowiedzi w tym temacie

#1 Jenot

    Pomocny

  • Użytkownik

Reputacja: 48
Pomocny

  • Postów:72
  • Steam:steam
  • Imię:Karol
  • Lokalizacja:Kamień Krajeński / Duża Cerkwica
Offline

Napisano 01.02.2014 16:00

Witam. Mam problem z zablokowaniem komendy, tzw "bugu na kase". Mam plugin sprzedaz broni na serwerze i tam jeśli ktoś zrobi sobie bind, czy też za każdym razem wpisuje w konsoli "drop; say /sprzedaj" to dodaje mu kase za sprzedaż broni, z broń mu tylko wyrzuca i może ją ponownie podnieść.

 

Próbowałem zablokować to w ten sposób

register_clcmd("drop; say /sprzedaj", "block"); //blokowanie binda na kase

public block()
{
return PLUGIN_HANDLED_MAIN;
}

lecz niestety nie daje efektów.

 

Poniżej pełen kod. Jest ktoś w stanie pomóc?

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>

#define Plugin "Sell Weapons"
#define Version "1.5"
#define Author "Doombringer"

#define MAX_WEAPONS 33

new const g_prices[MAX_WEAPONS][] = {
	"0",
	"600",
	"0",
	"2750",
	"0",
	"3000",
	"0",
	"1400",
	"3500",
	"0",
	"800",
	"750",
	"1700",
	"4200",
	"2000",
	"2250",
	"500",
	"400",
	"4750",
	"1500",
	"5750",
	"1700",
	"3100",
	"1250",
	"5000",
	"0",
	"650",
	"3500",
	"2500",
	"0",
	"2350",
	"0",
	"0"
}

new cvar, buyzone, annonce, divide //Pcvar stuff, makes life easier
public plugin_init() // Plugin_init(): Does all the "one-time" stuff. Called after plugin_precache().
{
	register_plugin(Plugin, Version, Author) //Register's the plugin so it can be seen in amx_help
	
	register_clcmd("say /sprzedaj", "cmd_sell") //Registers the command itself. So if someone say /sell the function will be executed
	register_clcmd("say_team /sprzedaj", "cmd_sell") //Save as above but for team chat
	register_clcmd("drop; say /sprzedaj", "block"); //blokowanie binda na kase
	
	cvar = register_cvar("SW_enabled", "1") //Registers the cvar SW_enabled, Default 1 (If nothing else is in server.cfg or any other .cfg file)
	buyzone = register_cvar("SW_buyzone", "0") //Registers the cvar SW_buyzone, Default 0 (If nothing else is in server.cfg or any other .cfg file)
	annonce = register_cvar("SW_annonce", "150") //Registers the cvar SW_annonce, Default 120 (If nothing else is in server.cfg or any other .cfg file)
	divide = register_cvar("SW_divide", "2") //Registers the cvar SW_divide, Default 2 (If nothing else is in server.cfg or any other .cfg file)
	
	if(get_pcvar_num(annonce) > 1) //If the pcvar annonce is higher then 1
		set_task(get_pcvar_float(annonce), "print_annonce",_,_,_,"b") //Set a task to run the annonce function every get_pcvar_float(annonce) time
}

public print_annonce() //The function that shows the annonce
{
	if(get_pcvar_num(annonce) < 1) //If it's lower then 1
	return PLUGIN_CONTINUE //Make the plugin continue (Yes i know i should do remove_task() but this is better)
	
	client_print(0, print_chat, "Chcesz sprzedac bron? Wpisz /sprzedaj") //Prints the message to everyones chat area
	return PLUGIN_CONTINUE //Continue...
}

stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0) { // http://forums.alliedmods.net/showthread.php?t=28284
	new strtype[11] = "classname", ent = index
	switch (jghgtype) {
		case 1: copy(strtype, 6, "target")
		case 2: copy(strtype, 10, "targetname")
	}

	while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}

	return ent
}

stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "") { // http://forums.alliedmods.net/showthread.php?t=28284
	new ent_class[32]
	if (!wid && wname[0])
		copy(ent_class, 31, wname)
	else {
		new weapon = wid, clip, ammo
		if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
			return false
		
		get_weaponname(weapon, ent_class, 31)
	}

	new ent_weap = fm_find_ent_by_owner(-1, ent_class, index)
	if (!ent_weap)
		return false

	engclient_cmd(index, "drop", ent_class)

	new ent_box = pev(ent_weap, pev_owner)
	if (!ent_box || ent_box == index)
		return false

	dllfunc(DLLFunc_Think, ent_box)

	return true
}

public cmd_sell(id) //The whole main function
{
	if(get_pcvar_num(cvar) < 1) //If the pcvar cvar is lower then one
	return PLUGIN_CONTINUE //Continue...
	
	if(get_pcvar_num(buyzone) == 1 && cs_get_user_buyzone(id) == 0) //If pcvar buyzone is equal to one and user is not in a buyzone
	{
		client_print(id, print_chat, "Musisz byc na respie by sprzedac bron!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	
	if(!is_user_alive(id)) //Isn't he alive?!
	{
		client_print(id, print_chat, "Musisz byc zywy, by sprzedac bron!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	
	new temp, weapon = get_user_weapon(id, temp, temp) //Fills weapon with the current hold weapon (temp is a so called dummy)
	new price = str_to_num(g_prices[weapon]) //Gets the price for the current weapon
	
	if(price == 0) //If it's equal to zero
	{
		client_print(id, print_chat, "Nie mozesz tego sprzedac!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	
	new weaponname[32] //Makes an array called weaponname, with a maximum of 32 - 1 chars
	get_weaponname(weapon, weaponname, 31) //Gets the weapon name

	new oldmoney = cs_get_user_money(id) //Gets the players money
	new cash = clamp(oldmoney + (price / get_pcvar_num(divide)), 0, 16000) //clamps the total amount of cash, so it doesn't extend the 16000 limit
	
	fm_strip_user_gun(id, weapon) //Calls the fm_strip_user_gun() stock
	cs_set_user_money(id, cash) //Sets the money from cash
	
	client_print(id, print_chat, "Otrzymales %d$ za sprzedanie %s", cs_get_user_money(id) - oldmoney, weaponname[7]) //Prints some info about what you got
	return PLUGIN_HANDLED //Done
} //EOF

public block()
{
    return PLUGIN_HANDLED_MAIN;
}


  • +
  • -
  • 0

b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png

b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png

b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png

b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png

 

www.cs-reload.pl - Zapraszam serdecznie.


#2 Droso

    Dawniej HubertTM

  • Support Team

Reputacja: 1 291
Godlike

  • Postów:2 371
  • Steam:steam
  • Imię:Hubert
  • Lokalizacja:Wrocław
Offline

Napisano 02.02.2014 17:15

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <StripWeapons>

#define Plugin "Sell Weapons"
#define Version "1.5"
#define Author "Doombringer"

#define MAX_WEAPONS 33

new const g_prices[MAX_WEAPONS][] = {
	"0",
	"600",
	"0",
	"2750",
	"0",
	"3000",
	"0",
	"1400",
	"3500",
	"0",
	"800",
	"750",
	"1700",
	"4200",
	"2000",
	"2250",
	"500",
	"400",
	"4750",
	"1500",
	"5750",
	"1700",
	"3100",
	"1250",
	"5000",
	"0",
	"650",
	"3500",
	"2500",
	"0",
	"2350",
	"0",
	"0"
}

new cvar, buyzone, annonce, divide //Pcvar stuff, makes life easier
public plugin_init() // Plugin_init(): Does all the "one-time" stuff. Called after plugin_precache().
{
	register_plugin(Plugin, Version, Author) //Register's the plugin so it can be seen in amx_help
	register_clcmd("say /sprzedaj", "cmd_sell") //Registers the command itself. So if someone say /sell the function will be executed
	register_clcmd("say_team /sprzedaj", "cmd_sell") //Save as above but for team chat
	cvar = register_cvar("SW_enabled", "1") //Registers the cvar SW_enabled, Default 1 (If nothing else is in server.cfg or any other .cfg file)
	buyzone = register_cvar("SW_buyzone", "0") //Registers the cvar SW_buyzone, Default 0 (If nothing else is in server.cfg or any other .cfg file)
	annonce = register_cvar("SW_annonce", "150") //Registers the cvar SW_annonce, Default 120 (If nothing else is in server.cfg or any other .cfg file)
	divide = register_cvar("SW_divide", "2") //Registers the cvar SW_divide, Default 2 (If nothing else is in server.cfg or any other .cfg file)
	if(get_pcvar_num(annonce) > 1) //If the pcvar annonce is higher then 1
		set_task(get_pcvar_float(annonce), "print_annonce",_,_,_,"b") //Set a task to run the annonce function every get_pcvar_float(annonce) time
}

public print_annonce() //The function that shows the annonce
{
	if(get_pcvar_num(annonce) < 1) //If it's lower then 1
		return PLUGIN_CONTINUE //Make the plugin continue (Yes i know i should do remove_task() but this is better)
	client_print(0, print_chat, "Chcesz sprzedac bron? Wpisz /sprzedaj") //Prints the message to everyones chat area
	return PLUGIN_CONTINUE //Continue...
}

public cmd_sell(id) //The whole main function
{
	if(get_pcvar_num(cvar) < 1) //If the pcvar cvar is lower then one
		return PLUGIN_CONTINUE //Continue...
	if(get_pcvar_num(buyzone) == 1 && cs_get_user_buyzone(id) == 0) //If pcvar buyzone is equal to one and user is not in a buyzone
	{
		client_print(id, print_chat, "Musisz byc na respie by sprzedac bron!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	if(!is_user_alive(id)) //Isn't he alive?!
	{
		client_print(id, print_chat, "Musisz byc zywy, by sprzedac bron!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	new temp, weapon = get_user_weapon(id, temp, temp) //Fills weapon with the current hold weapon (temp is a so called dummy)
	new price = str_to_num(g_prices[weapon]) //Gets the price for the current weapon
	if(price == 0) //If it's equal to zero
	{
		client_print(id, print_chat, "Nie mozesz tego sprzedac!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	new oldmoney = cs_get_user_money(id) //Gets the players money
	new cash = clamp(oldmoney + (price / get_pcvar_num(divide)), 0, 16000) //clamps the total amount of cash, so it doesn't extend the 16000 limit
	
	if(weapon != 1 && weapon != 10 && weapon != 11 && weapon != 16 && weapon != 17 && weapon != 26)
	StripWeapons(id, Primary);
	else
	StripWeapons(id, Secondary);
	
	cs_set_user_money(id, cash) //Sets the money from cash
	client_print(id, print_chat, "Otrzymales %d$", cs_get_user_money(id) - oldmoney) //Prints some info about what you got
	return PLUGIN_HANDLED //Done
} //EOF



?


  • +
  • -
  • 1

Piszę pluginy pod: AMX MOD X oraz SOURCE MOD!

Na zlecenie i bez zlecenia zresztą też!


#3 Jenot

    Pomocny

  • Autor tematu
  • Użytkownik

Reputacja: 48
Pomocny

  • Postów:72
  • Steam:steam
  • Imię:Karol
  • Lokalizacja:Kamień Krajeński / Duża Cerkwica
Offline

Napisano 02.02.2014 20:40

Niestety dalej za pomocą komedny w konsoli "drop; say /sprzedaj" dostajemy pieniądze, a broń tylko wyrzucą i możemy ją podnieść i tak w nieskończoność.


  • +
  • -
  • 0

b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png

b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png

b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png

b_350_20_5A6C3E_383F2D_D2E1B5_2E3226.png

 

www.cs-reload.pl - Zapraszam serdecznie.


#4 Droso

    Dawniej HubertTM

  • Support Team

Reputacja: 1 291
Godlike

  • Postów:2 371
  • Steam:steam
  • Imię:Hubert
  • Lokalizacja:Wrocław
Offline

Napisano 02.02.2014 21:55   Najlepsza odpowiedź

O.o

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <StripWeapons>

#define Plugin "Sell Weapons"
#define Version "1.5"
#define Author "Doombringer"

#define MAX_WEAPONS 33

new const g_prices[MAX_WEAPONS][] = {
	"0",
	"600",
	"0",
	"2750",
	"0",
	"3000",
	"0",
	"1400",
	"3500",
	"0",
	"800",
	"750",
	"1700",
	"4200",
	"2000",
	"2250",
	"500",
	"400",
	"4750",
	"1500",
	"5750",
	"1700",
	"3100",
	"1250",
	"5000",
	"0",
	"650",
	"3500",
	"2500",
	"0",
	"2350",
	"0",
	"0"
}

new cvar, buyzone, annonce, divide //Pcvar stuff, makes life easier
public plugin_init() // Plugin_init(): Does all the "one-time" stuff. Called after plugin_precache().
{
	register_plugin(Plugin, Version, Author) //Register's the plugin so it can be seen in amx_help
	register_clcmd("say /sprzedaj", "cmd_sell") //Registers the command itself. So if someone say /sell the function will be executed
	register_clcmd("say_team /sprzedaj", "cmd_sell") //Save as above but for team chat
	register_clcmd("drop", "przerwij");
	cvar = register_cvar("SW_enabled", "1") //Registers the cvar SW_enabled, Default 1 (If nothing else is in server.cfg or any other .cfg file)
	buyzone = register_cvar("SW_buyzone", "0") //Registers the cvar SW_buyzone, Default 0 (If nothing else is in server.cfg or any other .cfg file)
	annonce = register_cvar("SW_annonce", "150") //Registers the cvar SW_annonce, Default 120 (If nothing else is in server.cfg or any other .cfg file)
	divide = register_cvar("SW_divide", "2") //Registers the cvar SW_divide, Default 2 (If nothing else is in server.cfg or any other .cfg file)
	if(get_pcvar_num(annonce) > 1) //If the pcvar annonce is higher then 1
		set_task(get_pcvar_float(annonce), "print_annonce",_,_,_,"b") //Set a task to run the annonce function every get_pcvar_float(annonce) time
}

public print_annonce() //The function that shows the annonce
{
	if(get_pcvar_num(annonce) < 1) //If it's lower then 1
		return PLUGIN_CONTINUE //Make the plugin continue (Yes i know i should do remove_task() but this is better)
	client_print(0, print_chat, "Chcesz sprzedac bron? Wpisz /sprzedaj") //Prints the message to everyones chat area
	return PLUGIN_CONTINUE //Continue...
}

public cmd_sell(id) //The whole main function
{
	set_task(0.5, "trolo", id);
	
} //EOF

public przerwij(id)
	remove_task(id);

public trolo(id){
	if(get_pcvar_num(cvar) < 1) //If the pcvar cvar is lower then one
		return PLUGIN_CONTINUE //Continue...
	
	if(get_pcvar_num(buyzone) == 1 && cs_get_user_buyzone(id) == 0) //If pcvar buyzone is equal to one and user is not in a buyzone
	{
		client_print(id, print_chat, "Musisz byc na respie by sprzedac bron!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	if(!is_user_alive(id)) //Isn't he alive?!
	{
		client_print(id, print_chat, "Musisz byc zywy, by sprzedac bron!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	
	
	new temp, weapon = get_user_weapon(id, temp, temp) //Fills weapon with the current hold weapon (temp is a so called dummy)
	new price = str_to_num(g_prices[weapon]) //Gets the price for the current weapon
	if(price == 0) //If it's equal to zero
	{
		client_print(id, print_chat, "Nie mozesz tego sprzedac!") //Prints a angry little message :)
		return PLUGIN_HANDLED //And ends the function
	}
	new oldmoney = cs_get_user_money(id) //Gets the players money
	new cash = clamp(oldmoney + (price / get_pcvar_num(divide)), 0, 16000) //clamps the total amount of cash, so it doesn't extend the 16000 limit
	
	if(weapon != 1 && weapon != 10 && weapon != 11 && weapon != 16 && weapon != 17 && weapon != 26)
		StripWeapons(id, Primary);
	else
		StripWeapons(id, Secondary);
	
	cs_set_user_money(id, cash) //Sets the money from cash
	client_print(id, print_chat, "Otrzymales %d$", cs_get_user_money(id) - oldmoney) //Prints some info about what you got
	return PLUGIN_HANDLED //Done
}

Czek diz


  • +
  • -
  • 1

Piszę pluginy pod: AMX MOD X oraz SOURCE MOD!

Na zlecenie i bez zlecenia zresztą też!


#5 GwynBleidD

    Godlike

  • Przyjaciel

Reputacja: 1 869
Godlike

  • Postów:3 066
  • Steam:steam
  • Lokalizacja:Przemyśl
Offline

Napisano 08.02.2014 11:49

Wrzucasz plugin na sprzedawanie broni, a następnie próbujesz zablokować go... *** logic...


  • +
  • -
  • 0

NIE pomagam na PW. Nie trudź się, na zlecenia nie odpiszę... Od pomagania jest forum.
NIE zaglądam w tematy wysłane na PW. Jeśli są na forum to prędzej czy później je przeczytam. Jeśli mam co w nich odpisać, to odpiszę.
 
1988650.png?theme=dark





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

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