Raised This Month: $12 Target: $400
 3% 

Set Cvars everytime player joins


Post New Thread Reply   
 
Thread Tools Display Modes
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-28-2013 , 16:30   Re: Set Cvars everytime player joins
Reply With Quote #31

Lol, thanks necavi xDDD
__________________
TF2 Server/Community - "Pony: Elements of Harmony - Squee!"
**IP - peohtf2.clanservers.com**

Jakesterdog123 is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-28-2013 , 22:15   Re: Set Cvars everytime player joins
Reply With Quote #32

Necavi...i got this error when trying to compile...
sorry for all this trouble ;-;

Code:
 error 035: argument type mismatch (argument 1)
//
// 1 Error.
//
// Compilation Time: 0.16 sec
// ----------------------------------------

Press enter to exit ...
__________________
TF2 Server/Community - "Pony: Elements of Harmony - Squee!"
**IP - peohtf2.clanservers.com**

Jakesterdog123 is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-28-2013 , 22:18   Re: Set Cvars everytime player joins
Reply With Quote #33

Fixed
PHP Code:
#include <sourcemod>

public Plugin:myinfo 
{
    
name "Spawn Commands",
    
author "necavi",
    
description "Runs a set of commands from a config whenever a player spawns.",
    
version "1.0",
    
url "http://necavi.org/"
}
new 
Handle:g_hSpawnServerCommands INVALID_HANDLE;
new 
Handle:g_hSpawnClientCommands INVALID_HANDLE;
public 
OnPluginStart()
{
    new 
String:path[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMpathsizeof(path), "configs/spawn_server_commands.cfg");
    if(
FileExists(path))
    {
        if(
g_hSpawnServerCommands != INVALID_HANDLE)
        {
            
CloseHandle(g_hSpawnServerCommands);
        }
        
g_hSpawnServerCommands CreateArray(256);
        new 
Handle:file OpenFile(path"r");
        new 
String:buffer[256];
        while(
ReadFileLine(filebuffersizeof(buffer)))
        {
            
PushArrayString(g_hSpawnServerCommandsbuffer);
        }
        
CloseHandle(file);
    }
    
BuildPath(Path_SMpathsizeof(path), "configs/spawn_client_commands.cfg");
    if(
FileExists(path))
    {
        if(
g_hSpawnClientCommands != INVALID_HANDLE)
        {
            
CloseHandle(g_hSpawnClientCommands);
        }
        
g_hSpawnClientCommands CreateArray(256);
        new 
Handle:file OpenFile(path"r");
        new 
String:buffer[256];
        while(
ReadFileLine(filebuffersizeof(buffer)))
        {
            
PushArrayString(g_hSpawnClientCommandsbuffer);
        }
        
CloseHandle(file);
    }
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
userid GetEventInt(event"userid");
    new 
client GetClientOfUserId(userid);
    if(
GetClientTeam(client) > 1)
    {
        new 
String:buffer[256];
        new 
String:szUserID[8];
        
IntToString(useridszUserIDsizeof(szUserID));
        for(new 
0GetArraySize(g_hSpawnServerCommands); i++)
        {
            
GetArrayString(g_hSpawnServerCommandsibuffersizeof(buffer));
            
ReplaceString(buffersizeof(buffer), "[userid]"szUserID);
            
ServerCommand("%s"buffer);
        }
        for(new 
0GetArraySize(g_hSpawnClientCommands); i++)
        {
            
GetArrayString(g_hSpawnClientCommandsibuffersizeof(buffer));
            
FakeClientCommand(client"%s"buffer);
        }
    }

necavi is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-29-2013 , 02:37   Re: Set Cvars everytime player joins
Reply With Quote #34

Everything worked perfectly ! thank you necavi and DrMcKay for supporting and working on my plugin request and helping me through it for the last couple days! I really appreciate it guys!
Attached Thumbnails
Click image for larger version

Name:	tumblr_melb7tZEmj1r0r1zz.jpg
Views:	155
Size:	5.9 KB
ID:	121927  
__________________
TF2 Server/Community - "Pony: Elements of Harmony - Squee!"
**IP - peohtf2.clanservers.com**

Jakesterdog123 is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-29-2013 , 03:04   Re: Set Cvars everytime player joins
Reply With Quote #35

Sure, sorry again for the mistakes, it isn't really normal for me to have so many.
necavi is offline
AeraColthearts
Junior Member
Join Date: Aug 2017
Old 07-31-2020 , 09:43   Re: Set Cvars everytime player joins
Reply With Quote #36

Is there a way that the CVARs only take effect on the specified player like for example on L4D2
sm_cvar @testplayer melee_range 500, this CVAR will only work on a specified player.
AeraColthearts is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 07-31-2020 , 10:43   Re: Set Cvars everytime player joins
Reply With Quote #37

It's been such a long time. Wow. I was in high school when I worked on all this.

Anyway, the plugin was made with source engine compatibility. It should work across all the source engine game servers. Just make sure to follow the parameters from the instructions on the first page. If it doesn't work for l4d2, you'll have to resurrect the mod.

All i remember is that, yes, I intended this plugin to be player specific. All commands would only affect specific players for filtering purposes. I'm not sure if there's a better method at this point but it'll get the job done.

Below is something I found on the first page explaining what this was supposed to do exactly. Unfortunately it's been a long time since I've worked on sourcemods but I'll try to keep this alive.

Quote:

Yeah wrong section, i moved the thread to requested sourcemod plugins

But what I'm aiming for is a script that refreshes a cvar setting that fakes user input, so without you manually having to, for example, type sm_reloadadmins if your server added a new client to admin list everytime a new client joins the server.

I personally need it for the addcond plugin which requires you to input sm_addcond @<input person or group here> 11 ((fake kritzkrieg/crits)) whenever a new player joins my server but this was before a friendly member showed me his method to a crits plugin, but I need such an automated cvar refresher for lots of other instances for every time a player spawns.
__________________
TF2 Server/Community - "Pony: Elements of Harmony - Squee!"
**IP - peohtf2.clanservers.com**


Last edited by Jakesterdog123; 07-31-2020 at 11:06.
Jakesterdog123 is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 07-31-2020 , 21:16   Re: Set Cvars everytime player joins
Reply With Quote #38

Funny how time marches on, innit?
__________________
Dr. McKay is offline
Reply


Thread Tools
Display Modes

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 18:23.


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