Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <hamsandwich>
- #include <fakemeta>
- #define ADMIN_FLAG ADMIN_KICK
- #define MAX_PLAYERS 32
- #define TIMER_TASKID 1337
- #define PLUGIN_VERSION "1.0"
- new g_fwent;
- new g_timer;
- new g_started;
- new g_hudsync;
- new g_szFW[16];
- new g_rounds[MAX_PLAYERS + 1];
- new pCvar_enabled,pCvar_ratio,pCvar_ctrounds;
- public plugin_init(){
- register_plugin("First Write + CT Rounds",PLUGIN_VERSION,"Hyuna");
- register_cvar("fw_version",PLUGIN_VERSION,FCVAR_SPONLY);
- pCvar_enabled = register_cvar("fw_enabled","1");
- pCvar_ratio = register_cvar("fw_ratio","4");
- pCvar_ctrounds = register_cvar("fw_ctrounds","15");
- register_clcmd("say","SayHandler");
- register_clcmd("say_team","SayHandler");
- RegisterHam(Ham_Spawn,"player","fw_HamSpawnPost",1);
- RegisterHam(Ham_Think,"info_target","fw_FWentThink",1);
- g_hudsync = CreateHudSyncObj();
- if (!g_hudsync)
- set_fail_state("Invaild Hud Sync Object");
- }
- public plugin_cfg(){
- g_fwent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"));
- if (!pev_valid(g_fwent))
- set_fail_state("Invaild First Write Entity");
- set_think(g_fwent,1.0);
- }
- public client_putinserver(client){
- g_rounds[client] = 0;
- }
- public client_disconnect(client){
- set_think(g_fwent,1.0);
- }
- public fw_HamSpawnPost(client){
- static rounds;
- if (!get_pcvar_num(pCvar_enabled))
- return;
- if(is_user_alive(client))
- {
- if (cs_get_user_team(client) == CS_TEAM_CT)
- {
- rounds = get_pcvar_num(pCvar_ctrounds);
- if (rounds < ++g_rounds[client])
- {
- ColorChat(client,"You reatched to your rounds limit (^4%d/%d^1)",g_rounds[client],rounds);
- ColorChat(client,"You will be now move to the ^3Terrorist^1 Team");
- cs_set_user_team(client,CS_TEAM_T);
- cs_reset_user_model(client);
- ExecuteHamB(Ham_CS_RoundRespawn,client);
- g_rounds[client] = 0;
- set_think(g_fwent,1.0);
- return;
- }
- ColorChat(client,"This is your ^4%d/%d^1 round as a ^3guard",g_rounds[client],rounds);
- }
- }
- }
- public fw_FWentThink(ent){
- if (!pev_valid(ent))
- return HAM_IGNORED;
- if (ent == g_fwent)
- {
- static players[32],cts,trs;
- if (g_started)
- return HAM_IGNORED;
- get_players(players,cts,"ceh","CT");
- get_players(players,trs,"ceh","TERRORIST");
- if ((cts < 1 && trs > 1) || ((trs / get_pcvar_num(pCvar_ratio)) > cts))
- {
- g_timer = 5;
- g_started = 1;
- set_task(1.0,"CountDown",TIMER_TASKID,.flags="b");
- return HAM_IGNORED;
- }
- set_think(g_fwent,1.0);
- }
- return HAM_IGNORED;
- }
- public CountDown(taskid){
- if (g_started != 1)
- {
- remove_task(taskid);
- return;
- }
- if (!get_pcvar_num(pCvar_enabled))
- return;
- if (g_timer < 1)
- {
- formatex(g_szFW,charsmax(g_szFW),"%d%d%d%d%d%d",random(10),random(10),random(10),random(10),random(10),random(10));
- set_hudmessage(random(256),random(256),random(256),0.28,0.64,0,6.0,20.0);
- ShowSyncHudMsg(0,g_hudsync,"The combination is: %s",g_szFW);
- ColorChat(0,"The combination is: ^4%s",g_szFW);
- g_started = 2;
- remove_task(taskid);
- set_task(20.0,"Task_Faild",TIMER_TASKID);
- return;
- }
- static szWord[10];
- num_to_word(g_timer,szWord,charsmax(szWord));
- set_hudmessage(random(256),random(256),random(256),0.28,0.64,0,6.0,2.0);
- ShowSyncHudMsg(0,g_hudsync,"First Write game will start in %d second%s",g_timer,(g_timer == 1 ? "":"s"));
- client_cmd(0,"spk ^"vox/%s second%s^"",szWord,(g_timer == 1 ? "":"s"));
- g_timer--;
- }
- public Task_Faild(taskid){
- if (g_started != 2)
- {
- remove_task(taskid);
- return;
- }
- ColorChat(0,"Awwwww... Nobody won! Try again!");
- client_cmd(0,"spk ^"holo/tr_holo_tryagain^"");
- set_think(g_fwent,2.0);
- g_started = 0;
- }
- public SayHandler(client){
- if (!get_pcvar_num(pCvar_enabled))
- return 0;
- new szMsg[64];
- read_args(szMsg,charsmax(szMsg));
- remove_quotes(szMsg);
- if (equali(szMsg,"/first") || equali(szMsg,"/fwstart") || equali(szMsg,"/roshem"))
- {
- if (cs_get_user_team(client) == CS_TEAM_CT || get_user_flags(client) & ADMIN_FLAG)
- {
- if (!g_started)
- {
- ColorChat(0,"^3%s^1 has started ^4First Write^1 game",get_client_name(client));
- g_timer = 5;
- g_started = 1;
- set_task(1.0,"CountDown",TIMER_TASKID,.flags="b");
- }
- else
- ColorChat(client,"The ^4First Write^1 game is already started!");
- return 1;
- }
- else
- {
- client_cmd(client,"spk ^"vox/access denied^"");
- ColorChat(client,"You don't have access to this command!");
- }
- return 1;
- }
- else if (equali(szMsg,"/fwstop"))
- {
- if (cs_get_user_team(client) == CS_TEAM_CT || get_user_flags(client) & ADMIN_FLAG)
- {
- if (g_started)
- {
- ColorChat(0,"^3%s^1 has stopped ^4First Write^1 game",get_client_name(client));
- g_started = 0;
- set_think(g_fwent,1.0);
- remove_task(TIMER_TASKID);
- }
- else
- ColorChat(client,"The ^4First Write^1 didn't started yet.");
- return 1;
- }
- else
- {
- client_cmd(client,"spk ^"vox/access denied^"");
- ColorChat(client,"You don't have access to this command!");
- }
- return 1;
- }
- else if (szMsg[0] == '/' || szMsg[0] == '!' || szMsg[0] == '.')
- {
- new shit[16],shit2[16];
- parse(szMsg,shit,charsmax(shit),shit2,charsmax(shit2));
- if (equali(shit,"/rounds") || equali(shit,"!rounds") || equali(shit,".rounds"))
- {
- new player = cmd_target(client,shit2,(CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF));
- new cvar = get_pcvar_num(pCvar_ctrounds);
- if (!player)
- {
- ColorChat(client,"Syntex: ^3/rounds <name>");
- return 1;
- }
- new szName[32];
- get_user_name(player,szName,charsmax(szName));
- if (cs_get_user_team(client) != CS_TEAM_CT)
- {
- ColorChat(client,"Client ^3%s^1 isn't a ^3guard^1!",szName);
- return 1;
- }
- if (client == player)
- {
- ColorChat(client,"You have ^4%d/%d^1 rounds.",g_rounds[client],cvar);
- return 1;
- }
- ColorChat(client,"^3%s^1 has ^4%d/%d^1 rounds.",szName,g_rounds[player],cvar);
- return 1;
- }
- return 0;
- }
- else if (g_started == 2)
- {
- if (cs_get_user_team(client) == CS_TEAM_T && is_user_alive(client))
- {
- if (equali(szMsg,g_szFW))
- {
- client_cmd(client,"spk ^"holo/tr_holo_nicejob^"");
- remove_task(TIMER_TASKID);
- g_started = 0;
- ColorChat(client,"You won the game! You will be now transfred to the ^4Counter-Terrorists^1 team!");
- ColorChat(0,"^3%s^1 won in the ^4First Write^1 game! Good Job!",get_client_name(client));
- g_rounds[client] = 0;
- cs_set_user_team(client,CS_TEAM_CT);
- cs_reset_user_model(client);
- ExecuteHamB(Ham_CS_RoundRespawn,client);
- }
- else
- {
- client_cmd(client,"spk ^"scientist/completelywrong^"");
- ColorChat(client,"Sorry, but your answer (^4%s^1) is completely wrong!",szMsg);
- }
- }
- }
- return 0;
- }
- stock set_think(entity, Float:nextthink){
- if (pev_valid(entity))
- {
- set_pev(entity,pev_nextthink,get_gametime() + nextthink);
- return 1;
- }
- return 0;
- }
- stock get_client_name(client){
- static szName[32];
- get_user_name(client,szName,31);
- return szName;
- }
- stock ColorChat(const id, const string[], any:...){
- static msg[191],players[32];
- new count = 1;
- static len; len = formatex(msg,charsmax(msg),"^4[ ^3TAG ^4]^1 ");
- vformat(msg[len],charsmax(msg) - len,string,3);
- static msgSayText;
- if (!msgSayText)
- msgSayText = get_user_msgid("SayText");
- 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,msgSayText,.player = players[i]);
- write_byte(players[i]); // Sender ID
- write_string(msg); // String 1
- message_end();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement