12/06/2019, 11:00 PM
(Última modificación: 13/06/2019, 02:15 AM por wicho. Edited 1 time in total.)
Hola todos, alguien podria poner en este menu (de chema) que el maximo que se pueda donar sea 100 ammopacks y que solo se pueda utilizar una vez por mapa este menu (o sea solo pueda donar a un jugador por mapa) .. gracias antemano
Código PHP:
/* Sublime AMXX Editor v3.0.0-beta */
#include < amxmodx >
#pragma semicolon 1
#if AMXX_VERSION_NUM < 183
#define client_disconected client_disconnect
#define print_team_default 0
#define MAX_PLAYERS 32
#define MAX_NAME_LENGTH 32
stock client_print_color( iID, iFakeVar, const szInput[ ], any:... ) {
#pragma unused iFakeVar
static szMessage[ 191 ], g_iMsgSayText;
if( !g_iMsgSayText )
g_iMsgSayText = get_user_msgid( "SayText" );
vformat( szMessage, 190, szInput, 3 );
message_begin( iID ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_iMsgSayText, .player = iID );
write_byte( iID ? iID : 33 );
write_string( szMessage );
message_end( );
}
#endif
/* GLOBAL STUFF */
new g_szPluginName[ ] = "Donate ammopacks";
new g_szPluginVersion[ ] = "1.0b";
new g_szPluginAuthor[ ] = "Chema";
new g_szSayPrefix[ ] = "^3[Kohoutek Gaming]^1";
new g_szConsolePrefix[ ] = "[Kohoutek Gaming]";
new g_szContactUrl[ ] = "www.amxmodx-es.com/Chema";
new const g_szSelectItemSound[ ] = "Ui/buttonclickrelease.wav";
const Float:TASK_ADVERTISING = 90.0;
new g_szPlayerName[ MAX_PLAYERS + 1 ][ MAX_NAME_LENGTH ];
new g_iTarget[ MAX_PLAYERS + 1 ];
new g_iAmmopacks[ MAX_PLAYERS + 1 ];
public plugin_init( ) {
register_plugin( g_szPluginName, g_szPluginVersion, g_szPluginAuthor );
/* Plugin Cvars */
register_cvar( "donateaps_author", g_szPluginAuthor, FCVAR_SPONLY );
register_cvar( "donateaps", g_szPluginVersion, FCVAR_SERVER|FCVAR_SPONLY|FCVAR_UNLOGGED );
/* Client-related Stuff */
register_clcmd( "ENTER_AMMOUNT", "MESSAGE_EnterAmmount" );
register_clcmd( "say /donate", "ShowDonateMenu" );
/* Init Tasks */
set_task( TASK_ADVERTISING, "task_Advertising", 0, .flags = "b" );
}
/* Init Tasks */
public task_Advertising( ) {
ClrearUserChat( 0 );
client_print_color( 0, 0, "%s This server is using ^3%s^1 ^4%s^1 by ^3%s^1.", g_szSayPrefix, g_szPluginName, g_szPluginVersion, g_szPluginAuthor );
client_print_color( 0, 0, "%s You can contact him at: ^4%s^1.", g_szSayPrefix, g_szContactUrl );
}
/* Client-related Stuff */
public client_putinserver( iID )
g_iAmmopacks[ iID ] = 0;
public MESSAGE_EnterAmmount( const iID ) {
new szAmmount[ 12 ], iAmmount;
read_args( szAmmount, charsmax( szAmmount ) );
remove_quotes( szAmmount );
trim( szAmmount );
new iLen = strlen( szAmmount );
if( !iLen ) {
client_print_color( iID, 0, "%s You can't leave the amount blank.", g_szSayPrefix );
client_cmd( iID, "messagemode ^"ENTER_AMMOUNT^"" );
return PLUGIN_HANDLED;
}
for( new i = 0; i < iLen; i++ ) {
if( !isdigit( szAmmount[ i ] ) ) {
client_print_color( iID, 0, "%s You can only write numbers.", g_szSayPrefix );
client_cmd( iID, "messagemode ^"ENTER_AMMOUNT^"" );
return PLUGIN_HANDLED;
}
}
iAmmount = str_to_num( szAmmount );
if( iAmmount < 0 ) {
client_print_color( iID, 0, "%s You can't put negative numbers.", g_szSayPrefix );
client_cmd( iID, "messagemode ^"ENTER_AMMOUNT^"" );
return PLUGIN_HANDLED;
}
g_iAmmopacks[ g_iTarget[ iID ] ] += iAmmount;
client_print_color( iID, 0, "%s You gave him^4 %i^1 ammopacks to ^3%s^1.", g_szSayPrefix, iAmmount, g_szPlayerName[ g_iTarget[ iID ] ] );
client_print_color( g_iTarget[ iID ], 0, "%s ^3%s^1 has given you^4 %i^1 ammopacks.", g_szSayPrefix, g_szPlayerName[ iID ], iAmmount );
return PLUGIN_HANDLED;
}
/* Donate Menu */
public ShowDonateMenu( const iID ) {
if( !( get_user_flags( iID & ADMIN_KICK ) ) ) {
client_print_color( iID, 0, "%s Only administrators have access to this menu.", g_szSayPrefix );
return PLUGIN_HANDLED;
}
new szBuffer[ 40 ];
new iMenu = menu_create( "\yDonate ammopacks^n^nFirst select a \wplayer\y.", "HandlerDonateMenu" );
new iNumber[ 3 ];
for( new i = 1; i <= get_maxplayers( ); i++ ) {
if ( !is_user_connected( i ) /*|| i == iID*/ )
continue;
get_user_name( i, g_szPlayerName[ i ], sizeof( g_szPlayerName[ ] ) );
formatex( szBuffer, charsmax( szBuffer ), "%s \r(%i Ammopacks)", g_szPlayerName[ i ], g_iAmmopacks[ i ] );
num_to_str( i, iNumber, sizeof( iNumber ) );
menu_additem( iMenu, szBuffer, iNumber );
}
menu_setprop( iMenu, MPROP_NUMBER_COLOR, "\y" );
menu_display( iID, iMenu );
return PLUGIN_HANDLED;
}
public HandlerDonateMenu( const iID, const iMenu, const iItem ) {
if( iItem == MENU_EXIT ) {
menu_destroy( iMenu );
return PLUGIN_HANDLED;
}
static iNumber[ 6 ], iTarget;
menu_item_getinfo( iMenu, iItem, iTarget, iNumber, sizeof( iNumber ), _, _, iTarget );
g_iTarget[ iID ] = str_to_num( iNumber );
client_cmd( iID, "messagemode ^"ENTER_AMMOUNT^"" );
client_cmd( iID, "spk ^"%s^"", g_szSelectItemSound );
return PLUGIN_HANDLED;
}
/* Stocks & Private functions */
stock ClrearUserChat( const iID ) {
new j;
for( j = 1; j < 7; j++ ) {
client_print( iID, print_chat, " " );
}
}