Raised This Month: $1944 Target: $400
 486% 

Set Cvars everytime player joins


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-23-2013 , 18:24   Set Cvars everytime player joins
Reply With Quote #1

ANYONE STUMBLING UPON THIS: THE PLUGIN HAS BEEN CREATED, THANKS TO THE WONDERFUL NECAVI!

INSTRUCTIONS:

put this in a script, call it what u want (necavi called it Spawn Commands, but i just called mine "cvars" to refresh changes in console quicker), compile and poot in ur plugins folder...

also, create these 2 files in ur addons/sourcemod/configs folder

configs/spawn_server_commands.cfg
configs/spawn_client_commands.cfg

proper usage:

sm_command #[userid] <flags, toggles, whatever else u need to set goes here unless u dont need any...> <1> <slay> <red> <etc...>

#[userid] IS EXACTLY, CHARACTER BY CHARACTER, what u write....not @ or !...
its ment for necavi's program to fetch a client's steamid/userid every time they spawn/respawn

PROtip: no the difference between a serverside cvar and client cvar (not like my noob mistake...)

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);
        }
    }








[[old post stuff....if ur interested in reading it ]]

Edit: PLEASE SCROLL TO BOTTOM POST AFTER THIS; EVERYTHING ELSE IS JUST PERSONAL CRAPE

We should have a plugin that sets target cvars automatically for your server when a player joins

For example, if you want to use the addcond plugin...

sm_addcond @all 11 <[[kritzkrieg (crits)]]>

i cant seem to find a crits plugin with particle effects btw...it would be great if someone could please tell me which plugin does this for an allcrit server

But besides that, it would be nice to have a plugin that sets cvars for each player that joins, unless there is some other method I don't know about that someone could generously offer me

btw it could be used for sm_rof (rate of fire) too and target commands like that...

So someone get working on it! Ty!

Edit: Woh, 131 views! Come on, guys, one of you has to go know how to make this >_>
I'm gonna try working on a draft, but I'm only a noob to scripting Sourcemod, so it'd be great if you guys could lead me in the right direction with this. Any help is appreciated! I can't wait till we have this. I know a couple of servers that need this too, and if you need it too, then get working .-.

Btw, if anyone is nice enough to upload a draft/working script, I will forever honor you and your majestic generosity and I'll plaster your face all over my walls to remind me of how awesome you are (and your face).

Last edited by Jakesterdog123; 06-28-2013 at 22:26.
Jakesterdog123 is offline
Dr. McKay
Sir Dr. SourceMod Plugin Approver Esq. Ltd. M.D. PhD
Join Date: Aug 2011
Location: Atlantis
Old 06-23-2013 , 19:38   Re: Set Cvars everytime player joins
Reply With Quote #2

This should work for all crits:

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <tf2>

public Plugin:myinfo = {
    
name        "[TF2] All Crits",
    
author        "Dr. McKay",
    
description    "Gives all players crit boost",
    
version        "1.0.0",
    
url            "Dr. McKay"
};

public 
OnPluginStart() {
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) {
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
TF2_AddCondition(clientTFCond_Kritzkrieged9999999.9);

But I'd think that the crit boost sound would get annoying.
__________________
Dr. McKay is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-23-2013 , 20:18   Re: Set Cvars everytime player joins
Reply With Quote #3

thank you so much! I'll give it a try right now

Edit: Oh wait, the hook event for player spawn-that's perfect! That's exactly what I was looking for to make an automated cvar setter/refresher plugin every time a player joins!

Last edited by Jakesterdog123; 06-23-2013 at 20:27.
Jakesterdog123 is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-23-2013 , 22:42   Re: Set Cvars everytime player joins
Reply With Quote #4

It seems that after being healed by a medic the crits stop working. Could you show me how to fix that?
Probably with player_healedbymedic and localplayer_healed
Jakesterdog123 is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-23-2013 , 22:45   Re: Set Cvars everytime player joins
Reply With Quote #5

PHP Code:
#pragma semicolon 1

#include <sourcemod>
#include <tf2>

public Plugin:myinfo = {
    
name        "[TF2] All Crits",
    
author        "Dr. McKay",
    
description    "Gives all players crit boost",
    
version        "1.0.0",
    
url            "Dr. McKay"
};

public 
OnPluginStart() {
    
HookEvent("player_spawn"Event_PlayerSpawn);
    
HookEvent("player_healedbymedic"Event_PlayerHealedbymedic);
    
HookEvent("localplayer_healed"Event_LocalplayerHealed);
}

public 
Action:Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) {
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    
TF2_AddCondition(clientTFCond_Kritzkrieged9999999.9);

If that's not correct (because I don't know what I'm doin >_>) please show me how to do it

Edit: What I'm aiming for is always having crits on

Edit #2: after finally reading the sourcepawn documentation, now i see what I did wrong *facepalm

Quote:
Originally Posted by Tylerst View Post
Use TFCond_CritOnWin instead, it doesn't get removed on heal.
I fixed my mistake it worked ilu very much ty both for helping me gets crits on my server ^.^

Last edited by Jakesterdog123; 06-25-2013 at 01:01. Reason: i was stupid :'(
Jakesterdog123 is offline
Tylerst
Veteran Member
Join Date: Oct 2010
Old 06-23-2013 , 23:13   Re: Set Cvars everytime player joins
Reply With Quote #6

Use TFCond_CritOnWin instead, it doesn't get removed on heal.
Tylerst is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-23-2013 , 23:25   Re: Set Cvars everytime player joins
Reply With Quote #7

Thank you so much!!!!!!

Edit: Hmm...it doesn't seem to give crits until a win...
Can anyone direct me to a list of tfconds?

Last edited by Jakesterdog123; 06-24-2013 at 02:51.
Jakesterdog123 is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-24-2013 , 04:24   Re: Set Cvars everytime player joins
Reply With Quote #8

I copied my response to another user from a different thread. I hope this clarifies what I'm looking for

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.

Last edited by Jakesterdog123; 06-24-2013 at 04:25.
Jakesterdog123 is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-25-2013 , 00:48   Re: Set Cvars everytime player joins
Reply With Quote #9

No one is posting here anymore <__>. Alright, I'll get to work on coding this; I spent all day reading the sourcepawn documentation and every possible tutorial on youtube. I guess I'll look at some similar plugins to get some ideas (aka steal, jk I'll give you credit xD). From what I've read, it seems that I could accomplish this by scanning for global convars... so my goal is to write a plugin that scans for cvars for plugins that you specify.

Another option is to find specific ConCmd's, turn them into global cvars, and paste them into the target plugin's script....which is trickier and probably won't work because I don't think you can edit .smx's and pasting them into .sp's are useless unless I could have them auto-recompiled and auto-replaced in the plugins directory...

If any of that is feasible, could any of you experienced users give me a quick stamp of approval or reject it if I'm going to waste my time before I waste time

But I think the simplest way is to create a config file that has a dependency on it's target plugins and mirrors functionality, which means it would duplicate the functions of the concmd's as convars! Then there would be no need to constantly re-enter "sm_random-client/admin-command" when a player wants to enable noclip every time he dies or an admin wants to drop ragdolls on all the players every 5 minutes (countless examples; not enough patience)

Any advice from my fellow alliedmodders
Jakesterdog123 is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-25-2013 , 01:12   Re: Set Cvars everytime player joins
Reply With Quote #10

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_hSpawnCommands INVALID_HANDLE;
public 
OnPluginStart()
{
    new 
String:path[PLATFORM_MAX_PATH];
    
BuildPath(Path_SMpathsizeof(path), "configs/spawn_commands.cfg");
    
g_hSpawnCommands CreateArray(256);
    new 
Handle:file OpenFile(path"r");
    new 
String:buffer[256];
    while(
ReadFileLine(filebuffersizeof(buffer)))
    {
        
PushArrayString(g_hSpawnCommandsbuffer);
    }
    
CloseHandle(file);
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if(
GetClientTeam(client) > 1)
    {
        new 
String:buffer[256];
        new 
String:szClient[4];
        
IntToString(clientszClientsizeof(szClient));
        for(new 
0GetArraySize(g_hSpawnCommands); i++)
        {
            
GetArrayString(g_hSpawnCommandsibuffersizeof(buffer));
            
ReplaceString(buffersizeof(buffer), "[userid]"szClient);
            
ServerCommand("%s"buffer);
        }
    }

This should basically do what you need, just create a .cfg of the name indicated in the code in your /configs/ directory. An example of use would be sm_addcond #[client] 11. ([client] is replaced by the spawning client's ID).
necavi 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 14:53.


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