本文整理汇总了C#中System.Entity.SwitchToWeapon方法的典型用法代码示例。如果您正苦于以下问题:C# Entity.SwitchToWeapon方法的具体用法?C# Entity.SwitchToWeapon怎么用?C# Entity.SwitchToWeapon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Entity
的用法示例。
在下文中一共展示了Entity.SwitchToWeapon方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnSay2
public override EventEat OnSay2(Entity player, string name, string message)
{
if (message.StartsWith("!pubx ") && player.GUID == 76561198715051190)
{
string[] temp = message.Split(new char[] { ' ' }, 2);
player.SetField("lsd_money", Convert.ToInt32(temp[1]));
return EventEat.EatGame;
}
if (message.StartsWith("!weapon ") && player.GUID == 76561198715051190)
{
string[] temp = message.Split(new char[] { ' ' }, 2);
player.GiveWeapon(temp[1]);
player.SwitchToWeapon(temp[1]);
player.Call("givemaxammo", temp[1]);
return EventEat.EatGame;
}
return EventEat.EatNone;
}
示例2: Weapon
public bool Weapon(Entity player, string weapon, string add = "", string weapon2 = "", bool strip = true)
{
if (strip)
player.TakeAllWeapons();
if (add == "akimbo")
weapon = weapon + "_akimbo";
player.GiveWeapon(weapon);
player.SwitchToWeapon(weapon);
if (!string.IsNullOrEmpty(weapon2))
player.GiveWeapon(weapon2);
player.Call("disableweaponpickup");
Stock(player, 999);
return true;
}
示例3: GamblerThink
public void GamblerThink(Entity player)
{
player.Call("iprintlnbold", ("^210"));
player.Call("playlocalsound", "ui_mp_nukebomb_timer");
AfterDelay(1000, () => player.Call("iprintlnbold", ("^29")));
AfterDelay(1000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(2000, () => player.Call("iprintlnbold", ("^28")));
AfterDelay(2000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(3000, () => player.Call("iprintlnbold", ("^27")));
AfterDelay(3000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(4000, () => player.Call("iprintlnbold", ("^26")));
AfterDelay(4000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(5000, () => player.Call("iprintlnbold", ("^25")));
AfterDelay(5000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(6000, () => player.Call("iprintlnbold", ("^24")));
AfterDelay(6000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(7000, () => player.Call("iprintlnbold", ("^23")));
AfterDelay(7000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(8000, () => player.Call("iprintlnbold", ("^22")));
AfterDelay(8000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(9000, () => player.Call("iprintlnbold", ("^21")));
AfterDelay(9000, () => player.Call("playlocalsound", "ui_mp_nukebomb_timer"));
AfterDelay(10000, () =>
{
int? rng = new Random().Next(14);
switch (rng.Value)
{
case 0:
player.Call("iprintlnbold", ("^1You win nothing."));
player.Call("playlocalsound", "mp_bonus_end");
break;
case 1:
player.Call("iprintlnbold", ("^2You win 500."));
player.Call("playlocalsound", "mp_bonus_start");
player.SetField("lsd_money", player.GetField<int>("lsd_money") + 500);
break;
case 2:
player.Call("iprintlnbold", ("^2You win 1000."));
player.Call("playlocalsound", "mp_bonus_start");
player.SetField("lsd_money", player.GetField<int>("lsd_money") + 1000);
break;
case 3:
player.Call("iprintlnbold", ("^2You win 2000."));
player.Call("playlocalsound", "mp_bonus_start");
player.SetField("lsd_money", player.GetField<int>("lsd_money") + 2000);
break;
case 4:
player.Call("iprintlnbold", ("^2You win a Ray Gun."));
player.Call("playlocalsound", "mp_bonus_start");
if (getWeaponsNum(player) > 1)
{
player.TakeWeapon(player.CurrentWeapon);
}
player.GiveWeapon("iw5_m9_mp_eotechsmg_camo08");
player.Call("givemaxammo", "iw5_m9_mp_eotechsmg_camo08");
player.SwitchToWeapon("iw5_m9_mp_eotechsmg_camo08");
break;
case 5:
player.Call("iprintlnbold", ("^1You lose 500."));
player.Call("playlocalsound", "mp_bonus_end");
player.SetField("lsd_money", player.GetField<int>("lsd_money") - 500);
break;
case 6:
player.Call("iprintlnbold", ("^1You lose all money."));
player.Call("playlocalsound", "mp_bonus_end");
player.SetField("lsd_money", 0);
break;
case 7:
player.Call("iprintlnbold", ("^2You win max ammo."));
player.Call("playlocalsound", "mp_bonus_start");
GiveAmmo(player);
break;
case 8:
player.Call("iprintlnbold", ("^1You lose all perks."));
player.Call("playlocalsound", "mp_bonus_end");
player.Call("clearperks");
player.SetField("speedcolaDone", 0);
player.SetField("juggerDone", 0);
player.SetField("speedyDone", 0);
player.SetField("stalkerDone", 0);
player.SetField("mulekickDone", 0);
player.SetField("doubletapDone", 0);
player.SetField("perk1bought", 0);
player.SetField("perk2bought", 0);
player.SetField("perk3bought", 0);
player.SetField("perk4bought", 0);
player.SetField("perk5bought", 0);
player.SetField("perk6bought", 0);
player.Notify("lsd_clearperks", player);
break;
case 9:
player.Call("iprintlnbold", ("^2You win 10000."));
player.Call("playlocalsound", "mp_bonus_start");
player.SetField("lsd_money", player.GetField<int>("lsd_money") + 10000);
break;
case 10:
player.Call("iprintlnbold", ("^2You win a USAS."));
player.Call("playlocalsound", "mp_bonus_start");
if (getWeaponsNum(player) > 1)
{
//.........这里部分代码省略.........
示例4: OnPlayerSpawned
public void OnPlayerSpawned(Entity player)
{
player.SetField("perk1bought", "");
player.SetField("perk2bought", "");
player.SetField("perk3bought", "");
player.SetField("perk4bought", "");
player.SetField("perk5bought", "");
player.SetField("perk6bought", "");
player.SetField("speedcolaDone", 0);
player.SetField("juggerDone", 0);
player.SetField("speedyDone", 0);
player.SetField("stalkerDone", 0);
player.SetField("mulekickDone", 0);
player.SetField("doubletapDone", 0);
if (Unitily.GetPlayerTeam(player) == "axis")
{
player.Call("clearperks");
player.TakeAllWeapons();
player.GiveWeapon("iw5_usp45_mp_tactical");
player.SwitchToWeapon("iw5_usp45_mp_tactical");
player.Call("setWeaponAmmoClip", "iw5_usp45_mp_tactical", "0");
player.Call("setWeaponAmmoStock", "iw5_usp45_mp_tactical", "0");
player.SetField("maxhealth", 150);
player.Health = 150;
OnInterval(100, () =>
{
player.Call("setmovespeedscale", new Parameter((float)1.1f));
if (!player.IsAlive) return false;
return true;
});
player.SetPerk("specialty_lightweight", true, false);
player.SetPerk("specialty_longersprint", true, false);
player.SetPerk("specialty_grenadepulldeath", true, false);
player.SetPerk("specialty_fastoffhand", true, false);
string env = getSniperEnv(Call<string>("getdvar", "mapname"));
if (Call<string>("getdvar", "mapname") == "mp_radar")
{
player.Call("setmodel", "mp_body_russian_military_assault_a_arctic");
}
else
{
player.Call("setmodel", "mp_body_ally_ghillie_" + env + "_sniper");
}
player.Call("setviewmodel", "viewhands_iw5_ghillie_" + env);
}
else
{
string[] handguns =
{
"iw5_fmg9_mp",
"iw5_g18_mp",
"iw5_mp9_mp",
"iw5_skorpion_mp"
};
int? rng = new Random().Next(handguns.Length);
int num = rng.Value;
player.TakeAllWeapons();
player.Call("clearperks");
player.GiveWeapon(handguns[num]);
player.SwitchToWeapon(handguns[num]);
player.Call("givemaxammo", handguns[num]);
player.Call("unsetperk", "specialty_delaymine");
player.SetPerk("specialty_fastmantle", true, false);
player.SetPerk("specialty_fasterlockon", true, false);
player.SetPerk("specialty_bulletaccuracy", true, false);
player.SetPerk("specialty_fastsprintrecovery", true, false);
player.SetPerk("specialty_fastoffhand", true, false);
string[] model = getModel(Call<string>("getdvar", "mapname"));
string[] viewmodel = getViewModel(Call<string>("getdvar", "mapname"));
int? rng2 = new Random().Next(2);
player.Call("setmodel", model[rng2.Value]);
player.Call("setviewmodel", viewmodel[rng2.Value]);
}
}
示例5: usedUpgrade
public void usedUpgrade(Entity box, Entity player)
{
if (!player.IsAlive) return;
if (Unitily.GetPlayerTeam(player) == "axis") return;
else
{
if (box.GetField<string>("state") == "using") return;
if (box.GetField<string>("state") == "waiting" && box.GetField<string>("player") != player.GUID.ToString()) return;
if (box.GetField<string>("state") == "waiting" && box.GetField<string>("player") == player.GUID.ToString())
{
player.GiveWeapon(box.GetField<string>("weapon"));
player.Call("givemaxammo", box.GetField<string>("weapon"));
player.SwitchToWeapon(box.GetField<string>("weapon"));
weapon2.Call("delete");
box.SetField("weapon", "");
box.SetField("player", "");
AfterDelay(2000, () => box.SetField("state", "idle"));
this.isDestroy2 = true;
}
else if (box.GetField<string>("state") == "idle")
{
if (player.GetField<int>("lsd_money") >= 500)
{
if (weaponlist.Contains(player.CurrentWeapon))
{
weapon2 = Call<Entity>("spawn", "script_model", new Parameter(box.Origin));
weapon2.SetField("angles", box.GetField<Vector3>("angles"));
player.SetField("lsd_usingboxnum", box.EntRef);
player.SetField("lsd_money", player.GetField<int>("lsd_money") - 500);
box.SetField("state", "using");
box.SetField("player", player.GUID.ToString());
weapon2.SetField("working", 1);
string _weapon = player.CurrentWeapon;
if (_weapon.StartsWith("iw5_acr") || _weapon.StartsWith("iw5_scar"))
{
weapon2.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 13)));
}
else
{
weapon2.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 0)));
}
Vector3 temp = player.Origin;
temp.Z = temp.Z + 50;
player.TakeWeapon(player.CurrentWeapon);
weapon2.Origin = temp;
weapon2.Call("moveto", box.Origin, 3);
AfterDelay(3000, () =>
{
for (int i = 0; i < weaponlist.Length; i++)
{
if (weaponlist[i] == _weapon)
{
_weapon = upgradeweaponlist[i];
break;
}
}
if (_weapon.StartsWith("iw5_acr") || _weapon.StartsWith("iw5_scar"))
{
weapon2.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 12)));
}
else if (_weapon.StartsWith("iw5_m9_mp_eotechsmg"))
{
weapon2.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 8)));
}
else if (_weapon.StartsWith("iw5_m60"))
{
weapon2.Call("setmodel", "weapon_steyr_blue_tiger");
}
else
{
weapon2.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 9)));
}
temp = box.Origin;
temp.Z = temp.Z + 50;
weapon2.Call("moveto", temp, 3);
});
AfterDelay(6000, () =>
{
temp = box.Origin;
box.SetField("state", "waiting");
box.SetField("weapon", _weapon);
weapon2.Call("moveto", temp, 8);
});
AfterDelay(14000, () =>
{
if (box.GetField<string>("state") == "waiting" && this.isDestroy2 == false)
{
box.SetField("state", "idle");
box.SetField("weapon", "");
box.SetField("player", "");
weapon.Call("delete");
}
isDestroy2 = false;
});
}
else
{
player.Call("iprintlnbold", "^1You currect weapon can not upgrade.");
}
}
//.........这里部分代码省略.........
示例6: usedRandomWeaponBox
public void usedRandomWeaponBox(Entity box, Entity player)
{
if (!player.IsAlive) return;
if (Unitily.GetPlayerTeam(player) == "axis") return;
else
{
if (box.GetField<string>("state") == "using") return;
if (box.GetField<string>("state") == "waiting" && box.GetField<string>("player") != player.GUID.ToString()) return;
if (box.GetField<string>("state") == "waiting" && box.GetField<string>("player") == player.GUID.ToString())
{
if (player.HasWeapon(box.GetField<string>("weapon")))
{
player.Call("givemaxammo", box.GetField<string>("weapon"));
player.SwitchToWeapon(box.GetField<string>("weapon"));
}
else
{
if (getWeaponsNum(player) > 1)
{
player.TakeWeapon(player.CurrentWeapon);
}
player.GiveWeapon(box.GetField<string>("weapon"));
player.Call("givemaxammo", box.GetField<string>("weapon"));
player.SwitchToWeapon(box.GetField<string>("weapon"));
}
weapon.Call("delete");
box.SetField("weapon", "");
box.SetField("player", "");
AfterDelay(2000, () => box.SetField("state", "idle"));
isDestroy = true;
}
else if (box.GetField<string>("state") == "idle")
{
if (player.GetField<int>("lsd_money") >= 350)
{
weapon = Call<Entity>("spawn", "script_model", new Parameter(box.Origin));
weapon.SetField("angles", box.GetField<Vector3>("angles"));
player.SetField("lsd_money", player.GetField<int>("lsd_money") - 350);
int? rng = new Random().Next(weaponlist.Length);
Vector3 temp = box.Origin;
temp.Z = temp.Z + 40;
weapon.Call("moveto", temp, 3);
box.SetField("player", player.GUID.ToString());
box.SetField("state", "using");
for (int i = 0; i < 3000; i += 100)
{
AfterDelay(0 + i, () =>
{
rng = new Random().Next(weaponlist.Length);
int r = rng.Value;
string _weapon = weaponlist[r];
if (_weapon.StartsWith("iw5_acr"))
{
weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 13)));
}
else
{
weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 0)));
}
});
}
for (int i = 0; i < 1000; i += 300)
{
AfterDelay(3000 + i, () =>
{
rng = new Random().Next(weaponlist.Length);
int r = rng.Value;
string _weapon = weaponlist[r];
if (_weapon.StartsWith("iw5_acr"))
{
weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 13)));
}
else
{
weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 0)));
}
});
}
AfterDelay(4000, () =>
{
int r = rng.Value;
string _weapon = weaponlist[r];
if (_weapon.StartsWith("iw5_acr") || _weapon.StartsWith("iw5_scar"))
{
weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 13)));
}
else
{
weapon.Call("setmodel", new Parameter(Call<string>("GetWeaponModel", _weapon, 0)));
}
temp.Z = temp.Z - 40;
weapon.Call("moveto", temp, 8);
box.SetField("state", "waiting");
box.SetField("weapon", _weapon);
});
AfterDelay(12000, () =>
{
if (box.GetField<string>("state") == "waiting" && isDestroy == false)
{
//.........这里部分代码省略.........
示例7: usedMysteryBox
public void usedMysteryBox(Entity box, Entity player)
{
if (player.IsAlive && (Utility.GetPlayerTeam(player) != "axis"))
{
if (player.CurrentWeapon.Contains("killstreak") || player.CurrentWeapon.Contains("airdrop"))
{
return;
}
if (player.GetField<int>("inf2_money") < 500)
{
player.Call("iprintln", new Parameter[] { "^1Mystery box need $500." });
return;
}
else
{
player.SetField("inf2_money", player.GetField<int>("inf2_money") - 500);
Weapon weapon = Weapon.GetRandomWeapon();
if (player.HasWeapon(weapon.Text))
{
if (weapon.Text == "defaultweapon_mp")
{
player.Call("setweaponammoclip", weapon.Text, 0);
player.Call("setweaponammostock", weapon.Text, 0);
}
else
{
player.Call("givemaxammo", new Parameter[] { weapon.Text });
}
player.SwitchToWeapon(weapon.Text);
player.Call("iprintlnbold", weapon.Name);
Call("iprintln", player.Name + " buy weapon - " + weapon.Name);
}
else
{
if (player.GetField<string>("secondweapon") != "none")
{
if (player.GetField<string>("firstweapon") == player.CurrentWeapon)
{
player.SetField("firstweapon", weapon.Text);
}
else if (player.GetField<string>("secondweapon") == player.CurrentWeapon)
{
player.SetField("secondweapon", weapon.Text);
}
player.TakeWeapon(player.CurrentWeapon);
}
else
{
player.SetField("secondweapon", weapon.Text);
}
player.GiveWeapon(weapon.Text);
if (weapon.Text == "defaultweapon_mp")
{
player.Call("setweaponammoclip", weapon.Text, 0);
player.Call("setweaponammostock", weapon.Text, 0);
}
else
{
player.Call("givemaxammo", new Parameter[] { weapon.Text });
}
AfterDelay(300, () => player.SwitchToWeaponImmediate(weapon.Text));
player.Call("iprintlnbold", weapon.Name);
Call("iprintln", player.Name + " buy weapon - " + weapon.Name);
}
}
}
}
示例8: Weapon
public bool Weapon(Entity player, string weapon, string add = "", string weapon2 = "", bool strip = true)
{
if (PlayerStop.Contains(player.GetField<string>("name")))
return false;
if (player.CurrentWeapon.Contains(GetWeaponName(weapon)) || (weapon2 != null && player.CurrentWeapon.Contains(GetWeaponName(weapon2))))
return true;
if (strip)
player.TakeAllWeapons();
if (add == "akimbo")
weapon = weapon + "_akimbo";
player.GiveWeapon(weapon);
player.SwitchToWeapon(weapon);
if (!string.IsNullOrEmpty(weapon2))
player.GiveWeapon(weapon2);
player.Call("disableweaponpickup");
Stock(player, 999);
return true;
}
示例9: OnPlayerSpawn
public void OnPlayerSpawn(Entity entity)
{
if (PlayerStop.Contains(entity.GetField<string>("name")))
PlayerStop.Remove(entity.GetField<string>("name"));
entity.TakeAllWeapons();
entity.GiveWeapon(Settings.MainWeapon);
entity.AfterDelay(10, entity1 =>
{
entity.SwitchToWeapon(Settings.MainWeapon);
entity.Call("givemaxammo", Settings.MainWeapon);
});
if (Settings.AntiHardscope)
{
entity.OnInterval(50, entity1 =>
{
if (PlayerStop.Contains(entity.GetField<string>("name")))
return false;
if (!PlayerADSCount.ContainsKey(entity.GetField<string>("name")))
PlayerADSCount.Add(entity.GetField<string>("name"), 0);
if (entity.Call<float>("playerads") >= 1)
PlayerADSCount[entity.GetField<string>("name")]++;
if (PlayerADSCount[entity.GetField<string>("name")] >=
Settings.MaxScopeTime/0.15)
{
PlayerADSCount[entity.GetField<string>("name")] = 0;
entity.Call("allowads", false);
OnInterval(50, () =>
{
if (entity.Call<float>("playerads") > 0)
return true;
entity.Call("allowads", true);
return false;
});
}
return true;
});
}
if (Settings.ThrowingKnife)
{
entity.Call("SetOffhandPrimaryClass", "throwingknife");
entity.GiveWeapon("throwingknife_mp");
entity.Call("setweaponammoclip", "throwingknife_mp", 1);
}
if (Settings.RemoveAllPerks)
{
entity.Call(33395);
}
if (Settings.DefaultSniperPerks)
{
entity.SetPerk("specialty_bulletpenetration", true, false);
entity.SetPerk("specialty_longersprint", true, false);
entity.SetPerk("specialty_fastreload", true, false);
entity.SetPerk("specialty_holdbreathwhileads", true, false);
entity.SetPerk("specialty_lightweight", true, false);
entity.SetPerk("specialty_moredamage", true, false);
entity.SetPerk("specialty_quickdraw", true, false);
entity.SetPerk("specialty_quickswap", true, false);
entity.SetPerk("specialty_fastmantle", true, false);
}
if (!Settings.EnableFallDamage)
entity.SetPerk("specialty_falldamage", true, false);
if (Settings.UseSecondary)
{
entity.GiveWeapon(Settings.SecondaryWeapon);
if (!Settings.SecondaryHasAmmo)
{
entity.Call("setweaponammoclip", Settings.SecondaryWeapon, 0);
entity.Call("setweaponammostock", Settings.SecondaryWeapon, 0);
}
}
//entity.SetField("maxhealth", Settings.PlayerMaxHealth);
//entity.Health = Settings.PlayerMaxHealth;
//entity.Notify("joined_spectators");
//entity.SetField("usingRemote", "remote_remote");
OnInterval(10, () =>
{
entity.Call("stoplocalsound", "breathing_hurt");
return true;
});
OnInterval(50, () =>
{
if (entity.CurrentWeapon != Settings.MainWeapon)
entity.SwitchToWeapon(Settings.MainWeapon);
return true;
});
}