Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include < amxmodx >
- #include < fakemeta_util >
- #include < engine >
- #include < fun >
- #include < fvault >
- native get_user_cash(client);
- native set_user_cash(client, amount);
- new UseWing[ 33 ];
- new Wings[ 33 ];
- new szVault[ ] = "Wings_vault";
- new g_Sprite[ ][ ] = {"sprites/lgtning.spr" };
- new Sprite;
- new para_ent[33]
- enum _:WingsBrowse{
- modelplace[ 128 ],
- Name[ 33 ],
- price
- }
- new const g_szWings[ 5 ][ WingsBrowse ] =
- {
- { "models/AMXX/wings1.mdl", "Wing #1", 100000 },
- { "models/AMXX/wings2.mdl", "Wing #2", 200000 },
- { "models/AMXX/wings3.mdl", "Wing #3", 300000 },
- { "models/AMXX/wings4.mdl", "Wing #4", 400000 },
- { "models/AMXX/wings5.mdl", "Wing #5", 500000 }
- }
- public plugin_init()
- {
- register_clcmd("say /wing","MainMenu");
- register_clcmd("say /wings","MainMenu");
- register_event("ResetHUD", "newSpawn", "be")
- register_event("DeathMsg", "death_event", "a")
- }
- public plugin_precache()
- {
- for ( new i = 0; i < sizeof( g_szWings ); i++ )
- precache_model( g_szWings[ i ][ modelplace ] );
- Sprite = precache_model( g_Sprite[ 0 ] );
- }
- public death_event()
- {
- new id = read_data(2)
- parachute_reset(id)
- }
- parachute_reset(id)
- {
- if(para_ent[id] > 0)
- {
- if (is_valid_ent(para_ent[id]))
- {
- remove_entity(para_ent[id])
- }
- }
- if(is_user_alive(id)) set_user_gravity(id, 1.0)
- para_ent[id] = 0
- }
- public newSpawn(id)
- {
- if(para_ent[id] > 0)
- {
- remove_entity(para_ent[id])
- set_user_gravity(id, 1.0)
- para_ent[id] = 0
- }
- }
- public client_PreThink(id)
- {
- if( UseWing[ id ] >= 1 && Wings[ id ] >= 1 )
- {
- new Float:fallspeed = 100 * -1.0
- new Float:frame
- new button = get_user_button(id)
- new oldbutton = get_user_oldbutton(id)
- new flags = get_entity_flags(id)
- if(para_ent[id] > 0 && (flags & FL_ONGROUND))
- {
- if(get_user_gravity(id) == 0.1) set_user_gravity(id, 1.0)
- {
- if(entity_get_int(para_ent[id],EV_INT_sequence) != 2)
- {
- entity_set_int(para_ent[id], EV_INT_sequence, 2)
- entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
- entity_set_float(para_ent[id], EV_FL_frame, 0.0)
- entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
- entity_set_float(para_ent[id], EV_FL_animtime, 0.0)
- entity_set_float(para_ent[id], EV_FL_framerate, 0.0)
- return
- }
- frame = entity_get_float(para_ent[id],EV_FL_fuser1) + 2.0
- entity_set_float(para_ent[id],EV_FL_fuser1,frame)
- entity_set_float(para_ent[id],EV_FL_frame,frame)
- if(frame > 254.0)
- {
- remove_entity(para_ent[id])
- para_ent[id] = 0
- }
- else
- {
- remove_entity(para_ent[id])
- set_user_gravity(id, 1.0)
- para_ent[id] = 0
- }
- return
- }
- }
- if (button & IN_USE)
- {
- new Float:velocity[3]
- entity_get_vector(id, EV_VEC_velocity, velocity)
- if(velocity[2] < 0.0)
- {
- if(para_ent[id] <= 0)
- {
- para_ent[id] = create_entity("info_target")
- if(para_ent[id] > 0)
- {
- entity_set_edict( para_ent[id], EV_ENT_euser1, id );
- entity_set_int( para_ent[id], EV_INT_iuser1, 0 );
- entity_set_size( para_ent[id], Float:{-6.0,-6.0,-6.0}, Float:{6.0,6.0,6.0} );
- entity_set_float( para_ent[id], EV_FL_friction, 0.6 );
- message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
- write_byte( TE_BEAMFOLLOW );
- write_short( para_ent[id] );
- write_short( Sprite );
- write_byte( 20 );
- write_byte( 13 );
- write_byte( 12 );
- write_byte( 122 );
- write_byte( 221 );
- write_byte( 255 );
- message_end( );
- entity_set_string(para_ent[id],EV_SZ_classname,"parachute")
- entity_set_edict(para_ent[id], EV_ENT_aiment, id)
- entity_set_edict(para_ent[id], EV_ENT_owner, id)
- entity_set_int(para_ent[id], EV_INT_movetype, MOVETYPE_FOLLOW)
- fm_set_rendering( para_ent[id], kRenderFxGlowShell, random_num( 1, 255 ), random_num( 1, 255 ), random_num( 1, 255 ),kRenderNormal, 200 );
- entity_set_model(para_ent[id], g_szWings[ UseWing[ id ]-1 ][ modelplace ]);
- entity_set_int(para_ent[id], EV_INT_sequence, 0)
- entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
- entity_set_float(para_ent[id], EV_FL_frame, 0.0)
- entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
- }
- }
- if(para_ent[id] > 0)
- {
- entity_set_int(id, EV_INT_sequence, 3)
- entity_set_int(id, EV_INT_gaitsequence, 1)
- entity_set_float(id, EV_FL_frame, 1.0)
- entity_set_float(id, EV_FL_framerate, 1.0)
- set_user_gravity(id, 0.1)
- velocity[2] = (velocity[2] + 40.0 < fallspeed) ? velocity[2] + 40.0 : fallspeed
- entity_set_vector(id, EV_VEC_velocity, velocity)
- if(entity_get_int(para_ent[id],EV_INT_sequence) == 0)
- {
- frame = entity_get_float(para_ent[id],EV_FL_fuser1) + 1.0
- entity_set_float(para_ent[id],EV_FL_fuser1,frame)
- entity_set_float(para_ent[id],EV_FL_frame,frame)
- if (frame > 100.0)
- {
- entity_set_float(para_ent[id], EV_FL_animtime, 0.0)
- entity_set_float(para_ent[id], EV_FL_framerate, 0.4)
- entity_set_int(para_ent[id], EV_INT_sequence, 1)
- entity_set_int(para_ent[id], EV_INT_gaitsequence, 1)
- entity_set_float(para_ent[id], EV_FL_frame, 0.0)
- entity_set_float(para_ent[id], EV_FL_fuser1, 0.0)
- }
- }
- }
- }
- else if(para_ent[id] > 0)
- {
- remove_entity(para_ent[id])
- set_user_gravity(id, 1.0)
- para_ent[id] = 0
- }
- }
- else if((oldbutton & IN_USE) && para_ent[id] > 0 )
- {
- remove_entity(para_ent[id])
- set_user_gravity(id, 1.0)
- para_ent[id] = 0
- }
- }
- }
- public MainMenu(id)
- {
- new szMenu[ 128 ];
- formatex( szMenu, charsmax( szMenu ), "\r[\d AMXX \r] \wWings main menu" )
- new Menu1 = menu_create( szMenu, "MainMenu_sub" );
- formatex( szMenu, charsmax( szMenu ), "\wWings Shop");
- menu_additem( Menu1, szMenu, "0" );
- formatex( szMenu, charsmax( szMenu ), "\wUse Wings");
- menu_additem( Menu1, szMenu, "1" );
- menu_setprop(Menu1, MPROP_EXIT, MEXIT_ALL );
- menu_setprop(Menu1, MPROP_EXITNAME, "\wExit" )
- menu_setprop(Menu1, MPROP_NUMBER_COLOR, "\r" )
- menu_display(id, Menu1, 0);
- return PLUGIN_HANDLED;
- }
- public MainMenu_sub(id, Menu, item)
- {
- if( item == MENU_EXIT )
- {
- menu_destroy(Menu);
- return PLUGIN_HANDLED;
- }
- new data[6], iName[64];
- new access, callback;
- menu_item_getinfo(Menu, item, access, data, 6, iName, 63, callback)
- new key = str_to_num(data);
- switch(key)
- {
- case 0: wing( id )
- case 1: usewings( id )
- }
- menu_destroy(Menu);
- return PLUGIN_HANDLED;
- }
- public wing( client )
- {
- new szItem[ 208 ];
- formatex( szItem, charsmax( szItem ), "\r[\d AMXX \r] \wWings Shop:");
- new menu = menu_create( szItem, "handler" );
- new iColor[ 33 ]
- for ( new i = 0; i < sizeof( g_szWings ); i++ )
- {
- if( Wings[ client ] >= i+1 )
- iColor = "\w";
- else
- iColor = "\d";
- if( i <= Wings[ client ]-1 )
- formatex( szItem, charsmax( szItem ), "%s%s \d[ Purchased ]", iColor, g_szWings[ i ][ Name ] );
- else
- formatex( szItem, charsmax( szItem ), "%s%s \r[ %i Cash ]", iColor, g_szWings[ i ][ Name ], g_szWings[ i ][ price ] );
- menu_additem( menu, szItem );
- }
- menu_display( client, menu );
- return 1;
- }
- public handler( client, menu, item )
- {
- if( item == MENU_EXIT )
- {
- menu_destroy( menu );
- MainMenu( client );
- return 1;
- }
- if( item <= Wings[ client ]-1 )
- return ColorChat( client, "You have already^4 bought^1 this wings." );
- if( item > Wings[ client ] )
- return ColorChat( client, "You have to buy the previous wings." );
- if( get_user_cash( client ) >= g_szWings[ item ][ price ] )
- {
- Wings[ client ]++
- CmdSave( client );
- set_user_cash( client, get_user_cash( client ) - g_szWings[ item ][ price ] )
- ColorChat(0, "Congratulation,^3 %s^1 has purchase ^4%s^1.", GetUserName(client), g_szWings[ item ][ Name ])
- return 1;
- }
- else
- {
- ColorChat( client, "You don't have enough cash. Missing: ^4%i ^1cash.", g_szWings[ item ][ price ] - get_user_cash( client ) );
- wing( client )
- return 1;
- }
- return 1;
- }
- public usewings( client )
- {
- new szItem[ 208 ];
- formatex( szItem, charsmax( szItem ), "\r[\d AMXX \r] \wUse Wings menu:");
- new menu = menu_create( szItem, "handler_use" );
- for ( new i = 0; i < sizeof( g_szWings ); i++ )
- {
- formatex( szItem, charsmax( szItem ), "%s%s %s", Wings[ client ] >= i+1 ? "\w" : "\d", g_szWings[ i ][ Name ], UseWing[ client ]-1 == i ? "\d[ USED ]" : "\r[ USE ]");
- menu_additem( menu, szItem );
- }
- menu_display( client, menu );
- return 1;
- }
- public handler_use( client, menu, item )
- {
- if( item == MENU_EXIT )
- {
- menu_destroy( menu );
- MainMenu( client );
- return 1;
- }
- if( item+1 > Wings[ client ] )
- return ColorChat( client, "You have to^4 bought^1 this wings before using." );
- ColorChat( client, "You have been used:^4 %s^1.", g_szWings[ item ][ Name ] );
- UseWing[ client ] = item+1;
- CmdSave( client );
- return 1;
- }
- public client_putinserver( index )
- {
- CmdLoad( index );
- }
- public client_disconnect( client )
- {
- CmdSave( client );
- }
- stock GetAuth( id )
- {
- static szAuth[ 60 ];
- get_user_authid( id, szAuth, charsmax( szAuth ) );
- if( contain( szAuth, "VALVE_" ) != -1 || contain( szAuth, "ID_LAN" ) != -1 )
- get_user_ip( id, szAuth, charsmax( szAuth ), 1 );
- return szAuth;
- }
- stock CmdSave(index)
- {
- if(is_user_bot(index) || is_user_hltv(index))
- return;
- new szKey[ 64 ], szData[ 256 ];
- formatex( szKey, charsmax( szKey ), "%s", GetAuth( index ) );
- formatex( szData, charsmax( szData ), "%i %i %s",Wings[ index ], UseWing[ index ] ,GetUserName( index ));
- fvault_set_data( szVault, szKey, szData );
- }
- stock CmdLoad( index )
- {
- new szKey[ 64 ], szData[ 256 ];
- formatex( szKey, charsmax( szKey ), "%s", GetAuth( index ) );
- formatex( szData, charsmax( szData ), "%i %i %s",Wings[ index ], UseWing[ index ] ,GetUserName( index ));
- fvault_get_data( szVault, szKey, szData, 255 );
- new SetData[ 2 ][ 32 ];
- parse( szData, SetData[ 0 ], 31, SetData[ 1 ], 31 );
- Wings[ index ] = str_to_num( SetData[ 0 ] );
- UseWing[ index ] = str_to_num( SetData[ 1 ] );
- }
- stock GetUserName( client )
- {
- new szName[ 33 ];
- get_user_name( client, szName, charsmax( szName ) );
- return szName;
- }
- stock ColorChat( const index, const string[], any:... )
- {
- new szMsg[ 191 ], Players[ 32 ], PNum = 1;
- static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^4[AMXX]^1 ");
- vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
- if ( index )
- Players[ 0 ] = index;
- else
- get_players( Players, PNum, "ch" );
- for ( new i; i < PNum; i++ )
- {
- if( is_user_connected( Players[ i ] ) )
- {
- message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
- write_byte( Players[ i ] );
- write_string( szMsg );
- message_end( );
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement