AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plugin (https://forums.alliedmods.net/showthread.php?t=331734)

JeremWatts 04-05-2021 07:12

Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plugin
 
3 Attachment(s)
So

I have the [TF2items] Give Weapon plugin working to my knowledge.

Ultimately my goal is to setup a plugin before the end of the month for my birthday :crab: that will make tf2 more accessible for noobs by dictating loadouts for specific classes.

My issue is that I am not familiar with coding and can only either get every player to be completely weaponless or I get the weapons copying themselves and crashing the server via entity limit.

I'll attach the files for my last attempt, yet another t-pose party. :bacon:

The code i was trying to Frankenstein came from the first two pages of this thread https://forums.alliedmods.net/showthread.php?t=203225

If i can see an example of just one working weapon I feel like i can figure out the rest from there.

PC Gamer 04-06-2021 17:08

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
We can help you if more information is provided.

1. Are you wanting to give every Human and Bot Scout a STOCK Syringe Gun and a Medi Gun?
2. Are you running TF2Attributes?
3. Are you wanting to change player cosmetics?
4. What are the specific loadout do you want for a specific class?

The code you provided won't work until you change it. Once fixed it will give a standard Syringe Gun and standard Medi Gun to all Scouts when they spawn or touch a locker.

Change this line:
Code:

public OnPostInventoryApplication( Handle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
        new iClient = GetClientOfUserId( GetEventInt( hEvent, "userid" ) )
       
        for( new iSlot = 0; iSlot < _:TF2ItemSlot; iSlot++ )
                TF2_RemoveWeaponSlot( iClient, iSlot );
       
    if (TF2_GetPlayerClass(iClient) == TFClass_Scout)
    {
        TF2Items_GiveWeapon(iClient, 17);
        TF2Items_GiveWeapon(iClient, 29);
    }
       
}

To read:
Code:

public OnPostInventoryApplicationAndPlayerSpawn( Handle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
        new iClient = GetClientOfUserId( GetEventInt( hEvent, "userid" ) )
       
    if (TF2_GetPlayerClass(iClient) == TFClass_Scout)
    {
        TF2_RemoveWeaponSlot( iClient, 0 );
        TF2Items_GiveWeapon(iClient, 17);
        TF2_RemoveWeaponSlot( iClient, 1 );               
        TF2Items_GiveWeapon(iClient, 29);
    }
}

You can view my Bling plugin to get ideas on what is possible: https://forums.alliedmods.net/showthread.php?p=2728917

JeremWatts 04-07-2021 04:23

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
1 Attachment(s)
Script now amended, restarted the server but no go - still just t-poses. It's gotta be my config txt then right?

/just/ in case i read something wrong this is what my .sp looks like verbatim right now

Code:

#include <sourcemod>
#include <tf2items>
#include <tf2_stocks>
#include <tf2items_giveweapon>

new TF2ItemSlot = 8;
 
public Plugin:myinfo =
{
        name = "SmootheBrainBan",
        author = "Jerem",
        description = "Accessable TF2",
        version = "0.12",
        url = ""
};
 
public OnPluginStart()
{
        HookEvent( "post_inventory_application", OnPostInventoryApplicationAndPlayerSpawn );
}

public OnPostInventoryApplicationAndPlayerSpawn( Handle:hEvent, const String:strEventName[], bool:bDontBroadcast )
{
        new iClient = GetClientOfUserId( GetEventInt( hEvent, "userid" ) )
       
    if (TF2_GetPlayerClass(iClient) == TFClass_Scout)
    {
        TF2_RemoveWeaponSlot( iClient, 0 );
        TF2Items_GiveWeapon(iClient, 17);
        TF2_RemoveWeaponSlot( iClient, 1 );               
        TF2Items_GiveWeapon(iClient, 29);
    }
}

Quote:

Are you wanting to give every Human and Bot Scout a STOCK Syringe Gun and a Medi Gun?
&
Quote:

What are the specific loadout do you want for a specific class?
For this test, yes. Stock syringe gun and medigun.
However, my final product I want to look pretty dang similar to the picture i attached (simpler tf2 v0.4.png)

All regular unless specified
Scout with Backscat, Crit-a-cola, Bat
Heavy with Rocket Launcher(2rocketclip), Family Business, Cabertoss :grrr: (+movementspeed while active)
Engineer with Panic Attack, Ambassadore, Gunslinger
Medic with Shotgun, Quick-fix, Solemn Vow
Sniper with Classic, Piss, Bushwhacka

Quote:

Are you running TF2Attributes?
Nope, perhaps we have a winner I'll install it now.
Alright, copied the .sp, .smx & .inc into their directories & restarted but still t-pose central for now.

Quote:

Are you wanting to change player cosmetics?
Nah, I /did/ want to make all of blue team robots and disable/reduce cosmetics but after looking into it it seemed like a major hassle.
I guess I wouldn't mind being able to so some of that but I didn't think of doing that with this plugin.

PC Gamer 04-07-2021 12:32

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
1 Attachment(s)
I don't believe it is your config text file since you aren't using any custom weapons at all yet.

I tested your code without any edits on my server and it runs as intended. All scouts receive a Syringe Gun and Medigun. There is no T-pose.

I suspect there is a problem with your tf2items or tf2items_giveweapon plugin. You can test it by trying to give yourself a weapon. Try giving yourself a rocketlauncher by typing: !gimme 18

You can also type: sm plugins list
That will show you what plugins are running, and if if any plugins failed to load properly. You can also check your error log in: /tf/addons/sourcemod/logs/

Alternatively, you could just build the plugin without having a requirement to use tf2items or tf2items_giveweapon. See attached plugin for working example of Scout and Medic without tf2items.

JeremWatts 04-08-2021 04:00

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
1 Attachment(s)
oh, here we go
Code:

Unkown command: !gimme
Got that, did the tf2items_allow_gimme 1 command in the server before that too. But this got me thinking so I scrolled around and found this in the console (see attatched)

That item code doesn't appear in the pyrobattle.sp anymore and i doubt it's referenced in the smx so I reckon you're right about it not being the pyrobattle.sp

For good measure in case something broke while I wasn't looking I ran sm plugins list again. Everything's working as far as I can tell.

In case it's an option I want to mention at this point I'm happy to give you the login details to my server and just send you money through paypal to help. I've made a mess and I feel obliged to compensate you.

JeremWatts 04-08-2021 07:34

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
WAIT NO YOUR SCRIPT WORKS

alright yeah idk what was going wrong with tf2items but this is just as good, gdi I could kiss you man. Thank you so much lol - ignore my last post.

I've added the other classes to the code

Code:

{
        int client = GetClientOfUserId(GetEventInt(event, "userid"));
       
        if (TF2_GetPlayerClass(client) == TFClass_Scout)
        {
                TF2_RemoveWeaponSlot(client, 0);
                CreateWeapon(client, "tf_weapon_scattergun", 1103, 6);
               
                TF2_RemoveWeaponSlot(client, 1);               
                CreateWeapon(client, "tf_weapon_lunchbox_drink", 163, 6);
               
                TF2_RemoveWeaponSlot(client, 2);               
                CreateWeapon(client, "tf_weapon_bat", 0, 6);
        }

        if (TF2_GetPlayerClass(client) == TFClass_Medic)
        {
                TF2_RemoveWeaponSlot(client, 0);
                CreateWeapon(client, "tf_weapon_shotgun_primary", 9, 6);
               
                TF2_RemoveWeaponSlot(client, 1);               
                CreateWeapon(client, "tf_weapon_medigun", 411, 6);
               
                TF2_RemoveWeaponSlot(client, 2);               
                CreateWeapon(client, "tf_weapon_bonesaw", 413, 6);
        }

        if (TF2_GetPlayerClass(client) == TFClass_Heavy)
        {
                TF2_RemoveWeaponSlot(client, 0);
                CreateWeapon(client, "tf_weapon_rocketlauncher", 414, 6);
               
                TF2_RemoveWeaponSlot(client, 1);               
                CreateWeapon(client, "tf_weapon_shotgun", 425, 6);
               
                TF2_RemoveWeaponSlot(client, 2);               
                CreateWeapon(client, "tf_weapon_stickbomb", 307, 6);
        }
       
        if (TF2_GetPlayerClass(client) == TFClass_Engineer)
        {
                TF2_RemoveWeaponSlot(client, 0);
                CreateWeapon(client, "tf_weapon_shotgun", 1153, 6);
               
                TF2_RemoveWeaponSlot(client, 1);               
                CreateWeapon(client, "tf_weapon_revolver", 61, 6);
               
                TF2_RemoveWeaponSlot(client, 2);               
                CreateWeapon(client, "tf_weapon_robot_arm", 142, 6);
        }
       
        if (TF2_GetPlayerClass(client) == TFClass_Sniper)
        {
                TF2_RemoveWeaponSlot(client, 0);
                CreateWeapon(client, "tf_weapon_sniperrifle_classic", 1098, 6);
               
                TF2_RemoveWeaponSlot(client, 1);               
                CreateWeapon(client, "tf_weapon_jar", 58, 6);
               
                TF2_RemoveWeaponSlot(client, 2);               
                CreateWeapon(client, "tf_weapon_club", 232, 6);
        }
}

With this code the scout and medic are still fine but, what do I change to get the other 3 classes working?

Is there anyway to change attributes with this plugin? If not all good, i'll cope. If so then how would i reduce the clip on the liberty launcher to 2 and increase the movespeed when the cabertoss is active?

PC Gamer 04-08-2021 15:06

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
2 Attachment(s)
The easiest way to change attributes is to install TF2Attributes. Once you do that you can use the plugin attached to this post for increased speed while caber is active and reduced ammo for rocketlauncher.

I would've had this done sooner but changing the rocketlauncher ammo for the Heavy proved difficult. It appears that giving weapons to other classes (such as rocketlauncher to Heavy) results in the weapon having the default weapon ammo (such as 200 ammo for minigun applied to rocketlauncher).

Anyway, enjoy the plugin. I hope you have a great Birthday!

JeremWatts 04-08-2021 20:29

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
Perfection dude. Couple of randoms hopped on my server and helped me test balance and it's actually pretty damn good.

Thanks again, keep safe and all that.

oqyh 04-09-2021 15:58

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
Quote:

Originally Posted by JeremWatts (Post 2743098)
So

I have the [TF2items] Give Weapon plugin working to my knowledge.

Ultimately my goal is to setup a plugin before the end of the month for my birthday :crab: that will make tf2 more accessible for noobs by dictating loadouts for specific classes.

My issue is that I am not familiar with coding and can only either get every player to be completely weaponless or I get the weapons copying themselves and crashing the server via entity limit.

I'll attach the files for my last attempt, yet another t-pose party. :bacon:

The code i was trying to Frankenstein came from the first two pages of this thread https://forums.alliedmods.net/showthread.php?t=203225

If i can see an example of just one working weapon I feel like i can figure out the rest from there.


This Working Spawn Giver loadout

https://github.com/Hartmannq/SpawnWeapon

JeremWatts 04-11-2021 19:27

Re: Need help setting up a loadout plugin that piggybacks [TF2items] Give Weapon plug
 
Quote:

Originally Posted by oqyh (Post 2743600)
This Working Spawn Giver loadout

https://github.com/Hartmannq/SpawnWeapon

Doesn't look related to tf2 :shock:


All times are GMT -4. The time now is 02:09.

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