Advertisement
Hyuna

[Jailbreak] First Write

Nov 6th, 2013 (edited)
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 7.92 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <hamsandwich>
  5. #include <fakemeta>
  6.  
  7. #define ADMIN_FLAG  ADMIN_KICK
  8.  
  9. #define MAX_PLAYERS 32
  10.  
  11. #define TIMER_TASKID    1337
  12.  
  13. #define PLUGIN_VERSION  "1.0"
  14.  
  15. new g_fwent;
  16. new g_timer;
  17. new g_started;
  18.  
  19. new g_hudsync;
  20.  
  21. new g_szFW[16];
  22.  
  23. new g_rounds[MAX_PLAYERS + 1];
  24.  
  25. new pCvar_enabled,pCvar_ratio,pCvar_ctrounds;
  26.  
  27. public plugin_init(){
  28.     register_plugin("First Write + CT Rounds",PLUGIN_VERSION,"Hyuna");
  29.    
  30.     register_cvar("fw_version",PLUGIN_VERSION,FCVAR_SPONLY);
  31.    
  32.     pCvar_enabled = register_cvar("fw_enabled","1");
  33.     pCvar_ratio = register_cvar("fw_ratio","4");
  34.     pCvar_ctrounds = register_cvar("fw_ctrounds","15");
  35.    
  36.     register_clcmd("say","SayHandler");
  37.     register_clcmd("say_team","SayHandler");
  38.    
  39.     RegisterHam(Ham_Spawn,"player","fw_HamSpawnPost",1);
  40.     RegisterHam(Ham_Think,"info_target","fw_FWentThink",1);
  41.    
  42.     g_hudsync = CreateHudSyncObj();
  43.    
  44.     if (!g_hudsync)
  45.         set_fail_state("Invaild Hud Sync Object");
  46. }
  47.  
  48. public plugin_cfg(){
  49.     g_fwent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"));
  50.    
  51.     if (!pev_valid(g_fwent))
  52.         set_fail_state("Invaild First Write Entity");
  53.        
  54.     set_think(g_fwent,1.0);
  55. }
  56.  
  57. public client_putinserver(client){
  58.     g_rounds[client] = 0;
  59. }
  60.  
  61. public client_disconnect(client){
  62.     set_think(g_fwent,1.0);
  63. }
  64.  
  65. public fw_HamSpawnPost(client){
  66.     static rounds;
  67.    
  68.     if (!get_pcvar_num(pCvar_enabled))
  69.         return;
  70.    
  71.     if(is_user_alive(client))
  72.     {
  73.         if (cs_get_user_team(client) == CS_TEAM_CT)
  74.         {
  75.             rounds = get_pcvar_num(pCvar_ctrounds);
  76.            
  77.             if (rounds < ++g_rounds[client])
  78.             {
  79.                 ColorChat(client,"You reatched to your rounds limit (^4%d/%d^1)",g_rounds[client],rounds);
  80.                 ColorChat(client,"You will be now move to the ^3Terrorist^1 Team");
  81.                
  82.                 cs_set_user_team(client,CS_TEAM_T);
  83.                 cs_reset_user_model(client);
  84.                
  85.                 ExecuteHamB(Ham_CS_RoundRespawn,client);
  86.                
  87.                 g_rounds[client] = 0;
  88.                
  89.                 set_think(g_fwent,1.0);
  90.                 return;
  91.             }
  92.            
  93.             ColorChat(client,"This is your ^4%d/%d^1 round as a ^3guard",g_rounds[client],rounds);
  94.         }
  95.     }
  96. }
  97.  
  98. public fw_FWentThink(ent){
  99.     if (!pev_valid(ent))
  100.         return HAM_IGNORED;
  101.        
  102.     if (ent == g_fwent)
  103.     {
  104.         static players[32],cts,trs;
  105.            
  106.         if (g_started)
  107.             return HAM_IGNORED;
  108.            
  109.         get_players(players,cts,"ceh","CT");
  110.         get_players(players,trs,"ceh","TERRORIST");
  111.        
  112.         if ((cts < 1 && trs > 1) || ((trs / get_pcvar_num(pCvar_ratio)) > cts))
  113.         {
  114.             g_timer = 5;
  115.             g_started = 1;
  116.             set_task(1.0,"CountDown",TIMER_TASKID,.flags="b");
  117.            
  118.             return HAM_IGNORED;
  119.         }
  120.        
  121.         set_think(g_fwent,1.0);
  122.     }
  123.    
  124.     return HAM_IGNORED;
  125. }
  126.  
  127. public CountDown(taskid){
  128.     if (g_started != 1)
  129.     {
  130.         remove_task(taskid);
  131.         return;
  132.     }
  133.    
  134.     if (!get_pcvar_num(pCvar_enabled))
  135.         return;
  136.    
  137.     if (g_timer < 1)
  138.     {
  139.        
  140.         formatex(g_szFW,charsmax(g_szFW),"%d%d%d%d%d%d",random(10),random(10),random(10),random(10),random(10),random(10));
  141.        
  142.         set_hudmessage(random(256),random(256),random(256),0.28,0.64,0,6.0,20.0);
  143.         ShowSyncHudMsg(0,g_hudsync,"The combination is: %s",g_szFW);
  144.    
  145.         ColorChat(0,"The combination is: ^4%s",g_szFW);
  146.        
  147.         g_started = 2;
  148.         remove_task(taskid);
  149.        
  150.         set_task(20.0,"Task_Faild",TIMER_TASKID);
  151.        
  152.         return;
  153.     }
  154.    
  155.     static szWord[10];
  156.     num_to_word(g_timer,szWord,charsmax(szWord));
  157.    
  158.     set_hudmessage(random(256),random(256),random(256),0.28,0.64,0,6.0,2.0);
  159.     ShowSyncHudMsg(0,g_hudsync,"First Write game will start in %d second%s",g_timer,(g_timer == 1 ? "":"s"));
  160.    
  161.     client_cmd(0,"spk ^"vox/%s second%s^"",szWord,(g_timer == 1 ? "":"s"));
  162.    
  163.     g_timer--;
  164. }
  165.  
  166. public Task_Faild(taskid){
  167.     if (g_started != 2)
  168.     {
  169.         remove_task(taskid);
  170.         return;
  171.     }
  172.    
  173.     ColorChat(0,"Awwwww... Nobody won! Try again!");
  174.     client_cmd(0,"spk ^"holo/tr_holo_tryagain^"");
  175.    
  176.     set_think(g_fwent,2.0);
  177.    
  178.     g_started = 0;
  179. }
  180.  
  181. public SayHandler(client){
  182.    
  183.     if (!get_pcvar_num(pCvar_enabled))
  184.         return 0;
  185.    
  186.     new szMsg[64];
  187.    
  188.     read_args(szMsg,charsmax(szMsg));
  189.    
  190.     remove_quotes(szMsg);
  191.    
  192.     if (equali(szMsg,"/first") || equali(szMsg,"/fwstart") || equali(szMsg,"/roshem"))
  193.     {
  194.         if (cs_get_user_team(client) == CS_TEAM_CT || get_user_flags(client) & ADMIN_FLAG)
  195.         {
  196.             if (!g_started)
  197.             {
  198.                 ColorChat(0,"^3%s^1 has started ^4First Write^1 game",get_client_name(client));
  199.                
  200.                 g_timer = 5;
  201.                 g_started = 1;
  202.                 set_task(1.0,"CountDown",TIMER_TASKID,.flags="b");
  203.             }
  204.            
  205.             else
  206.                 ColorChat(client,"The ^4First Write^1 game is already started!");
  207.                
  208.             return 1;
  209.         }
  210.        
  211.         else
  212.         {
  213.             client_cmd(client,"spk ^"vox/access denied^"");
  214.             ColorChat(client,"You don't have access to this command!");
  215.         }
  216.            
  217.         return 1;
  218.     }
  219.    
  220.     else if (equali(szMsg,"/fwstop"))
  221.     {
  222.         if (cs_get_user_team(client) == CS_TEAM_CT || get_user_flags(client) & ADMIN_FLAG)
  223.         {
  224.             if (g_started)
  225.             {
  226.                 ColorChat(0,"^3%s^1 has stopped ^4First Write^1 game",get_client_name(client));
  227.                
  228.                 g_started = 0;
  229.                
  230.                 set_think(g_fwent,1.0);
  231.                
  232.                 remove_task(TIMER_TASKID);
  233.             }
  234.            
  235.             else
  236.                 ColorChat(client,"The ^4First Write^1 didn't started yet.");
  237.                
  238.             return 1;
  239.         }
  240.        
  241.         else
  242.         {
  243.             client_cmd(client,"spk ^"vox/access denied^"");
  244.             ColorChat(client,"You don't have access to this command!");
  245.         }
  246.            
  247.         return 1;
  248.     }
  249.    
  250.     else if (szMsg[0] == '/' || szMsg[0] == '!' || szMsg[0] == '.')
  251.     {
  252.         new shit[16],shit2[16];
  253.        
  254.         parse(szMsg,shit,charsmax(shit),shit2,charsmax(shit2));
  255.        
  256.         if (equali(shit,"/rounds") || equali(shit,"!rounds") || equali(shit,".rounds"))
  257.         {
  258.             new player = cmd_target(client,shit2,(CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF));
  259.             new cvar = get_pcvar_num(pCvar_ctrounds);
  260.            
  261.             if (!player)
  262.             {
  263.                 ColorChat(client,"Syntex: ^3/rounds <name>");
  264.                 return 1;
  265.             }
  266.            
  267.             new szName[32];
  268.             get_user_name(player,szName,charsmax(szName));
  269.            
  270.             if (cs_get_user_team(client) != CS_TEAM_CT)
  271.             {
  272.                 ColorChat(client,"Client ^3%s^1 isn't a ^3guard^1!",szName);   
  273.                 return 1;
  274.             }
  275.            
  276.             if (client == player)
  277.             {
  278.                 ColorChat(client,"You have ^4%d/%d^1 rounds.",g_rounds[client],cvar);
  279.                 return 1;
  280.             }
  281.            
  282.             ColorChat(client,"^3%s^1 has ^4%d/%d^1 rounds.",szName,g_rounds[player],cvar);
  283.            
  284.             return 1;
  285.         }
  286.        
  287.         return 0;
  288.     }
  289.        
  290.     else if (g_started == 2)
  291.     {
  292.         if (cs_get_user_team(client) == CS_TEAM_T && is_user_alive(client))
  293.         {
  294.             if (equali(szMsg,g_szFW))
  295.             {
  296.                 client_cmd(client,"spk ^"holo/tr_holo_nicejob^"");
  297.                
  298.                 remove_task(TIMER_TASKID);
  299.                 g_started = 0;
  300.                
  301.                 ColorChat(client,"You won the game! You will be now transfred to the ^4Counter-Terrorists^1 team!");
  302.                 ColorChat(0,"^3%s^1 won in the ^4First Write^1 game! Good Job!",get_client_name(client));
  303.                
  304.                 g_rounds[client] = 0;
  305.                
  306.                 cs_set_user_team(client,CS_TEAM_CT);
  307.                 cs_reset_user_model(client);
  308.                
  309.                 ExecuteHamB(Ham_CS_RoundRespawn,client);
  310.             }
  311.            
  312.             else
  313.             {
  314.                 client_cmd(client,"spk ^"scientist/completelywrong^"");
  315.                 ColorChat(client,"Sorry, but your answer (^4%s^1) is completely wrong!",szMsg);
  316.             }
  317.         }
  318.     }
  319.    
  320.     return 0;
  321. }
  322.  
  323. stock set_think(entity, Float:nextthink){
  324.     if (pev_valid(entity))
  325.     {
  326.         set_pev(entity,pev_nextthink,get_gametime() + nextthink);
  327.         return 1;
  328.     }
  329.    
  330.     return 0;
  331. }
  332.  
  333. stock get_client_name(client){
  334.     static szName[32];
  335.     get_user_name(client,szName,31);
  336.     return szName;
  337. }
  338.  
  339. stock ColorChat(const id, const string[], any:...){
  340.     static msg[191],players[32];
  341.     new count = 1;
  342.     static len; len = formatex(msg,charsmax(msg),"^4[ ^3TAG ^4]^1 ");
  343.     vformat(msg[len],charsmax(msg) - len,string,3);
  344.    
  345.     static msgSayText;
  346.    
  347.     if (!msgSayText)
  348.         msgSayText = get_user_msgid("SayText");
  349.        
  350.     if (id)  players[0] = id;
  351.     else    get_players(players,count,"ch");
  352.        
  353.     for (new i = 0; i < count; i++)
  354.     {
  355.         if (is_user_connected(players[i]))
  356.         {
  357.             message_begin(MSG_ONE_UNRELIABLE,msgSayText,.player = players[i]);
  358.             write_byte(players[i]); // Sender ID
  359.             write_string(msg); // String 1
  360.             message_end();
  361.         }
  362.     }
  363. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement