Advertisement
orayon

First Writes - not mine

May 3rd, 2020
410
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.25 KB | None | 0 0
  1. #include < amxmodx >
  2. #include < amxmisc >
  3. #include < cstrike >
  4. #include < hamsandwich >
  5. #include < ColorChat >
  6.  
  7. #define FW_ACCESS ADMIN_KICK
  8.  
  9. new CTRounds[33] = 0
  10.  
  11. new bool: FW_Started = false
  12. new FWTime
  13. new NumberSelected
  14.  
  15. new bool: haramod
  16.  
  17.  
  18.  
  19. public plugin_init()  
  20. {
  21.     register_clcmd("say","HandleSay")
  22.     RegisterHam(Ham_Spawn,"player","PlayerRespawned", 1)
  23.     set_task(10.0,"Ratio",_,_,_,"b")
  24.     register_clcmd("say /fwwin", "fwwin")
  25.    
  26.     haramod = true
  27. }
  28.  
  29. public Ratio()
  30. {
  31.     new CTCounter, TCounter
  32.     new players[32],pnum
  33.     get_players(players,pnum)
  34.     for(new i = 0;i<pnum;i++)
  35.     {
  36.         new cid = players[i]
  37.         switch(cs_get_user_team(cid))
  38.         {
  39.             case CS_TEAM_T:
  40.             {
  41.                 TCounter++
  42.             }
  43.             case CS_TEAM_CT:
  44.             {
  45.                 CTCounter++
  46.             }
  47.         }
  48.     }
  49.      
  50.      
  51.     if(CTCounter == 0 && TCounter >= 2)
  52.     {
  53.         StartFWRatio()
  54.     }
  55.     else if(CTCounter == 1 && TCounter >= 11)
  56.     {
  57.         StartFWRatio()
  58.     }
  59.     else if(CTCounter == 2 && TCounter >= 16)
  60.     {
  61.         StartFWRatio()
  62.     }
  63.     else if(CTCounter == 3 && TCounter >= 21)
  64.     {
  65.         StartFWRatio()
  66.     }
  67. }
  68.  
  69.  
  70. public PlayerRespawned(id)
  71. {
  72.     if(!is_user_alive(id))
  73.     {
  74.         return 1;
  75.     }
  76.     if(cs_get_user_team(id) == CS_TEAM_CT)
  77.     {
  78.         if(CTRounds[id] == 9)
  79.         {
  80.             cs_set_user_team(id,CS_TEAM_T)
  81.             ExecuteHamB(Ham_CS_RoundRespawn, id)
  82.             new szName[32];
  83.             get_user_name(id,szName,31)
  84.             ColorChat(0, 0,"^4[Extazza] ^3%s^1 his was^4 10 ^1rounds in CT.",szName)
  85.             CTRounds[id] = 0
  86.             StartFWRounds
  87.         }
  88.         else
  89.         {    
  90.             CTRounds[id]++
  91.             ColorChat(id, 0, "^4[Extazza] ^1You have been CT [^4%d^1/10] Rounds!",CTRounds[id])
  92.              
  93.         }
  94.     }
  95.     else
  96.     {
  97.         CTRounds[id] = 0
  98.     }
  99.     return 0;
  100. }
  101.  
  102. public HandleSay(id)
  103. {
  104.     new StrNumberSelected[22]
  105.     num_to_str(NumberSelected,StrNumberSelected,21)
  106.     new szMessage[128], szArg1[38],szArg2[38];
  107.     read_argv(1, szMessage, charsmax(szMessage));
  108.     parse(szMessage, szArg1, charsmax(szArg1),szArg2,charsmax(szArg2));
  109.     if(equali(szArg1,"/fw") || equali(szArg1,"/first")|| equali(szArg1,"!first") || equali(szArg1,"!fw"))
  110.     {
  111.         if(get_user_flags(id) & FW_ACCESS)
  112.         {
  113.             StartFW(id)
  114.         }
  115.     }
  116.     if(equali(szArg1,"/stopfw") || equali(szArg1,"!stopfw"))
  117.     {
  118.         if(get_user_flags(id) & FW_ACCESS)
  119.         {
  120.             StopFW(id)
  121.         }
  122.     }
  123.     if(FW_Started && ! ( haramod ) )
  124.     {
  125.         if(equali(szArg1,StrNumberSelected))
  126.         {
  127.             if(cs_get_user_team(id) == CS_TEAM_T)
  128.             {
  129.                 FW_Started = false
  130.                 set_hudmessage(0, 212, 255, -1.0, 0.28, 2, 0.02, 4.0, 0.01, 0.1, 1);  
  131.                 new szName[32]
  132.                 get_user_name(id,szName,31)
  133.                 if(is_user_alive(id))
  134.                 cs_set_user_team(id,CS_TEAM_CT);
  135.                 ExecuteHamB(Ham_CS_RoundRespawn, id)
  136.                 show_hudmessage(0,"%s, Won The First Write Contest! ^nAnd Moved To The Guards Team.",szName)
  137.                 ColorChat(0, 0,"^4[Extazza] ^3%s^4, Won The First Write!",szName)
  138.    
  139.             }
  140.             else
  141.             {
  142.                 ColorChat(id, 0,"^4[Extazza] ^1You are a^4 Guard^1 already!")
  143.             }
  144.         }
  145.     }
  146.     if(equali(szArg1,"/rounds"))
  147.     {
  148.         new player = cmd_target(id, szArg2, 0)
  149.         if(!(player))
  150.     {
  151.         ColorChat(id, 0, "^4[Extazza] ^1There is no player named^3 %s^1",szArg2)
  152.         return 1;
  153.     }
  154.     new szName[32]
  155.     get_user_name(player,szName,31)
  156.     if(cs_get_user_team(player) != CS_TEAM_CT)
  157.     {
  158.         ColorChat(id, 0, "^4[Extazza] ^1The player^3 %s^1 is not in CT team!",szName)
  159.         return 1;
  160.     }
  161. ColorChat(id, 0, "^4[Extazza] ^1The player^3 %s^1 Left^4 Rounds ^1[^4%d^1/10]^4 rounds!",szName,CTRounds[player])
  162.     }
  163.     return 0;
  164.      
  165. }
  166.  
  167. public StartFW(id)
  168. {
  169.     if(!FW_Started)
  170.     {
  171.         FW_Started = true
  172.         FWTime = 6
  173.         set_task(1.0,"CheckTime",1992,_,_,"b")
  174.         new szAdmin[32]
  175.         get_user_name(id,szAdmin,31)
  176.         ColorChat(0, 0, "^4[Extazza] ^1Admin^3 %s ^4started ^1the first writes",szAdmin)
  177.     }
  178.     else
  179.     {
  180.         ColorChat(id, 0, "^4[Extazza] ^1First writes is already ^4activated!")
  181.     }
  182.     return 1;
  183. }
  184. public StartFWRatio()
  185. {
  186.     if(!FW_Started)
  187.     {
  188.         FW_Started = true
  189.         FWTime = 6
  190.         set_task(1.0,"CheckTime",1992,_,_,"b")
  191.         ColorChat(0, 0, "^4[Extazza] ^1Auto^4 FirstWrite ^1started")
  192.     }
  193. }
  194. public StartFWRounds()
  195. {
  196.     if(!FW_Started)
  197.     {
  198.         FW_Started = true
  199.         FWTime = 9
  200.         set_task(1.0,"CheckTime",1992,_,_,"b")
  201.     }
  202. }
  203. public StopFW(id)
  204. {
  205.     if(FW_Started)
  206.     {
  207.         FW_Started = false
  208.          
  209.         new szName[32]
  210.         get_user_name(id,szName,31)
  211.         ColorChat(0, 0, "^4[Extazza] ^1Admin ^3%s ^4stopped ^1first writes!",szName)
  212.          
  213.     }
  214.     else
  215.     {
  216.          
  217.         ColorChat(id, 0, "^4[Extazza] ^1FirstWrite is not ^4activated!")
  218.     }
  219.     return 1;
  220. }
  221.  
  222. public CheckTime()
  223. {
  224.      
  225.     if(FWTime > 1)
  226.     {
  227.         if(FW_Started)
  228.         {
  229.             FWTime--
  230.             set_hudmessage(0, 212, 255, -1.0, 0.28, 2, 0.02, 4.0, 0.01, 0.1, 1);  
  231.             show_hudmessage(0,"The First Write Will Start In %d Seconds!",FWTime)
  232.             new Num[10]
  233.             num_to_word(FWTime,Num,9)
  234.             client_cmd(0,"spk fvox/%s",Num)
  235.         }
  236.         else
  237.         {
  238.             remove_task(1992)
  239.         }
  240.     }
  241.     else if(FWTime == 1)
  242.     {
  243.         FWTime--
  244.         haramod = false
  245.         set_hudmessage(0, 212, 255, -1.0, 0.28, 2, 0.02, 4.0, 0.01, 0.1, 1);  
  246.         NumberSelected = random_num(1,10000)
  247.         new szText[100]
  248.         formatex(szText,99,"The Chosen Number Is:^n[ %d ]",NumberSelected)
  249.         show_hudmessage(0,szText)
  250.         ColorChat(0, 0, "^4[Extazza] ^1The ^4Chosen ^1Number is:^4%d",NumberSelected)
  251.         remove_task(1992)
  252.     }
  253. }
  254.  
  255. public fwwin(id)
  256. {
  257.     if(!(get_user_flags(id) & ADMIN_KICK))
  258.     {
  259.         client_print(id, print_chat, "[Error] Sorry you don't have access to that command")
  260.         return
  261.     }
  262.         if(FW_Started == true)
  263.         {
  264.             if(cs_get_user_team(id) == CS_TEAM_T)
  265.             {
  266.                 FW_Started = false
  267.                 set_hudmessage(0, 212, 255, -1.0, 0.28, 2, 0.02, 4.0, 0.01, 0.1, 1);  
  268.                 new szName[32]
  269.                 get_user_name(id,szName,31)
  270.                 if(is_user_alive(id))
  271.                 cs_set_user_team(id,CS_TEAM_CT);
  272.                 ExecuteHamB(Ham_CS_RoundRespawn, id)
  273.                 show_hudmessage(0,"%s, Won The First Write Contest! ^nAnd Moved To The Guards Team.",szName)
  274.            ColorChat(0, 0, "^4[Extazza] ^3%s^4, Won The First Write!",szName)  
  275.         }
  276.     }
  277. }
  278.  
  279.  
  280. stock ColorChat( const client, const string[], any:... )
  281. {
  282.     new szMsg[ 191 ], Players[ 32 ], PNum = 1;
  283.    
  284.     static iLen; iLen = formatex( szMsg, charsmax( szMsg ), "^1[^4 %s^1 ] ", Info[ 4 ] );
  285.    
  286.     vformat( szMsg[ iLen ], charsmax( szMsg ) - iLen, string, 3 );
  287.    
  288.     if ( client )
  289.         Players[ 0 ] = client;
  290.    
  291.     else
  292.         get_players( Players, PNum, "ch" );
  293.    
  294.     for ( new i; i < PNum; i++ )
  295.     {
  296.         if( is_user_connected( Players[ i ] ) )
  297.         {
  298.             message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "SayText" ), _, Players[ i ] );
  299.            
  300.             write_byte( Players[ i ] );
  301.            
  302.             write_string( szMsg );
  303.            
  304.             message_end( );
  305.         }
  306.     }
  307.    
  308.     return 1;
  309. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement