Added replace_weapon_on_spawn

This commit is contained in:
Resxt 2022-02-21 19:35:49 +01:00
parent bd0b0072b8
commit 1d8dbaf732
2 changed files with 75 additions and 0 deletions

View File

@ -0,0 +1,10 @@
# Replace Weapon On Spawn
A script to replace players weapon when they spawn.
This can easily be modified to always give a certain weapon or only give it when the player has a certain weapon etc.
This is useful to add ported weapons like the Intervention to your default classes until Plutonium adds the possibility to do it directly in dsr files.
## replace_rsass_with_intervention.gsc
Replace the RSASS with an Intervention (ACOG sight)
Replace the RSASS silencer with an Intervention (ACOG sight + silencer)
Gives a throwing knife and a tactical insertion in both cases

View File

@ -0,0 +1,65 @@
Init()
{
level thread OnPlayerConnect();
}
OnPlayerConnect()
{
for(;;)
{
level waittill("connected", player);
player thread OnPlayerSpawned();
}
}
OnPlayerSpawned()
{
self endon("disconnect");
for(;;)
{
self waittill("spawned_player");
current_weapon = self GetCurrentWeapon();
self thread DoWeaponCheck(current_weapon);
}
}
DoWeaponCheck(current_weapon)
{
self endon("death");
self endon("disconnect");
level endon("game_ended");
//Debug(current_weapon);
if (current_weapon == "iw5_rsass_mp_rsassscope")
{
ReplaceWeapon("iw5_cheytac_mp_acog");
GiveLethalAndTactical();
}
else if (current_weapon == "iw5_rsass_mp_rsassscope_silencer03")
{
ReplaceWeapon("iw5_cheytac_mp_acog_silencer03");
GiveLethalAndTactical();
}
}
ReplaceWeapon(new_weapon)
{
self TakeAllWeapons();
self GiveWeapon(new_weapon);
self SetSpawnWeapon(new_weapon); // This gives the weapon without playing the animation
}
// TakeAllWeapons() removes lethal and tactical as well so we give default items after calling it
GiveLethalAndTactical()
{
self GiveWeapon("throwingknife_mp"); // Found in dsr files
self GiveWeapon("flare_mp"); // Tactical insertion - found in common_mp.ff
}
// Prints text in the bootstrapper
Debug(text)
{
Print(text);
}