Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Plugin generated by Top Jailbreak-Studio */
- #include <amxmodx>
- #include <amxmisc>
- #include <fvault>
- #include <ColorChat>
- #define Price 7500
- #define MaxTickets 150
- #define CD_TASK 101
- new Tickets[33],Running[33],CD[33],PrizeAmount[33],u_All[33];
- native get_user_cash(index)
- native set_user_cash(index,amount)
- public client_connect( id )
- CmdLoad(id)
- public client_disconnect( id )
- CmdSave(id)
- new szVault[] = "luckycardfixeda";
- public plugin_init() {
- register_plugin("Lucky Ticket","1.0","Built by MJ || Edit by @.TheBomB`")
- register_clcmd("say /luckyticket","LuckyMenu");
- register_clcmd("say /luckycard","LuckyMenu");
- register_clcmd("say /lucky","LuckyMenu");
- register_concmd("amx_add_tickets","AddCmd");
- register_concmd("amx_set_tickets","SetCmd");
- register_concmd("amx_remove_tickets","RemoveCmd");
- register_concmd("amx_reset_tickets","ResetCmd");
- }
- public plugin_precache()
- {
- precache_sound("Top/JB/Bigwin.wav");
- }
- public plugin_natives()
- {
- register_native("get_user_tickets","_get_user_tickets");
- register_native("set_user_tickets","_set_user_tickets");
- }
- public _get_user_tickets(plugin,param)
- {
- new index = get_param(1);
- return Tickets[index];
- }
- public _set_user_tickets(plugin,param)
- {
- new index = get_param(1);
- new Amount = get_param(2);
- Tickets[index] = Amount;
- return Tickets[index];
- }
- //CallBacks
- public buycb(id)
- {
- if(get_user_cash(id) < Price || Tickets[id] > 149)
- return ITEM_DISABLED;
- return ITEM_ENABLED;
- }
- public buy10cb(id)
- {
- if(get_user_cash(id) < Price*10|| Tickets[id] > 140 || !(get_user_flags(id) & ADMIN_LEVEL_C))
- return ITEM_DISABLED;
- return ITEM_ENABLED;
- }
- public buy100cb(id)
- {
- if(get_user_cash(id) < Price*100|| Tickets[id] > 50 || !(get_user_flags(id) & ADMIN_LEVEL_C))
- return ITEM_DISABLED;
- return ITEM_ENABLED;
- }
- public usecb(id)
- {
- if((Tickets[id] < 1) || Running[id])
- return ITEM_DISABLED;
- return ITEM_ENABLED;
- }
- public fastusecb(id)
- {
- if((Tickets[id] < 1) || Running[id] || !(get_user_flags(id) & ADMIN_LEVEL_C))
- return ITEM_DISABLED;
- return ITEM_ENABLED;
- }
- //End CallBacks
- //Menu
- public LuckyMenu (id)
- {
- new Info[512];
- formatex(Info,charsmax(Info),"Lucky Card\y Menu\w^nYour cash:\y %i\w^nYour tickets:\y %i\d/\r150^n\wBiggest Won: \y500,000",get_user_cash(id),Tickets[id]);
- new hMenu = menu_create(Info,"LuckyHandler");
- new bcb = menu_makecallback("buycb");
- new b1cb = menu_makecallback("buy10cb");
- new b10cb = menu_makecallback("buy100cb");
- new ucb = menu_makecallback("usecb");
- new fucb = menu_makecallback("fastusecb");
- menu_additem(hMenu,"\yBuy \wTicket \r(\y7,500\w cash\r)",.callback=bcb);
- menu_additem(hMenu,"\yUse \wTicket",.callback=ucb);
- menu_additem(hMenu,"\ySell\w Tickets \r(\wfor \y5,000\w cash\r)^n^n\d- \rPremium Gets:",.callback=ucb);
- menu_additem(hMenu,"\yBuy \w10 Tickets \r(\y75,000\w cash\r)",.callback=b1cb);
- menu_additem(hMenu,"\yBuy \w100 Tickets \r(\y750,000\w cash\r)",.callback=b10cb);
- menu_additem(hMenu,"\yFast Use \wTicket",.callback=fucb);
- menu_additem(hMenu,"\yUse \wAll Tickets",.callback=fucb);
- menu_display(id,hMenu);
- return 1;
- }
- public LuckyHandler (id,hMenu,Item)
- {
- new sellticket = 5000
- switch (Item)
- {
- case MENU_EXIT: menu_destroy(hMenu);
- case 0:
- {
- if(get_user_cash(id) < Price) return 1;
- Tickets[id] ++;
- set_user_cash(id,get_user_cash(id) -Price)
- return LuckyMenu(id);
- }
- case 1:
- {
- if ((Tickets[id] < 1) || Running[id]) return 1;
- Tickets[id] --;
- Running[id] = true;
- CD[id] = 5;
- StartLotto(id);
- return LuckyMenu(id);
- }
- case 2:
- {
- if ((Tickets[id] < 1)) return 1;
- Tickets[id] --;
- set_user_cash(id, get_user_cash(id) + sellticket);
- return LuckyMenu(id);
- }
- case 3:
- {
- if(get_user_cash(id) < Price*10) return 1;
- Tickets[id] +=10;
- set_user_cash(id,get_user_cash(id) -Price*10)
- return LuckyMenu(id);
- }
- case 4:
- {
- if(get_user_cash(id) < Price*100) return 1;
- Tickets[id] +=100;
- set_user_cash(id,get_user_cash(id) -Price*100)
- return LuckyMenu(id);
- }
- case 5:
- {
- if ((Tickets[id] < 1) || Running[id]) return 1;
- Tickets[id] --;
- Running[id] = true;
- CD[id] = 0;
- StartLotto(id);
- return LuckyMenu(id);
- }
- case 6:
- {
- if ((Tickets[id] < 1) || Running[id]) return 1;
- Running[id] = true;
- CD[id] = 3;
- u_All[id] = true;
- StartLotto(id);
- return LuckyMenu(id);
- }
- }
- return 1;
- }
- //Prize Chance
- public CheckPrize (id)
- {
- new Number[33];
- Number[id] = random_num(1,100)
- if (Number[id] > 0 && Number[id] < 26)
- PrizeAmount[id] = random_num(0,500);
- if (Number[id] > 25 && Number[id] < 46)
- PrizeAmount[id] = random_num(500,1000);
- if (Number[id] > 45 && Number[id] < 66)
- PrizeAmount[id] = random_num(1000,3000);
- if (Number[id] > 65 && Number[id] < 86)
- PrizeAmount[id] = random_num(3000,5000);
- if (Number[id] > 80 && Number[id] < 91)
- PrizeAmount[id] = random_num(5000,15000);
- if (Number[id] > 90 && Number[id] < 95)
- PrizeAmount[id] = random_num(15000,30000);
- if(Number[id] > 94 && Number[id] < 99)
- PrizeAmount[id] = random_num(30000,50000);
- if(Number[id] > 98 && Number[id] < 100)
- PrizeAmount[id] = random_num(50000,150000);
- if(Number[id] == 100)
- {
- new Chance[33];
- Chance[id] = random_num(1,4)
- if (Chance[id] == 1)
- {
- PrizeAmount[id] = 500000;
- client_cmd(0,"spk Top/JB/Bigwin.wav");
- }
- else
- PrizeAmount[id] = random_num(50000,150000);
- }
- return PrizeAmount[id];
- }
- //Prize Messages
- public StartLotto(id)
- {
- new t_Prize[33];
- if(CD[id] < 1)
- {
- set_hudmessage(21, 157, 144, -1.0, 0.20, 1, 6.0, 15.0,_,_,4)
- if (u_All[id])
- {
- new times[33];
- for(new i; i < Tickets[id]; i++)
- {
- CheckPrize(id);
- times[id] ++;
- t_Prize[id] += CheckPrize(id);
- continue;
- }
- Tickets[id] = 0;
- if(times[id] > 1)
- ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^3Premium %s ^1has won ^3%d ^1cash from ^3%d ^4Lucky Tickets^1 ^1(%s%d Cash).",get_name(id),t_Prize[id],times[id],t_Prize[id]-(times[id]*Price) > 0 ? "+" : "" ,t_Prize[id]-(times[id]*Price));
- else
- ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] You ^1have won ^3%d ^1cash from ^3%d ^4Lucky Tickets^1 ^1(%s%d Cash).",t_Prize[id],times[id],t_Prize[id]-(times[id]*Price) > 0 ? "+" : "",t_Prize[id]-(times[id]*Price));
- u_All[id] = false;
- }
- else
- {
- CheckPrize(id);
- show_hudmessage(id, "Congratulation, You won %d Cash!",PrizeAmount[id]);
- if (PrizeAmount[id] > 49999 && !u_All[id])
- ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] %s ^1has won ^3%d ^1cash from the ^4Lucky Ticket^1.",get_name(id),PrizeAmount[id]);
- if (PrizeAmount[id] < 49999 && !u_All[id])
- ColorChat(id,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] You ^1have won ^3%d ^1cash from the ^4Lucky Ticket^1.",PrizeAmount[id]);
- t_Prize[id] = PrizeAmount[id];
- }
- set_user_cash(id,get_user_cash(id)+t_Prize[id])
- remove_task(id);
- Running[id] = false;
- return 1;
- }
- new szVox[10];
- set_hudmessage(21, 157, 144, -1.0, 0.20, 1, 6.0, 3.0,_,_,4)
- show_hudmessage(id, "You will get your prize amount in %d seconds",CD[id] );
- num_to_word( CD[id], szVox, charsmax( szVox ) );
- client_cmd( id, "spk ^"vox/%s^"", szVox );
- CD[id]--;
- set_task(1.0,"StartLotto",id);
- return 1;
- }
- //Cmds Add/Set/Remove/Save Tickets
- public AddCmd(id)
- {
- if(!(get_user_flags(id) & ADMIN_IMMUNITY)) return 1;
- new Args[128],aTarget[32],aTicket[32];
- read_args(Args,charsmax(Args));
- remove_quotes( Args );
- parse( Args,aTarget, charsmax( aTarget ), aTicket,charsmax( aTicket ) );
- if( equali( aTarget, "" ) || equali( aTicket, "" ) )
- return console_print(id,"Usage: amx_add_tickets <Nick> <Tickets>");
- new iPlayer = cmd_target( iPlayer, aTarget,8);
- if(!is_str_num(aTicket))
- return console_print(id,"You need to fill numbers in the Tickets Amount");
- if(!iPlayer)
- return console_print(id,"The Player has not found");
- new iTicket = str_to_num( aTicket );
- if( iTicket < 1)
- return console_print(id,"The Minimum of the value to add ticket is 1");
- if( iTicket > 150)
- return console_print(id,"The Maximum of the value to add ticket is 150");
- Tickets[iPlayer] += iTicket;
- ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^1Admin: ^4%s ^1has ^3added ^4%d ^1lucky tickets to the player ^4%s",get_name(id),iTicket,get_name(iPlayer));
- if (Tickets[iPlayer] > 150)
- Tickets[iPlayer] = 150;
- return 1;
- }
- public RemoveCmd(id)
- {
- if(!(get_user_flags(id) & ADMIN_IMMUNITY)) return 1;
- new Args[128],aTarget[32],aTicket[32];
- read_args(Args,charsmax(Args));
- remove_quotes( Args );
- parse( Args,aTarget, charsmax( aTarget ), aTicket,charsmax( aTicket ) );
- if( equali( aTarget, "" ) || equali( aTicket, "" ) )
- return console_print(id,"Usage: amx_remove_tickets <Nick> <Tickets>");
- new iPlayer = cmd_target( iPlayer, aTarget,8);
- if(!is_str_num(aTicket))
- return console_print(id,"You need to fill numbers in the Tickets Amount");
- if(!iPlayer)
- return console_print(id,"The Player has not found");
- new iTicket = str_to_num( aTicket );
- if( iTicket < 1)
- return console_print(id,"The Minimum of the value to remove ticket is 1");
- if( iTicket > 150)
- return console_print(id,"The Maximum of the value to remove ticket is 150");
- Tickets[iPlayer] -= iTicket;
- ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^1Admin: ^4%s ^1has ^3removed ^4%d ^1lucky tickets to the player ^4%s",get_name(id),iTicket,get_name(iPlayer));
- if (Tickets[iPlayer] < 0)
- Tickets[iPlayer] = 0;
- return 1;
- }
- public SetCmd(id)
- {
- if(!(get_user_flags(id) & ADMIN_IMMUNITY)) return 1;
- new Args[128],aTarget[32],aTicket[32];
- read_args(Args,charsmax(Args));
- remove_quotes( Args );
- parse( Args,aTarget, charsmax( aTarget ), aTicket,charsmax( aTicket ) );
- if( equali( aTarget, "" ) || equali( aTicket, "" ) )
- return console_print(id,"Usage: amx_set_tickets <Nick> <Tickets>");
- new iPlayer = cmd_target( iPlayer, aTarget,8);
- if(!is_str_num(aTicket))
- return console_print(id,"You need to fill numbers in the Tickets Amount");
- if(!iPlayer)
- return console_print(id,"The Player has not found");
- new iTicket = str_to_num( aTicket );
- if( iTicket < 0)
- return console_print(id,"The Minimum of the value to set ticket is 0");
- if( iTicket > 150)
- return console_print(id,"The Maximum of the value to set ticket is 150");
- Tickets[iPlayer] = iTicket;
- ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^1Admin: ^4%s ^1has ^3setted ^4%d ^1lucky tickets to the player ^4%s",get_name(id),iTicket,get_name(iPlayer));
- return 1;
- }
- public ResetCmd(id)
- {
- for (new i; i < get_maxplayers(); i++)
- {
- if(!is_user_connected(i)) continue;
- Tickets[i] = 5;
- }
- ColorChat(0,TEAM_COLOR,"^4[ ^1Top Jailbreak ^4] ^1Admin: ^4%s ^1has ^3resetted ^4all online players ^1lucky tickets to^4 5",get_name(id));
- return 1;
- }
- public CmdSave(id)
- {
- new szData[ 100 ],szAuth[ 60 ];
- formatex(szAuth,charsmax(szAuth),"%s",GetAuth(id))
- formatex( szData, charsmax( szData ), "%d", Tickets[ id ] );
- fvault_set_data( szVault,szAuth, szData );
- return 1;
- }
- public CmdLoad(id)
- {
- // cash
- new sztData[ 100 ],szAuth[ 60 ];
- formatex(szAuth,charsmax(szAuth),"%s",GetAuth(id))
- // tickets
- if( ! ( fvault_get_data( szVault, szAuth, sztData, charsmax( sztData ) ) ) )
- {
- fvault_set_data( szVault, szAuth, "2" );
- Tickets[ id ] = 2;
- }
- else
- Tickets[ id ] = str_to_num( sztData );
- }
- //Stocks
- stock get_name(index)
- {
- new szName[32];
- get_user_name(index,szName,charsmax(szName))
- return szName;
- }
- 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement