CSO SHOP V0.2 (BETA) - UPDATE (MUTAT PE NATIVE!)

Pluginuri pentru modul AmxModX.

Moderators: Moderatori ajutatori, Moderatori

User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2440
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 36 times
Been thanked: 372 times
Contact:

29 Jan 2019, 19:11

LondoN eXtream wrote:
cso_Shop.sma | Afiseaza codul
#include < amxmodx >
#include < amxmisc >
#include < cstrike >

// Declarand o constanta cu tag-ul e doar o pierdere de memorie
#define CHAT_TAG	"^x04[CSDM NEW]^x01"

// Declaram nativele
native give_dualuzi ( Player );
native give_dartpistol ( Player );
native give_ethereal ( Player );
native give_thanatos ( Player );
native give_spear ( Player );
native give_lightsaber ( Player );
native give_thunderbolt ( Player );

public plugin_init ( )
{
	register_plugin ( "CSO Shop", "0.2", "dragonCSX" );
	register_clcmd ( "say", "PlayerMenu" );
	register_clcmd ( "say_team", "PlayerMenu" );
}

public PlayerMenu ( Player )
{
	new szArg [ 32 ];
	read_args ( szArg, charsmax ( szArg ) );
	remove_quotes ( szArg );

	if ( containi ( szArg, "/shop" ) != -1 || equal ( szArg, "/shop" ) && is_user_alive ( Player ) )
		ShowPlayerWeapons ( Player );

	return szArg [ 0 ] == '/' ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
}

public ShowPlayerWeapons ( Player )
{
	new szName [ 32 ], szTitle [ 128 ];
	get_user_name ( Player, szName, charsmax ( szName ) );
	formatex ( szTitle, charsmax ( szTitle ), "\w[\rCSO NST\w] Magazin Arme \rCSO^n\wBun venit [\r%s\w]", szName );

	new MenuID = menu_create ( szTitle, "MenuHandler" );

	menu_additem ( MenuID, "\wLightsaber \r[800$]" );
	menu_additem ( MenuID, "\wDart Pistol \r[1500$]" );
	menu_additem ( MenuID, "\wThanatos-11 \r[4500$]" );
	menu_additem ( MenuID, "\wEhereal Gun \r[6500$]" );
	menu_additem ( MenuID, "\wDual Uzi \r[8500$]" );
	menu_additem ( MenuID, "\wSpear Gun \r[12500$]" );
	menu_additem ( MenuID, "\wThunderbolt \r[16000$]" );

	menu_setprop ( MenuID, MPROP_EXITNAME, "\wIesire" );
	menu_setprop ( MenuID, MPROP_EXIT, MEXIT_ALL );
	menu_display ( Player, MenuID, 0 );
}

public MenuHandler ( Player, MenuID, ITEM )
{
	if ( !( ITEM == MENU_EXIT ) )
	{
		static Money;	Money = cs_get_user_money ( Player );

		switch ( ITEM )
		{
			case 0:		
			{
				if ( Money < 800 )
					ErrorShow ( Player, 800 );

				cs_set_user_money ( Player, Money - 800 );
				give_lightsaber ( Player );
				chat_color ( Player, "Ai cumparat^x04 Light Saber" );
			}

			case 1:
			{
				if ( Money < 2500 )
					ErrorShow ( Player, 2500 );

				cs_set_user_money ( Player, Money - 2500 );
				give_dartpistol ( Player );
				chat_color ( Player, "Ai cumparat^x04 Dart Pistol" );
			}

			case 2:
			{
				if ( Money < 4500 )
					ErrorShow ( Player, 4500 );
			
				cs_set_user_money ( Player, Money - 4500 );
				give_thanatos ( Player );
				chat_color ( Player, "Ai cumparat^x04 Thanatos-11" );
			}

			case 3:
			{
				if ( Money < 6500 )
					ErrorShow ( Player, 6500 );	
				
				cs_set_user_money ( Player, Money - 6500 );
				give_ethereal ( Player );
				chat_color ( Player, "Ai cumparat^x04 Ethereal" );
			}

			case 4:
			{
				if ( Money < 8500 )
					ErrorShow ( Player, 8500 );

				cs_set_user_money ( Player, Money - 8500 );
				give_dualuzi ( Player );
				chat_color ( Player, "Ai cumparat^x04 Dual U.Z.I" );
			}

			case 5:
			{
				if ( Money < 12500 )
					ErrorShow ( Player, 12500 );

				cs_set_user_money ( Player, Money - 12500 );
				give_spear ( Player );
				chat_color ( Player, "Ai cumparat^x04 Spear Gun" );
			}

			case 6:
			{
				if ( Money < 16000 )
					ErrorShow ( Player, 16000 );

				cs_set_user_money ( Player, Money - 16000 );
				give_thunderbolt ( Player );
				chat_color ( Player, "Ai cumparat^x04 Thunder Bolt" );
			}
		}
	}

	menu_destroy ( MenuID );
	return PLUGIN_HANDLED;
}

public ErrorShow ( Player, Money )
{
	chat_color ( Player, "Ai nevoie de^x04 %d $^x01 pentru a cumpara acest item", Money );
	return PLUGIN_HANDLED;
}

stock chat_color ( const Player, const Text [ ], any:... )
{
	static Message [ 191 ];
	new Players [ 32 ], Count = 1;
	vformat ( Message, charsmax ( Message ), Text, 3 );

	formatex ( Message, charsmax ( Message ), "%s %s", CHAT_TAG, Message );

	static SayText;

	if ( !SayText )
		SayText = get_user_msgid ( "SayText" );

	if ( Player )	Players [ 0 ] = Player; else get_players ( Players, Count, "ch" )
	{
		for ( new i = 0; i < Count; i++ )
		{
			if ( !is_user_connected ( Players [ i ] ) )
				continue;
			
			message_begin ( MSG_ONE_UNRELIABLE, SayText, _, Players [ i ] );
			write_byte ( Players [ i ] );
			write_string ( Message );
			message_end ( );
		}
	}
}
Optimizat. Cu placere
nu mai știu la cine am văuzt..dar făcuse un for frumos pentru meniu+callback..(tu sau yonutu),era super ca și cod
la stock e aiurea acel if {}
în errorshow,puteai face să și ia banii,în cazul în care are
if ( !( ITEM == MENU_EXIT ) ) cam aiurea
static money-new money..
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
eXtreamSHOP
User avatar
LondoN eXtream
Utilizator neserios
Utilizator neserios
Posts: 2929
Joined: 10 Oct 2014, 05:21
Detinator Steam: Da
SteamID: /id/london_extreamcs
Reputatie: Utilizator neserios
Fost scripter eXtreamCS
Fost moderator ajutator
Membru Club eXtreamCS (6 luni)
Fond eXtream: 0
Location: Roman, Neamț
Has thanked: 2 times
Been thanked: 3 times

29 Jan 2019, 19:43

da stiu despre ce vorbesti...

new items[][]...

for(new i = 0; i < sizeof items; i++)

la callback

iar for
if(item == i ) { instructiuni }

referitor la static..se distruge si se creaza o singura data in tot codul..daca bagam cu new se creea de fiecare data cand accesa o tasta..deci zic ca e mai bine asa xD

la error show am fost strict pe eroare ca sa nu mai stau sa scriu acelasi rand de x ori..
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2440
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 36 times
Been thanked: 372 times
Contact:

29 Jan 2019, 20:21

mă gândeam la un new general,cu static am nelămuriri(e static pentru toată lumea...nu știu dacă și cu new e mai bine,dar e mai ok să se facă un new pentru fiecare în parte(zic))
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
User avatar
LondoN eXtream
Utilizator neserios
Utilizator neserios
Posts: 2929
Joined: 10 Oct 2014, 05:21
Detinator Steam: Da
SteamID: /id/london_extreamcs
Reputatie: Utilizator neserios
Fost scripter eXtreamCS
Fost moderator ajutator
Membru Club eXtreamCS (6 luni)
Fond eXtream: 0
Location: Roman, Neamț
Has thanked: 2 times
Been thanked: 3 times

29 Jan 2019, 20:30

L E V I N wrote:mă gândeam la un new general,cu static am nelămuriri(e static pentru toată lumea...nu știu dacă și cu new e mai bine,dar e mai ok să se facă un new pentru fiecare în parte(zic))
Static nu inseamna ca e static pentru fiecare in parte..inseamna ca se creează si se distruge o singură dată.. exemplu

Handler meniu - id jucător 1 - creare static money
Handler meniu - id jucător 2 - deja creat, doar ia valoarea cs get user money

Pe cand la new se creează una si pentru id 1 si pentru id2
Lux0R^
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 1225
Joined: 13 Jul 2013, 15:31
Detinator Steam: Da
Reputatie: Scripter eXtreamCS
Moderator ajutator
Has thanked: 15 times
Been thanked: 9 times

29 Jan 2019, 21:20

de ce toti au rang de scripter daca nu stiu nici macar “the basic stuff” ???
cine va designeaza ?
Pauza pana in iulie... licenta ^^

Fara pm-uri pentru pluginuri de zm/furien + tot ce tine de vip.

Codul Scripterului: scripting/codul-scripterului-t362300.html#p2754224
Lux0R^
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 1225
Joined: 13 Jul 2013, 15:31
Detinator Steam: Da
Reputatie: Scripter eXtreamCS
Moderator ajutator
Has thanked: 15 times
Been thanked: 9 times

29 Jan 2019, 21:58

LondoN eXtream wrote:
cso_Shop.sma | Afiseaza codul
#include < amxmodx >
#include < amxmisc >
#include < cstrike >

// Declarand o constanta cu tag-ul e doar o pierdere de memorie
#define CHAT_TAG	"^x04[CSDM NEW]^x01"

// Declaram nativele
native give_dualuzi ( Player );
native give_dartpistol ( Player );
native give_ethereal ( Player );
native give_thanatos ( Player );
native give_spear ( Player );
native give_lightsaber ( Player );
native give_thunderbolt ( Player );

public plugin_init ( )
{
	register_plugin ( "CSO Shop", "0.2", "dragonCSX" );
	register_clcmd ( "say", "PlayerMenu" );
	register_clcmd ( "say_team", "PlayerMenu" );
}

public PlayerMenu ( Player )
{
	new szArg [ 32 ];
	read_args ( szArg, charsmax ( szArg ) );
	remove_quotes ( szArg );

	if ( containi ( szArg, "/shop" ) != -1 || equal ( szArg, "/shop" ) && is_user_alive ( Player ) )
		ShowPlayerWeapons ( Player );

	return szArg [ 0 ] == '/' ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
}

public ShowPlayerWeapons ( Player )
{
	new szName [ 32 ], szTitle [ 128 ];
	get_user_name ( Player, szName, charsmax ( szName ) );
	formatex ( szTitle, charsmax ( szTitle ), "\w[\rCSO NST\w] Magazin Arme \rCSO^n\wBun venit [\r%s\w]", szName );

	new MenuID = menu_create ( szTitle, "MenuHandler" );

	menu_additem ( MenuID, "\wLightsaber \r[800$]" );
	menu_additem ( MenuID, "\wDart Pistol \r[1500$]" );
	menu_additem ( MenuID, "\wThanatos-11 \r[4500$]" );
	menu_additem ( MenuID, "\wEhereal Gun \r[6500$]" );
	menu_additem ( MenuID, "\wDual Uzi \r[8500$]" );
	menu_additem ( MenuID, "\wSpear Gun \r[12500$]" );
	menu_additem ( MenuID, "\wThunderbolt \r[16000$]" );

	menu_setprop ( MenuID, MPROP_EXITNAME, "\wIesire" );
	menu_setprop ( MenuID, MPROP_EXIT, MEXIT_ALL );
	menu_display ( Player, MenuID, 0 );
}

public MenuHandler ( Player, MenuID, ITEM )
{
	if ( !( ITEM == MENU_EXIT ) )
	{
		static Money;	Money = cs_get_user_money ( Player );

		switch ( ITEM )
		{
			case 0:		
			{
				if ( Money < 800 )
					ErrorShow ( Player, 800 );

				cs_set_user_money ( Player, Money - 800 );
				give_lightsaber ( Player );
				chat_color ( Player, "Ai cumparat^x04 Light Saber" );
			}

			case 1:
			{
				if ( Money < 2500 )
					ErrorShow ( Player, 2500 );

				cs_set_user_money ( Player, Money - 2500 );
				give_dartpistol ( Player );
				chat_color ( Player, "Ai cumparat^x04 Dart Pistol" );
			}

			case 2:
			{
				if ( Money < 4500 )
					ErrorShow ( Player, 4500 );
			
				cs_set_user_money ( Player, Money - 4500 );
				give_thanatos ( Player );
				chat_color ( Player, "Ai cumparat^x04 Thanatos-11" );
			}

			case 3:
			{
				if ( Money < 6500 )
					ErrorShow ( Player, 6500 );	
				
				cs_set_user_money ( Player, Money - 6500 );
				give_ethereal ( Player );
				chat_color ( Player, "Ai cumparat^x04 Ethereal" );
			}

			case 4:
			{
				if ( Money < 8500 )
					ErrorShow ( Player, 8500 );

				cs_set_user_money ( Player, Money - 8500 );
				give_dualuzi ( Player );
				chat_color ( Player, "Ai cumparat^x04 Dual U.Z.I" );
			}

			case 5:
			{
				if ( Money < 12500 )
					ErrorShow ( Player, 12500 );

				cs_set_user_money ( Player, Money - 12500 );
				give_spear ( Player );
				chat_color ( Player, "Ai cumparat^x04 Spear Gun" );
			}

			case 6:
			{
				if ( Money < 16000 )
					ErrorShow ( Player, 16000 );

				cs_set_user_money ( Player, Money - 16000 );
				give_thunderbolt ( Player );
				chat_color ( Player, "Ai cumparat^x04 Thunder Bolt" );
			}
		}
	}

	menu_destroy ( MenuID );
	return PLUGIN_HANDLED;
}

public ErrorShow ( Player, Money )
{
	chat_color ( Player, "Ai nevoie de^x04 %d $^x01 pentru a cumpara acest item", Money );
	return PLUGIN_HANDLED;
}

stock chat_color ( const Player, const Text [ ], any:... )
{
	static Message [ 191 ];
	new Players [ 32 ], Count = 1;
	vformat ( Message, charsmax ( Message ), Text, 3 );

	formatex ( Message, charsmax ( Message ), "%s %s", CHAT_TAG, Message );

	static SayText;

	if ( !SayText )
		SayText = get_user_msgid ( "SayText" );

	if ( Player )	Players [ 0 ] = Player; else get_players ( Players, Count, "ch" )
	{
		for ( new i = 0; i < Count; i++ )
		{
			if ( !is_user_connected ( Players [ i ] ) )
				continue;
			
			message_begin ( MSG_ONE_UNRELIABLE, SayText, _, Players [ i ] );
			write_byte ( Players [ i ] );
			write_string ( Message );
			message_end ( );
		}
	}
}
Optimizat. Cu placere
| Afiseaza codul
#include < amxmodx >
#include < amxmisc >
#include < cstrike >

// Declarand o constanta cu tag-ul e doar o pierdere de memorie
#define CHAT_TAG	"^x04[CSDM NEW]^x01"


// Declarat tip de data
// triplet : nume produs - cost produs - numele metodei ce va da produsul
enum Produs {
	nume[128], // nume cam lung, dar na, sa fim siguri
	cost,
	caller[128] // asta va fi metoda ce va fi apelata
}

new const produse[][Produs] = {
    { "Lightsaber", 800, "give_lightsaber" },
    { "Dart Pistol", 1500, "give_dartpistol" },
    { "Thanatos-11", 4500, "give_thanatos" },
    { "Ehereal Gun", 6500, "give_ethereal" },
    { "Dual Uzi", 7500, "give_dualuzi" },
    { "Spear Gun", 12500, "give_spear" },
    { "Thunderbolt", 16000, "give_thunderbolt" }
}

// Declaram nativele
native give_dualuzi ( Player );
native give_dartpistol ( Player );
native give_ethereal ( Player );
native give_thanatos ( Player );
native give_spear ( Player );
native give_lightsaber ( Player );
native give_thunderbolt ( Player );

public plugin_init ( )
{
	register_plugin ( "CSO Shop", "0.2", "dragonCSX" );
	register_clcmd ( "say", "PlayerMenu" );
	register_clcmd ( "say_team", "PlayerMenu" );
}

public PlayerMenu ( Player )
{
	new szArg [ 32 ];
	read_args ( szArg, charsmax ( szArg ) );
	remove_quotes ( szArg );

	if ( containi ( szArg, "/shop" ) != -1 || equal ( szArg, "/shop" ) && is_user_alive ( Player ) )
		ShowPlayerWeapons ( Player );

	return szArg [ 0 ] == '/' ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
}

public ShowPlayerWeapons ( Player )
{
	new szName [ 32 ], szTitle [ 128 ], itemName[180];
	get_user_name ( Player, szName, charsmax ( szName ) );
	formatex ( szTitle, charsmax ( szTitle ), "w[rCSO NSTw] Magazin Arme rCSO^nwBun venit [r%sw]", szName );

	new MenuID = menu_create ( szTitle, "MenuHandler" );

	for (new i = 0; i < sizeof(produse); ++i)
	{
		formatex(itemName, charsmax(itemName), "w%s r[%d$]", produse[nume], produse[cost]);
		menu_additem ( MenuID, itemName );
	}

	menu_setprop ( MenuID, MPROP_EXITNAME, "wIesire" );
	menu_setprop ( MenuID, MPROP_EXIT, MEXIT_ALL );
	menu_display ( Player, MenuID, 0 );
}

public MenuHandler ( Player, MenuID, item )
{
	if ( !( item == MENU_EXIT ) )
	{
		new	Money = cs_get_user_money ( Player ); // nu folosi static, ca nu se apeleaza de N ori pe secunda
		if ( Money < produse[item][cost] )
			ErrorShow(Player, produse[item][cost]) // ErrorShow really ? nu cumva showError ?

		cs_set_user_money ( Player, Money - produse[item][cost] );
                set_task(0.0, produse[item][caller], Player)
		chat_color ( Player, "Ai cumparat^x04 %s", produse[item][nume]);
	}

	menu_destroy ( MenuID );
	return PLUGIN_HANDLED; // pentru ce return. ??
}

public ErrorShow ( Player, Money )
{
	chat_color ( Player, "Ai nevoie de^x04 %d $^x01 pentru a cumpara acest item", Money );
	return PLUGIN_HANDLED; // the fuck, pentru ce return aici ???
}

stock chat_color ( const Player, const Text [ ], any:... )
{
	static Message [ 191 ];
	new Players [ 32 ], Count = 1;
	vformat ( Message, charsmax ( Message ), Text, 3 );

	formatex ( Message, charsmax ( Message ), "%s %s", CHAT_TAG, Message );

	static SayText;

	if ( !SayText )
		SayText = get_user_msgid ( "SayText" );

	if ( Player )	Players [ 0 ] = Player; else get_players ( Players, Count, "ch" )
	{
		for ( new i = 0; i < Count; i++ )
		{
			if ( !is_user_connected ( Players [ i ] ) )
				continue;
			
			message_begin ( MSG_ONE_UNRELIABLE, SayText, _, Players [ i ] );
			write_byte ( Players [ i ] );
			write_string ( Message );
			message_end ( );
		}
	}
}


nu e mai ok asa ?
e un trade fair, mai bine codul curat si safe decat cu 0.000000000000000...01 ori mai rapid


nu am testat ca nu mai am servere si nici compiler... l-am verificat d.p.d.v. al erorilor cu un compilator online


ideea unui plugin e sa fie usor de modificat, fara sa modifici in tot codul pentru o mica aditie.. uite cum e ceea ce am postat eu, cu 2 linii de cod adaugi o arma noua, lol
codul trebuie sa fie optimizat, dar nu super optimizat, cel mai important e sa poti intelege codul, sa il poti edita usor, si sa fie eficient
Pauza pana in iulie... licenta ^^

Fara pm-uri pentru pluginuri de zm/furien + tot ce tine de vip.

Codul Scripterului: scripting/codul-scripterului-t362300.html#p2754224
User avatar
dragonCSX
Membru, skill +1
Membru, skill +1
Posts: 192
Joined: 04 Feb 2017, 17:36
Detinator Steam: Da
CS Status: Web Developer / Scripting AMXX.
Detinator server CS: da
SteamID: weedakadulceata
Fond eXtream: 0
Location: Ploiesti
Contact:

29 Jan 2019, 22:21

Lux0R^ wrote:
LondoN eXtream wrote:
cso_Shop.sma | Afiseaza codul
#include < amxmodx >
#include < amxmisc >
#include < cstrike >

// Declarand o constanta cu tag-ul e doar o pierdere de memorie
#define CHAT_TAG	"^x04[CSDM NEW]^x01"

// Declaram nativele
native give_dualuzi ( Player );
native give_dartpistol ( Player );
native give_ethereal ( Player );
native give_thanatos ( Player );
native give_spear ( Player );
native give_lightsaber ( Player );
native give_thunderbolt ( Player );

public plugin_init ( )
{
	register_plugin ( "CSO Shop", "0.2", "dragonCSX" );
	register_clcmd ( "say", "PlayerMenu" );
	register_clcmd ( "say_team", "PlayerMenu" );
}

public PlayerMenu ( Player )
{
	new szArg [ 32 ];
	read_args ( szArg, charsmax ( szArg ) );
	remove_quotes ( szArg );

	if ( containi ( szArg, "/shop" ) != -1 || equal ( szArg, "/shop" ) && is_user_alive ( Player ) )
		ShowPlayerWeapons ( Player );

	return szArg [ 0 ] == '/' ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
}

public ShowPlayerWeapons ( Player )
{
	new szName [ 32 ], szTitle [ 128 ];
	get_user_name ( Player, szName, charsmax ( szName ) );
	formatex ( szTitle, charsmax ( szTitle ), "\w[\rCSO NST\w] Magazin Arme \rCSO^n\wBun venit [\r%s\w]", szName );

	new MenuID = menu_create ( szTitle, "MenuHandler" );

	menu_additem ( MenuID, "\wLightsaber \r[800$]" );
	menu_additem ( MenuID, "\wDart Pistol \r[1500$]" );
	menu_additem ( MenuID, "\wThanatos-11 \r[4500$]" );
	menu_additem ( MenuID, "\wEhereal Gun \r[6500$]" );
	menu_additem ( MenuID, "\wDual Uzi \r[8500$]" );
	menu_additem ( MenuID, "\wSpear Gun \r[12500$]" );
	menu_additem ( MenuID, "\wThunderbolt \r[16000$]" );

	menu_setprop ( MenuID, MPROP_EXITNAME, "\wIesire" );
	menu_setprop ( MenuID, MPROP_EXIT, MEXIT_ALL );
	menu_display ( Player, MenuID, 0 );
}

public MenuHandler ( Player, MenuID, ITEM )
{
	if ( !( ITEM == MENU_EXIT ) )
	{
		static Money;	Money = cs_get_user_money ( Player );

		switch ( ITEM )
		{
			case 0:		
			{
				if ( Money < 800 )
					ErrorShow ( Player, 800 );

				cs_set_user_money ( Player, Money - 800 );
				give_lightsaber ( Player );
				chat_color ( Player, "Ai cumparat^x04 Light Saber" );
			}

			case 1:
			{
				if ( Money < 2500 )
					ErrorShow ( Player, 2500 );

				cs_set_user_money ( Player, Money - 2500 );
				give_dartpistol ( Player );
				chat_color ( Player, "Ai cumparat^x04 Dart Pistol" );
			}

			case 2:
			{
				if ( Money < 4500 )
					ErrorShow ( Player, 4500 );
			
				cs_set_user_money ( Player, Money - 4500 );
				give_thanatos ( Player );
				chat_color ( Player, "Ai cumparat^x04 Thanatos-11" );
			}

			case 3:
			{
				if ( Money < 6500 )
					ErrorShow ( Player, 6500 );	
				
				cs_set_user_money ( Player, Money - 6500 );
				give_ethereal ( Player );
				chat_color ( Player, "Ai cumparat^x04 Ethereal" );
			}

			case 4:
			{
				if ( Money < 8500 )
					ErrorShow ( Player, 8500 );

				cs_set_user_money ( Player, Money - 8500 );
				give_dualuzi ( Player );
				chat_color ( Player, "Ai cumparat^x04 Dual U.Z.I" );
			}

			case 5:
			{
				if ( Money < 12500 )
					ErrorShow ( Player, 12500 );

				cs_set_user_money ( Player, Money - 12500 );
				give_spear ( Player );
				chat_color ( Player, "Ai cumparat^x04 Spear Gun" );
			}

			case 6:
			{
				if ( Money < 16000 )
					ErrorShow ( Player, 16000 );

				cs_set_user_money ( Player, Money - 16000 );
				give_thunderbolt ( Player );
				chat_color ( Player, "Ai cumparat^x04 Thunder Bolt" );
			}
		}
	}

	menu_destroy ( MenuID );
	return PLUGIN_HANDLED;
}

public ErrorShow ( Player, Money )
{
	chat_color ( Player, "Ai nevoie de^x04 %d $^x01 pentru a cumpara acest item", Money );
	return PLUGIN_HANDLED;
}

stock chat_color ( const Player, const Text [ ], any:... )
{
	static Message [ 191 ];
	new Players [ 32 ], Count = 1;
	vformat ( Message, charsmax ( Message ), Text, 3 );

	formatex ( Message, charsmax ( Message ), "%s %s", CHAT_TAG, Message );

	static SayText;

	if ( !SayText )
		SayText = get_user_msgid ( "SayText" );

	if ( Player )	Players [ 0 ] = Player; else get_players ( Players, Count, "ch" )
	{
		for ( new i = 0; i < Count; i++ )
		{
			if ( !is_user_connected ( Players [ i ] ) )
				continue;
			
			message_begin ( MSG_ONE_UNRELIABLE, SayText, _, Players [ i ] );
			write_byte ( Players [ i ] );
			write_string ( Message );
			message_end ( );
		}
	}
}
Optimizat. Cu placere
| Afiseaza codul
#include < amxmodx >
#include < amxmisc >
#include < cstrike >

// Declarand o constanta cu tag-ul e doar o pierdere de memorie
#define CHAT_TAG	"^x04[CSDM NEW]^x01"


// Declarat tip de data
// triplet : nume produs - cost produs - numele metodei ce va da produsul
enum Produs {
	nume[128], // nume cam lung, dar na, sa fim siguri
	cost,
	caller[128] // asta va fi metoda ce va fi apelata
}

new const produse[][Produs] = {
    { "Lightsaber", 800, "give_lightsaber" },
    { "Dart Pistol", 1500, "give_dartpistol" },
    { "Thanatos-11", 4500, "give_thanatos" },
    { "Ehereal Gun", 6500, "give_ethereal" },
    { "Dual Uzi", 7500, "give_dualuzi" },
    { "Spear Gun", 12500, "give_spear" },
    { "Thunderbolt", 16000, "give_thunderbolt" }
}

// Declaram nativele
native give_dualuzi ( Player );
native give_dartpistol ( Player );
native give_ethereal ( Player );
native give_thanatos ( Player );
native give_spear ( Player );
native give_lightsaber ( Player );
native give_thunderbolt ( Player );

public plugin_init ( )
{
	register_plugin ( "CSO Shop", "0.2", "dragonCSX" );
	register_clcmd ( "say", "PlayerMenu" );
	register_clcmd ( "say_team", "PlayerMenu" );
}

public PlayerMenu ( Player )
{
	new szArg [ 32 ];
	read_args ( szArg, charsmax ( szArg ) );
	remove_quotes ( szArg );

	if ( containi ( szArg, "/shop" ) != -1 || equal ( szArg, "/shop" ) && is_user_alive ( Player ) )
		ShowPlayerWeapons ( Player );

	return szArg [ 0 ] == '/' ? PLUGIN_HANDLED : PLUGIN_CONTINUE;
}

public ShowPlayerWeapons ( Player )
{
	new szName [ 32 ], szTitle [ 128 ], itemName[180];
	get_user_name ( Player, szName, charsmax ( szName ) );
	formatex ( szTitle, charsmax ( szTitle ), "w[rCSO NSTw] Magazin Arme rCSO^nwBun venit [r%sw]", szName );

	new MenuID = menu_create ( szTitle, "MenuHandler" );

	for (new i = 0; i < sizeof(produse); ++i)
	{
		formatex(itemName, charsmax(itemName), "w%s r[%d$]", produse[nume], produse[cost]);
		menu_additem ( MenuID, itemName );
	}

	menu_setprop ( MenuID, MPROP_EXITNAME, "wIesire" );
	menu_setprop ( MenuID, MPROP_EXIT, MEXIT_ALL );
	menu_display ( Player, MenuID, 0 );
}

public MenuHandler ( Player, MenuID, item )
{
	if ( !( item == MENU_EXIT ) )
	{
		new	Money = cs_get_user_money ( Player ); // nu folosi static, ca nu se apeleaza de N ori pe secunda
		if ( Money < produse[item][cost] )
			ErrorShow(Player, produse[item][cost]) // ErrorShow really ? nu cumva showError ?

		cs_set_user_money ( Player, Money - produse[item][cost] );
                set_task(0.0, produse[item][caller], Player)
		chat_color ( Player, "Ai cumparat^x04 %s", produse[item][nume]);
	}

	menu_destroy ( MenuID );
	return PLUGIN_HANDLED; // pentru ce return. ??
}

public ErrorShow ( Player, Money )
{
	chat_color ( Player, "Ai nevoie de^x04 %d $^x01 pentru a cumpara acest item", Money );
	return PLUGIN_HANDLED; // the fuck, pentru ce return aici ???
}

stock chat_color ( const Player, const Text [ ], any:... )
{
	static Message [ 191 ];
	new Players [ 32 ], Count = 1;
	vformat ( Message, charsmax ( Message ), Text, 3 );

	formatex ( Message, charsmax ( Message ), "%s %s", CHAT_TAG, Message );

	static SayText;

	if ( !SayText )
		SayText = get_user_msgid ( "SayText" );

	if ( Player )	Players [ 0 ] = Player; else get_players ( Players, Count, "ch" )
	{
		for ( new i = 0; i < Count; i++ )
		{
			if ( !is_user_connected ( Players [ i ] ) )
				continue;
			
			message_begin ( MSG_ONE_UNRELIABLE, SayText, _, Players [ i ] );
			write_byte ( Players [ i ] );
			write_string ( Message );
			message_end ( );
		}
	}
}


nu e mai ok asa ?
e un trade fair, mai bine codul curat si safe decat cu 0.000000000000000...01 ori mai rapid


nu am testat ca nu mai am servere si nici compiler... l-am verificat d.p.d.v. al erorilor cu un compilator online


ideea unui plugin e sa fie usor de modificat, fara sa modifici in tot codul pentru o mica aditie.. uite cum e ceea ce am postat eu, cu 2 linii de cod adaugi o arma noua, lol
codul trebuie sa fie optimizat, dar nu super optimizat, cel mai important e sa poti intelege codul, sa il poti edita usor, si sa fie eficient


;)
User avatar
L E V I N
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 2440
Joined: 24 Aug 2011, 11:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Has thanked: 36 times
Been thanked: 372 times
Contact:

29 Jan 2019, 22:31

Lux0R^ wrote:de ce toti au rang de scripter daca nu stiu nici macar “the basic stuff” ???
cine va designeaza ?
păi atunci cumde ai gradu?te crezi zeu? a stai, ești d-ăla prea inteligent,înnăscut cu amxx, fiecare știe ce știe,cine ești tu să-ți dai cu părerea? ți-am cerut-o?
scripter nu se referă numai la amxx,dragă luxor :') :') ':)
tu de ex,de ce ai „scripter”? ajuți lumea măcar?sau ai postat 2-3 plugine de pe net,schimbate la cod,ai făcut chestii geniale?să n-o dăm așa
eu unu nu am pus întrebare,diferență/sau ce reprezintă,da e greu să gândești ce citești(dacă citești)
Nu fac nimic contra cost! Faceți cerere bine detaliată aici, pe forum. Nu-mi mai dați add pe Steam doar pentru a mă avea în lista de prieteni.
Am cont și activez doar aici! Aveți grijă la cei ce încearcă să mă copieze..Puteți lua legătura cu mine dacă aveți o problemă/nelămurire în acest caz.
În cazul în care utilizați ceva din addonsurile postate de mine aici, e bine să fiți la curent cu modificările aduse unor plugine, aici.
User avatar
dragonCSX
Membru, skill +1
Membru, skill +1
Posts: 192
Joined: 04 Feb 2017, 17:36
Detinator Steam: Da
CS Status: Web Developer / Scripting AMXX.
Detinator server CS: da
SteamID: weedakadulceata
Fond eXtream: 0
Location: Ploiesti
Contact:

30 Jan 2019, 03:02

@L E V I N
Apreciez munca amandurora .
Imi este indiferent , ca ala face asa sau ala asa.
User avatar
Filiq_
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 620
Joined: 02 Nov 2014, 18:21
Detinator Steam: Da
CS Status: Citesc forumul eXtreamCS.com...!
Reputatie: Scripter eXtreamCS
Fost Membru Club eXtreamCS (doua luni)
Nume anterior: IIiFF, Diversity
Fond eXtream: 0
Location: Constanta
Has thanked: 29 times
Been thanked: 13 times

02 Feb 2019, 14:06

Ce e cu atata ura intre voi?

@luxor
Daca cineva nu iti vrea ajutorul sau sfatul nu ii baga toate lucrurile pe gat ca poate omul le stie doar ca nu le a aplicat.
Last edited by YONTU on 02 Feb 2019, 16:14, edited 2 times in total.
Reason: Pai daca stie, de ce nu aplica? E ca si cum ai face o sortare, stii si quick sort si bubble sort, dar tu aplici bubble sort. Eficienta unde?
ImageImage

Retras [ m-am mutat pe cs:go ].
http://extreamcs.net/forum/ :hand_over_mouth:
User avatar
dragonCSX
Membru, skill +1
Membru, skill +1
Posts: 192
Joined: 04 Feb 2017, 17:36
Detinator Steam: Da
CS Status: Web Developer / Scripting AMXX.
Detinator server CS: da
SteamID: weedakadulceata
Fond eXtream: 0
Location: Ploiesti
Contact:

17 Feb 2019, 20:55

Update-ul întârzie.
Sunt plecat cu munca.
Post Reply

Return to “AmxModX”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 5 guests