AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   First round knife only & set money 0.. (https://forums.alliedmods.net/showthread.php?t=49359)

Healyrae 01-02-2007 12:53

First round knife only & set money 0..
 
Hi,

Ive been trying to modify some scripts ive found to do the following on my server.

1st round - Knives only ( Set players money to 0 to prevent buying )
2nd round - Pistols ( Set player money to 800 as a normal 1st round )
3rd round - Normal play

On restartround

Do the same as above.

Ive modded some code by iG_os that I found in these forums and added some code from a money give script. I know the set money 0 code is not in the script.

The problem i'm getting is on a new map the first player joins and the knife script kicks in, but when another player joins the server classes this as restart, the plugin then does a knife round but does not reset money at the end of this round.

This is not what I want because players are keeping the kill money from the knife round and beginning what I want to be a pistol round with MP5s and the like.

If anyone could help me sort this I would be very grateful!!!

Code:


#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define PLUGIN  "FirstRoundKnife"
#define VERSION "0.1"
#define AUTHOR  "iG_os"
 
new bool:FirstRound = true
new bool:SecondRound = false
new players[32], playerCount, i, player, pMoney;
 
public switchweapon(id)
{
  if (FirstRound)
  {
      engclient_cmd(id,"weapon_knife")
  }
  return PLUGIN_CONTINUE
}
 
public newround(id)
{
  if (SecondRound)
  {
  pMoney = 800
  get_players(players,playerCount);
 
  for(i=0;i<playerCount;i++)
      {
        player = players[i];
        {
        cs_set_user_money(player, pMoney);
        }
      }
  SecondRound = false
  }
  if (FirstRound)
  {
      set_task(3.0, "Mode_msg", id)
      SecondRound = true
  }
  return PLUGIN_CONTINUE
}
 
public restartround(){
  FirstRound = true
  return PLUGIN_CONTINUE
}
 
public end_round()
{
  FirstRound = false
  return PLUGIN_CONTINUE
}
 
public Mode_msg(id)
{
  new msg[64]
  format(msg,63,"Knife Round!")
  set_hudmessage(50, 255, 50, -1.0, 0.70, 0, 6.0, 10.0, 0.5, 0.15, -1)
  show_hudmessage(id,msg)
}
 
public plugin_init(){
  register_plugin(PLUGIN,VERSION,AUTHOR)
  register_event("ResetHUD", "newround", "be")
  register_event("TextMsg", "restartround", "a", "2&#Game_C", "2&#Game_w")
  register_event("SendAudio", "end_round", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
  register_event("CurWeapon", "switchweapon", "be", "1=1","2!29")
}


nerzon 10-29-2013 07:19

Re: First round knife only & set money 0..
 
have you deside the problem?
i'm trying to do this how:

Code:

new const PLUGIN[] = "Knife_round_1"
new const VERSION[] = "2.0"
new const AUTHOR[] = "jas0n & S.p.0_o.N"

new const g_HudMsgStart[] = "nepBbIu payHd Ha Ho}|{ax!"
new const g_HudMsgEnd[] = "3akynau opy}|{ee u B 6ou!"

new bool:g_IsKnifeRound
new bool:g_IsCommencing
new g_Mode, p_Mode
new g_Timer, p_Timer
new g_SyncMsgObj
new players[32], playerCount, i, player, pMoney;

public plugin_init()
{
        register_plugin(PLUGIN, VERSION, AUTHOR)

        register_event("TextMsg", "evGameCommencing", "a", "2=#Game_Commencing")
        register_event("CurWeapon", "evCurWeapon", "be", "1=1", "2!29")
        register_event("HLTV", "evNewRound", "a", "1=0", "2=0")
        register_logevent("evStartRound", 2, "1=Round_Start")
        register_logevent("evRestartRound", 2, "1&Restart_Round_")

        g_Mode = register_cvar("kr_mode", "1")
        g_Timer = register_cvar("kr_timer", "0")
        g_SyncMsgObj = CreateHudSyncObj()
}

public plugin_cfg() {
        p_Mode = get_pcvar_num(g_Mode)
        p_Timer = get_pcvar_num(g_Timer)
}

public evGameCommencing() {
        g_IsCommencing = true
}

public evNewRound() {
        if(!g_IsKnifeRound)
                return
       
        if(task_exists(348916))
                remove_task(348916)

          pMoney = 800
  get_players(players,playerCount);
 
  for(i=0;i<playerCount;i++)
      {
        player = players[i];
        {
        cs_set_user_money(player, pMoney);
        }
      }

        set_hudmessage(0, 225, 0, -1.0, 0.30, 2, 2.0, 6.0, _, _, -1)
        ShowSyncHudMsg(0, g_SyncMsgObj, g_HudMsgEnd)
               
        g_IsCommencing = false
        g_IsKnifeRound = false

        pause("ad")
}

public evStartRound() {
        if (!g_IsCommencing)
                return

        g_IsKnifeRound = true

        if (p_Timer >= 30)
                set_task(float(p_Timer), "evNewRound", 348916)

        set_hudmessage(0, 225, 0, -1.0, 0.30, 2, 2.0, 6.0, _, _, -1)
        ShowSyncHudMsg(0, g_SyncMsgObj, g_HudMsgStart)
}

public client_spawn(id) {
        if (!g_IsCommencing)
                return
       
        force_knife(id)
}

public evRestartRound() {
        if (!g_IsKnifeRound)
                return

        g_IsKnifeRound = false
}

public evCurWeapon(id) {
        if (!g_IsCommencing)
                return

        static weapon
        weapon = get_user_weapon(id)

        switch(p_Mode) {
                case 1: if (weapon == CSW_C4) return
                case 2: if (weapon == CSW_HEGRENADE || weapon == CSW_FLASHBANG || weapon == CSW_SMOKEGRENADE) return
                case 3: if (weapon == CSW_C4 || weapon == CSW_HEGRENADE || weapon == CSW_FLASHBANG || weapon == CSW_SMOKEGRENADE) return
        }

        force_knife(id)
}

force_knife(id)
{
        engclient_cmd(id, "weapon_knife")
}



All times are GMT -4. The time now is 22:19.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.