Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #define CommunityName "Units-JUMP"
- #define ACCESS ADMIN_IMMUNITY
- #define AUTOTIME 300
- #define TopPlayers 3
- native get_user_cash(index);
- native set_user_cash(index, amount);
- new Timer, bool:bRandomStarted = false, Auto = AUTOTIME;
- public plugin_init() {
- register_plugin("Random Cash", "v1.3", "koko&Edgeee")
- register_clcmd("say /random", "RandomCash");
- register_clcmd("say /next", "NextRandom");
- register_clcmd("say /nextrandom", "NextRandom");
- set_task(1.0, "AutoRandom", 0,_,_, "b");
- set_task(220.0, "Knowing", 0,_,_, "b");
- }
- public RandomCash(id)
- {
- if(!(get_user_flags(id) & ACCESS))
- return ColorChat(id, "^1You have ^4no access ^1to this command.");
- if(bRandomStarted)
- return ColorChat(id, "^1The random cash ^4is already ^1staretd.");
- bRandomStarted = true;
- Timer = 6;
- ColorChat(0, "^1%s ^4just started ^1the ^4random cash^1.", GetName(id));
- set_task(1.0, "StartRandomCash", 0,_,_, "b");
- return 1;
- }
- public StartRandomCash()
- {
- Timer--;
- if(Timer > 0)
- {
- set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), 0.39, 0.21, 0, 6.0, 1.0)
- show_hudmessage(0, " Random Cash^nTime Left: %i seconds.", Timer)
- new Spk[10];
- num_to_word(Timer, Spk, charsmax(Spk));
- client_cmd(0, "spk vox/%s", Spk);
- }
- else
- {
- new Winner = get_randomplayer();
- new RandomAmount = random_num(1, 5800);
- set_user_cash(Winner, get_user_cash(Winner) + RandomAmount);
- set_hudmessage(random_num(1, 255), random_num(1, 255), random_num(1, 255), 0.39, 0.21, 0, 6.0, 10.0)
- show_hudmessage(0, " Winner: %s!^nHe just won: %i cash!", GetName(Winner), RandomAmount)
- ColorChat(0, "^1The Winner is ^4%s^1, and he won^4 %i cash^1. ", GetName(Winner), RandomAmount);
- bRandomStarted = false;
- remove_task(0);
- Auto = AUTOTIME;
- set_task(1.0, "AutoRandom", 0,_,_, "b");
- }
- }
- public AutoRandom()
- {
- new players[32], pnum;
- get_players(players, pnum, "ch");
- if(pnum <= TopPlayers)
- return 1;
- Auto--;
- if(Auto == 0)
- {
- bRandomStarted = true;
- Timer = 6;
- ColorChat(0, "^1The ^4random cash ^1has started.");
- set_task(1.0, "StartRandomCash", 0,_,_, "b");
- }
- return 1;
- }
- public NextRandom(id) {
- new players[32], pnum;
- get_players(players, pnum, "ch");
- if(pnum <= TopPlayers)
- return ColorChat(id, "^1The ^4random cash ^1start when there is ^4more then %i ^1players.", TopPlayers);
- if(bRandomStarted)
- return ColorChat(id, "^1The ^4random cash ^1already started.");
- ColorChat(id, "^1The ^4random cash ^1will start in:^4 %i seconds^1.", Auto);
- return 0;
- }
- public Knowing()
- ColorChat(0, "^1To see when the ^4next random cash ^1start, type ^4/next^1.");
- stock get_randomplayer()
- {
- static players[32], pnum;
- get_players(players, pnum, "ch");
- return players[random(pnum)];
- }
- stock GetName(id)
- {
- static szName[33];
- get_user_name(id, szName, charsmax(szName));
- return szName;
- }
- stock ColorChat(const id, const string[], {Float, Sql, Resul,_}:...) {
- new msg[191], players[32], count = 1
- new Community[30];
- formatex(Community, charsmax(Community), "^3[%s] ", CommunityName);
- static len
- len = formatex(msg, charsmax(msg), Community)
- vformat(msg[len], charsmax(msg) - len, string, 3)
- if(id) players[0] = id
- else get_players(players,count,"ch")
- for (new i = 0; i < count; i++)
- {
- if(is_user_connected(players[i]))
- {
- message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"),_, players[i])
- write_byte(players[i])
- write_string(msg)
- message_end()
- }
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement