Advertisement
Rejack

Donation Menu (v1.0)

Feb 10th, 2013 (edited)
758
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 9.63 KB | None | 0 0
  1. /*
  2.     Notice - This plugin is bugged... so if you want to use it you can.. tought i don't recommand it...
  3.     This plugin was made by Rejack ( AmxxStudio ).
  4.     This was never published because it's still bugged...
  5. */
  6.  
  7. #include < amxmodx >
  8. #include < cstrike >
  9.  
  10. new gDonate[ 33 ], bool:AllowDonate[ 33 ] = false, gReq[ 33 ];
  11.  
  12. public plugin_init()
  13. {
  14.     register_clcmd( "say /donate", "cmdDonateMenu" );
  15.     register_clcmd( "_donate_", "DonateValue" );
  16.     register_clcmd( "_req_", "RequestValue" );
  17. }
  18.  
  19. public cmdDonateMenu( id )
  20. {
  21.     new gMenu = menu_create( "Donate Menu", "subDonateMenu" );
  22.     menu_additem( gMenu, "Make a Donation", "0" );
  23.     menu_additem( gMenu, "Request a Donation^n", "1" );
  24.    
  25.     new szItem[ 128 ];
  26.     formatex( szItem, charsmax( szItem ), "Allow Donation Request:\r O%s", AllowDonate[ id ] ? "n" : "ff" );
  27.     menu_additem( gMenu, szItem, "2" );
  28.     menu_display( id, gMenu );
  29. }
  30. public subDonateMenu( id, gMenu, gItem )
  31. {
  32.     if ( gItem == MENU_EXIT )
  33.     {
  34.         menu_destroy( gMenu );
  35.         return PLUGIN_HANDLED;
  36.     }
  37.     switch ( gItem )
  38.     {
  39.         case 0:
  40.         {
  41.             cmdDonate( id );
  42.         }
  43.         case 1:
  44.         {
  45.             cmdRequest( id );
  46.         }
  47.         case 2:
  48.         {
  49.             AllowDonate[ id ] = !AllowDonate[ id ];
  50.             ColorChat( id, "Donation Request - %sabled", AllowDonate[ id ] ? "^4En" : "^3Dis" );
  51.             cmdDonateMenu( id );
  52.         }
  53.     }
  54.     menu_destroy( gMenu );
  55.     return PLUGIN_HANDLED;
  56. }
  57. public cmdRequest( id )
  58. {
  59.     new players[ 32 ], pnum;
  60.     new szName[ 32 ], szTempId[ 3 ], gMenuItem[ 64 ], szAddItem[ 64 ];
  61.    
  62.     new gMenu = menu_create( "Donate to a Player Menu", "subRequest" );
  63.     formatex( gMenuItem, 63, "\yYou will request a donation of:\r %d", gReq[ id ] );
  64.     menu_additem( gMenu, gMenuItem, "0" );
  65.     get_players( players, pnum, "c" );
  66.     for( new i=0; i<pnum; i+=1 )
  67.     {
  68.         new tempid = players[ i ];
  69.         num_to_str( tempid, szTempId, charsmax( szTempId ) );
  70.        
  71.         get_user_name( tempid, szName, charsmax( szName ) );
  72.        
  73.         new gMoney = cs_get_user_money( tempid );
  74.            
  75.         formatex( szAddItem, charsmax( szAddItem ), "\w%s \y[\d %i$ \y]", szName, gMoney );
  76.        
  77.         /*if ( id == tempid )
  78.             return PLUGIN_HANDLED;*/
  79.            
  80.         menu_additem( gMenu, szAddItem, szTempId );
  81.     }
  82.     menu_setprop( gMenu, MPROP_EXITNAME, "Close Menu" );
  83.     menu_setprop( gMenu, MPROP_PERPAGE, 6 );
  84.     menu_display( id, gMenu );
  85.     return PLUGIN_CONTINUE;
  86. }
  87. public subRequest( id, gMenu, gItem )
  88. {
  89.     new szData[ 6 ], iName[ 64 ];
  90.     new gAccess, gCallback;
  91.     menu_item_getinfo( gMenu, gItem, gAccess, szData, charsmax( szData ), iName, charsmax( iName ), gCallback );
  92.    
  93.     if( gItem == MENU_EXIT )
  94.     {
  95.         menu_destroy( gMenu );
  96.         return PLUGIN_HANDLED;
  97.     }
  98.     switch ( gItem )
  99.     {
  100.         case 0:
  101.         {
  102.             client_cmd( id, "messagemode _req_" );
  103.             return PLUGIN_HANDLED;
  104.         }
  105.     }
  106.     new tempid = str_to_num( szData );
  107.    
  108.     new szTempid[ 32 ], szName[ 32 ];
  109.     get_user_name( id, szName, charsmax( szName ) );
  110.     get_user_name( tempid, szTempid, charsmax( szTempid ) );
  111.    
  112.     //new gMoney = cs_get_user_money( id );
  113.     new iMoney = cs_get_user_money( tempid )
  114.     if ( AllowDonate[ tempid ] )
  115.     {
  116.         ColorChat( id, "This player does not^3 Allow Donation Requests^1!" );
  117.         cmdRequest( id )
  118.         return PLUGIN_HANDLED;
  119.     }
  120.     if ( gReq[ id ] > iMoney )
  121.     {
  122.         ColorChat( id, "The player you have chosen to request a donation from does ^3 Not^1 have this amount of^4 Money^1." );
  123.         cmdRequest( id );
  124.         return PLUGIN_HANDLED;
  125.     }
  126.     if ( !is_user_connected( tempid ) )
  127.     {
  128.         ColorChat( id, "The player you wish to request a donation from is^3 Not Connected^1." );
  129.         return PLUGIN_HANDLED;
  130.     }
  131.     ReqDonate( tempid, id );
  132.     menu_destroy( gMenu );
  133.     return PLUGIN_HANDLED;
  134. }
  135. public ReqDonate( tempid, id )
  136. {
  137.     new gTitle[ 128 ], szName[ 32 ];
  138.     get_user_name( id, szName, 32 );
  139.     formatex( gTitle, charsmax( gTitle ), "%s\w has requested you for a donation of:\r %d$^n\wDo you aceept?", szName, gReq[ id ] )
  140.     new gMenu = menu_create( gTitle, "subReq" );
  141.     menu_additem( gMenu, "Yes, I accept the donation request", "1" );
  142.     menu_additem( gMenu, "No, I decline the donation request", "2" );
  143.     menu_display( tempid, gMenu );
  144. }
  145. public subReq( client, gMenu, gItem )
  146. {
  147.     if ( gItem == MENU_EXIT )
  148.     {
  149.         menu_destroy( gMenu );
  150.         return PLUGIN_HANDLED;
  151.     }
  152.     new gData[ 6 ], iName[ 64 ];
  153.     new gAccess, gCallback;
  154.     menu_item_getinfo( gMenu, gItem, gAccess, gData, 5, iName, 63, gCallback );
  155.    
  156.     new szName[ 32 ], szName2[ 32 ], szKey[ 10 ], szClient[ 10 ];
  157.    
  158.     parse( gData, szKey, charsmax( szKey ), szClient, charsmax( szClient ) );
  159.     new id  = str_to_num( szClient );
  160.    
  161.     get_user_name( id, szName2, 31 );
  162.     get_user_name( client, szName, 31 );
  163.    
  164.     new gMoney = cs_get_user_money( client );
  165.     new iMoney = cs_get_user_money( id )
  166.    
  167.     switch( gItem )
  168.     {
  169.         case 1:
  170.         {
  171.             ColorChat( 0, "^4%s^1 has accepted the donation request from ^3%s^1 and transfered to him^4 %i$^1.", szName, szName2, gReq[ id ] );
  172.             cs_set_user_money( client, gMoney - gReq[ id ] );
  173.             cs_set_user_money( id, iMoney + gReq[ id ] );
  174.            
  175.         }
  176.         case 2:
  177.         {
  178.             ColorChat( id, "^4%s^1 has declined your donation request!" );
  179.         }
  180.     }
  181.     menu_destroy( gMenu );
  182.     return PLUGIN_HANDLED;
  183. }
  184. public RequestValue( id )
  185. {
  186.     new Arg[ 128 ];
  187.     read_args( Arg, charsmax( Arg ) );
  188.     remove_quotes( Arg );
  189.    
  190.     new g_Nums[ 1 ];
  191.     g_Nums[ 0 ] = str_to_num( Arg );
  192.    
  193.     new gMoney = cs_get_user_money( id );
  194.    
  195.     if (  !is_str_num( Arg ) )
  196.         return PLUGIN_HANDLED;
  197.    
  198.     if ( g_Nums[ 0 ] < 100 )
  199.     {
  200.         ColorChat( id, "The value of^3 money^1 must be greater than^4 100$" );
  201.         client_cmd(id, "messagemode _req_");
  202.         return PLUGIN_HANDLED;
  203.     }
  204.     if ( g_Nums[ 0 ] > 16000 )
  205.     {
  206.         ColorChat( id, "The value of^3 money^1 must be smaller than^4 16000$" );
  207.         client_cmd(id, "messagemode _req_");
  208.         return PLUGIN_HANDLED;
  209.     }
  210.     if ( g_Nums[ 0 ] > gMoney )
  211.     {
  212.         ColorChat( id, "You don't have this amount of money." );
  213.         client_cmd(id, "messagemode _req_");
  214.         return PLUGIN_HANDLED;
  215.     }
  216.     gReq[ id ] = g_Nums[ 0 ];
  217.     cmdRequest( id );
  218.     return PLUGIN_HANDLED;
  219. }  
  220. public cmdDonate( id )
  221. {
  222.     new players[ 32 ], pnum;
  223.     new szName[ 32 ], szTempId[ 3 ], gMenuItem[ 64 ], szAddItem[ 64 ];
  224.    
  225.     new gMenu = menu_create( "Donate to a Player Menu", "subDonate" );
  226.     formatex( gMenuItem, 63, "\yYou will donate:\r %d", gDonate[ id ] );
  227.     menu_additem( gMenu, gMenuItem, "0" );
  228.     get_players( players, pnum, "c" );
  229.     for( new i=0; i<pnum; i+=1 )
  230.     {
  231.         new tempid = players[ i ];
  232.         num_to_str( tempid, szTempId, charsmax( szTempId ) );
  233.        
  234.         get_user_name( tempid, szName, charsmax( szName ) );
  235.        
  236.         new gMoney = cs_get_user_money( tempid );
  237.            
  238.         formatex( szAddItem, charsmax( szAddItem ), "\w%s \y[\d %i$ \y]", szName, gMoney );
  239.        
  240.         if ( id == tempid )
  241.             return PLUGIN_HANDLED;
  242.            
  243.         menu_additem( gMenu, szAddItem, szTempId );
  244.     }
  245.     menu_setprop( gMenu, MPROP_EXITNAME, "Close Menu" );
  246.     menu_setprop( gMenu, MPROP_PERPAGE, 6 );
  247.     menu_display( id, gMenu );
  248.     return PLUGIN_CONTINUE;
  249. }
  250. public subDonate( id, gMenu, gItem )
  251. {
  252.     new szData[ 6 ], iName[ 64 ];
  253.     new gAccess, gCallback;
  254.     menu_item_getinfo( gMenu, gItem, gAccess, szData, charsmax( szData ), iName, charsmax( iName ), gCallback );
  255.    
  256.     if( gItem == MENU_EXIT )
  257.     {
  258.         menu_destroy( gMenu );
  259.         return PLUGIN_HANDLED;
  260.     }
  261.     switch ( gItem )
  262.     {
  263.         case 0:
  264.         {
  265.             client_cmd( id, "messagemode _donate_" );
  266.             return PLUGIN_HANDLED;
  267.         }
  268.     }
  269.     new tempid = str_to_num( szData );
  270.    
  271.     new szTempid[ 32 ], szName[ 32 ];
  272.     get_user_name( id, szName, charsmax( szName ) );
  273.     get_user_name( tempid, szTempid, charsmax( szTempid ) );
  274.    
  275.     new gMoney = cs_get_user_money( id );
  276.     new iMoney = cs_get_user_money( tempid )
  277.    
  278.     if ( gDonate[ id ] > gMoney )
  279.     {
  280.         ColorChat( id, "You don't have this amount of^4 money^1 to^3 donate^1." );
  281.         cmdDonate( id );
  282.         return PLUGIN_HANDLED;
  283.     }
  284.     if ( gDonate[ id ] <= 0 )
  285.     {
  286.         ColorChat( id, "You must type in number for the value^3 money^1. ");
  287.         cmdDonate( id );
  288.         return PLUGIN_HANDLED;
  289.     }
  290.     if ( !is_user_connected( tempid ) )
  291.     {
  292.         ColorChat( id, "The player you wish to donate to is^3 Not Connected^1." );
  293.         return PLUGIN_HANDLED;
  294.     }
  295.     cs_set_user_money( id, gMoney - gDonate[ id ] );
  296.     cs_set_user_money( tempid, iMoney + gDonate[ id ] );
  297.     ColorChat( 0, "^4%s^3 (^1%i^3)^1 just donated^3 %d$^1 to^4 %s^3 (^1%i^3)^1.", szName, gMoney, gDonate[ id ], szTempid, iMoney );
  298.     gDonate[ id ] = 0;
  299.     menu_destroy( gMenu );
  300.     return PLUGIN_HANDLED;
  301. }
  302. public DonateValue( id )
  303. {
  304.     new Arg[ 128 ];
  305.     read_args( Arg, charsmax( Arg ) );
  306.     remove_quotes( Arg );
  307.    
  308.     new g_Nums[ 1 ];
  309.     g_Nums[ 0 ] = str_to_num( Arg );
  310.    
  311.     new gMoney = cs_get_user_money( id );
  312.    
  313.     if (  !is_str_num( Arg ) )
  314.         return PLUGIN_HANDLED;
  315.    
  316.     if ( g_Nums[ 0 ] < 100 )
  317.     {
  318.         ColorChat( id, "The value of^3 money^1 must be greater than^4 100$" );
  319.         client_cmd(id, "messagemode _donate_");
  320.         return PLUGIN_HANDLED;
  321.     }
  322.     if ( g_Nums[ 0 ] > 16000 )
  323.     {
  324.         ColorChat( id, "The value of^3 money^1 must be smaller than^4 16000$" );
  325.         client_cmd(id, "messagemode _donate_");
  326.         return PLUGIN_HANDLED;
  327.     }
  328.     if ( g_Nums[ 0 ] > gMoney )
  329.     {
  330.         ColorChat( id, "You don't have this amount of money." );
  331.         client_cmd(id, "messagemode _donate_");
  332.         return PLUGIN_HANDLED;
  333.     }
  334.     gDonate[ id ] = g_Nums[ 0 ];
  335.     cmdDonate( id );
  336.     return PLUGIN_HANDLED;
  337. }
  338. stock ColorChat( const id, const string[], any:... )
  339. {
  340.     new msg[ 191 ], players[ 32 ], count = 1;
  341.    
  342.     static len; len = formatex( msg, charsmax( msg ), "^3[^4 Rage ^3]^1 " );
  343.     vformat( msg[ len ], charsmax( msg ) - len, string, 3 );
  344.    
  345.     if( id )  players[ 0 ] = id;
  346.    
  347.     else    get_players( players,count,"ch" );
  348.    
  349.     for ( new i = 0; i < count; i++ )
  350.     {
  351.         if( is_user_connected( players[ i ] ) )
  352.         {
  353.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, players[ i ] );
  354.             write_byte( players[ i ] );
  355.             write_string( msg );
  356.             message_end( );
  357.         }
  358.     }
  359. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement