Raised This Month: $23 Target: $400
 5% 

Set Cvars everytime player joins


Post New Thread Reply   
 
Thread Tools Display Modes
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-25-2013 , 02:23   Re: Set Cvars everytime player joins
Reply With Quote #11

Quote:
Originally Posted by necavi View Post
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 THANK U SO MUCH!!!!!! IM GONNA TEST IT RIGHT NOW! I CANT BELIEVE YOU HELPED ME WITH THIS! I LOVE YOU 4EVER <3

I'm curious about how you made this, so I'll get to comprehending this after I try it out.

AGAIN, THANK YOU SO MUCH FOR THIS!!!!!
Jakesterdog123 is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-25-2013 , 02:35   Re: Set Cvars everytime player joins
Reply With Quote #12

Sure, be sure to post if it works, I threw it together pretty quickly so there may be bugs.
necavi is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-25-2013 , 15:22   Re: Set Cvars everytime player joins
Reply With Quote #13

Quote:
Originally Posted by necavi View Post
Sure, be sure to post if it works, I threw it together pretty quickly so there may be bugs.
Well, I tested it, but no matter what I do it doesn't work ;-;

I created spawn_commands.cfg in /configs/ directory, then I
wrote

sm_rof #[client] 4
sm_addcond #[client] 11 99999.9

i used rof to test if it works quicker 0-0
and well, i tried everything possible to get it to work

@all
#all
@[client]
#[STEAM_0:1:XXXXXXXX]
@[STEAM_0:1:XXXXXXXX]
@STEAM_0:1:XXXXXXXX
#STEAM_0:1:XXXXXXXX

and some more, but none of them worked after i reloaded the plugin and respawned.

btw, did you mean that #[client] would be replaced by the SERVER when a client joins, or for me to
place manually client steamid's!?!??!

Edit: I'm working on my server currently, so I'll check back for replies

Last edited by Jakesterdog123; 06-25-2013 at 15:30.
Jakesterdog123 is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-25-2013 , 15:40   Re: Set Cvars everytime player joins
Reply With Quote #14

Heh, two problems, one I meant [userid] not [client], and two I was trying to fill it with a client index not a userid I forgot which one commands used.
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 
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_hSpawnCommands); i++)
        {
            
GetArrayString(g_hSpawnCommandsibuffersizeof(buffer));
            
ReplaceString(buffersizeof(buffer), "[userid]"szUserID);
            
ServerCommand("%s"buffer);
        }
    }

This should work just fine.
necavi is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-25-2013 , 15:59   Re: Set Cvars everytime player joins
Reply With Quote #15

WOH, YOU FIXED IT!
sm_command #[client] WORKS GREAT! THANK YOU SO MUCH I CAN'T THANK YOU ENOUGH FOR THIS :O!!!!!

Edit: oh wait, let me test that again i think it didnt now im sure i could fix it though ;-;
but is that what i add in the cfg?

do i just put sm_command #[userid] or #[client]?

Edit: OK USERID WORKED!!!!!!!!!! OK THERE PROBLEM SOLVED!!!!

Last edited by Jakesterdog123; 06-25-2013 at 16:03.
Jakesterdog123 is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-25-2013 , 16:09   Re: Set Cvars everytime player joins
Reply With Quote #16

Happy to help, sorry about that little hiccup there.
necavi is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-27-2013 , 01:23   Re: Set Cvars everytime player joins
Reply With Quote #17

Hey necavi, if you get to this page again, I'm having a problem with sm_join and sm_ponyspencer (from that plugin xD)...

it's for this plugin:
https://forums.alliedmods.net/showthread.php?p=1556742

no matter what i do, it doesn't perform the command when a player spawns...
can u help me fix it?

*************************
So far, I have:

-**sm_join #[userid]** in /configs/spawn_commands.cfg
-placed group info in admin_overides and join plugin config like the plugin told me to..

*************************

Last edited by Jakesterdog123; 06-27-2013 at 01:27.
Jakesterdog123 is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-27-2013 , 01:33   Re: Set Cvars everytime player joins
Reply With Quote #18

That would be because the plugin I gave you runs the command as a ServerCommand (Since you mentioned commands that would be admin commands, normally not able to be run by any random client).
necavi is offline
Jakesterdog123
Senior Member
Join Date: Oct 2012
Location: California
Old 06-27-2013 , 01:41   Re: Set Cvars everytime player joins
Reply With Quote #19

I see...server commands...
that makes sense xD

hmm...can u add it in for me still..plz?

It'll help players to not have to type a lot of commands I use when they need them 0-0
it should enable it for them, that's how I like it
Jakesterdog123 is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 06-27-2013 , 01:59   Re: Set Cvars everytime player joins
Reply With Quote #20

I took the rather lazy route, but this one will use two configs, one spawn_server_commands.cfg and the other one spawn_client_commands.cfg
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));
            
ServerCommand("%s"buffer);
        }
    }

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 12:11.


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