Raised This Month: $ Target: $400
 0% 

Remove All Weapons / Give Weapon On Round Start


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
deltadude
SourceMod Donor
Join Date: Mar 2010
Old 12-09-2012 , 23:16   Remove All Weapons / Give Weapon On Round Start
Reply With Quote #1

Looking for a plugin that will remove all weapons / give a certain weapon to replace it, and have it running active throughout the game so players who join midway do not receive all weapons.

__________________
deltadude is offline
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 12-10-2012 , 16:57   Re: Remove All Weapons / Give Weapon On Round Start
Reply With Quote #2

This should work:
PHP Code:
#include <sourcemod>
#include <smlib>

// If you use this please give me the credit :D

public Plugin:myinfo 
{
    
name "Remove Weapons",
    
author "Marcus",
    
description "Removes a players' weaopon(s) on spawn",
    
version "0.0.2",
    
url "http://www.sourcemod.net"
};

public 
OnPluginStart()
{
    
HookEvent("player_spawn"Event_Spawn);
    
HookEvent("round_start"Event_Start);
}

public 
Action:Event_Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
GetClientOfUserId(GetEventInt(event"userid"));
    
RemoveWeapons(i)

}

public 
Action:Event_Start(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
GetClientOfUserId(GetEventInt(event"userid"));
    
RemoveWeapons(i)
}

RemoveWeapons(client)
{
    new 
team GetClientTeam(client);
    
    
Client_RemoveAllWeapons(client""true); // Removes all the weapons ; Add a weapon name into the "" to exclude that weapon.
    
if( team != && team == // Checks if the player is not a spectator and if the player is on Red Team
    
{
        
Client_GiveWeaponAndAmmo(client"weapon_glock"true90); // Change weapon_glock to the weapon you want. 90 is the amount of ammo given.
        
Client_GiveWeaponAndAmmo(client"weapon_ak47"true90); // Change weapon_ak47 to the weapon you want.
    
} else if ( team != && team == 3// Checks if the player is not a spectator and if the player is on the Blu Team
    
{
        
Client_GiveWeaponAndAmmo(client"weapon_p228"true90); // Change weapon_p228 to the weapon you want. 90 is the amount of ammo given.
        
Client_GiveWeaponAndAmmo(client"weapon_m4a1"true90); // Change weapon_m4a1 to the weapon you want.
    
}
    

As said in the comments, change the weapon names to what ever you want for whichever game you are using. If you want to add more weapons you can simply copy the Client_GiveWeaponAndAmmo line and change the new one to a different weapon name. Lemme know if you something done to this! You do need to have SourceMod Library to compile this ( Download Here: http://www.sourcemodplugins.org/bund...smlib_0.11.zip ) .

Last edited by Marcus_Brown001; 12-11-2012 at 00:03.
Marcus_Brown001 is offline
deltadude
SourceMod Donor
Join Date: Mar 2010
Old 12-10-2012 , 20:34   Re: Remove All Weapons / Give Weapon On Round Start
Reply With Quote #3

Mk, working with tf2, is there a way to specify teams? or have it so it give weapons on round start as well as spawn? having issues giving it to hale on deathrun since he spawns in normal and changes.
__________________

Last edited by deltadude; 12-10-2012 at 21:16.
deltadude is offline
Marcus_Brown001
AlliedModders Donor
Join Date: Nov 2012
Location: Illinois, United States
Old 12-11-2012 , 00:05   Re: Remove All Weapons / Give Weapon On Round Start
Reply With Quote #4

I have updated my original post with the new code. In basic, it does the same exact thing but I added a check for teams. In the comments you will see which section is for which team. Again change the weapon names for what weapons you want which players to get. I also added it in for round start ( although if the player spawns it should do it automatically ). I do not play TF2 very often so I am not aware of how most of it works. If you are still having issues let me know and I will try to fix them

I tested this in CS:S and it worked as it should. So in theory it should work correctly in TF2 as well, please let me know! Enjoy xD

*Edit* If you wanted to, I could also do a check for which classes a player has on spawn, and give them a weapon based on that. If you were wondering

Last edited by Marcus_Brown001; 12-11-2012 at 07:21.
Marcus_Brown001 is offline
deltadude
SourceMod Donor
Join Date: Mar 2010
Old 12-12-2012 , 11:28   Re: Remove All Weapons / Give Weapon On Round Start
Reply With Quote #5

The class check would be nice, also maybe a way to remove certain weapons instead of all weapons.
__________________
deltadude is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-13-2012 , 11:29   Re: Remove All Weapons / Give Weapon On Round Start
Reply With Quote #6

TF2 does weapons differently than most other games... a number of weapons share classes with one another and are distinguished by their item indexes and weapon attributes. You're really going to need the TF2Items extension to do the give weapon part.

And as long as you're doing that, you might as well use TF2_RemoveWeaponSlot to remove weapons.

Also, TF2 uses teamplay_round_start instead of round_start.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 12-13-2012 at 11:34.
Powerlord is offline
Ejziponken
AlliedModders Donor
Join Date: Apr 2008
Old 11-06-2014 , 06:35   Re: Remove All Weapons / Give Weapon On Round Start
Reply With Quote #7

Quote:
Originally Posted by Marcus_Brown001 View Post
This should work:
PHP Code:
#include <sourcemod>
#include <smlib>

// If you use this please give me the credit :D

public Plugin:myinfo 
{
    
name "Remove Weapons",
    
author "Marcus",
    
description "Removes a players' weaopon(s) on spawn",
    
version "0.0.2",
    
url "http://www.sourcemod.net"
};

public 
OnPluginStart()
{
    
HookEvent("player_spawn"Event_Spawn);
    
HookEvent("round_start"Event_Start);
}

public 
Action:Event_Spawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
GetClientOfUserId(GetEventInt(event"userid"));
    
RemoveWeapons(i)

}

public 
Action:Event_Start(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
GetClientOfUserId(GetEventInt(event"userid"));
    
RemoveWeapons(i)
}

RemoveWeapons(client)
{
    new 
team GetClientTeam(client);
    
    
Client_RemoveAllWeapons(client""true); // Removes all the weapons ; Add a weapon name into the "" to exclude that weapon.
    
if( team != && team == // Checks if the player is not a spectator and if the player is on Red Team
    
{
        
Client_GiveWeaponAndAmmo(client"weapon_glock"true90); // Change weapon_glock to the weapon you want. 90 is the amount of ammo given.
        
Client_GiveWeaponAndAmmo(client"weapon_ak47"true90); // Change weapon_ak47 to the weapon you want.
    
} else if ( team != && team == 3// Checks if the player is not a spectator and if the player is on the Blu Team
    
{
        
Client_GiveWeaponAndAmmo(client"weapon_p228"true90); // Change weapon_p228 to the weapon you want. 90 is the amount of ammo given.
        
Client_GiveWeaponAndAmmo(client"weapon_m4a1"true90); // Change weapon_m4a1 to the weapon you want.
    
}
    

As said in the comments, change the weapon names to what ever you want for whichever game you are using. If you want to add more weapons you can simply copy the Client_GiveWeaponAndAmmo line and change the new one to a different weapon name. Lemme know if you something done to this! You do need to have SourceMod Library to compile this ( Download Here: http://www.sourcemodplugins.org/bund...smlib_0.11.zip ) .
Im looking for something like this but this plugin has one problem and it messes up the scope on scout when you fire. Its not acting like it should for some reason,
Ejziponken is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:59.


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