Raised This Month: $ Target: $400
 0% 

Change server pass...


Post New Thread Reply   
 
Thread Tools Display Modes
stupok
Veteran Member
Join Date: Feb 2006
Old 07-12-2007 , 14:35   Re: Change server pass...
Reply With Quote #11

It's still not correct, I don't understand why you don't use the code I've written for you. It's like you're trying to make this more difficult. The code below is correct and does exactly what you want:

Code:
/* AMXMOD X script.
*
* (c) Copyright 2007 Qlim4X
* This file is provided as is (no warranties).
*
* For #Pro.Gather in GrNet. Internal use only.
*
*/

#include <amxmod>
#include <amxmisc>

#define MAX_PLAYERS 32

public plugin_init()
{
	register_plugin("pro.gather ChangePass", "1.0", "qlim4x")
	
	register_concmd("pro_pass", "set_password", ADMIN_BAN, "<password>")
}


public set_password(id, level, cid)
{
	if(!cmd_access(id, level, cid, 2))
		return PLUGIN_HANDLED
	
	new set_pass[32]
	read_argv(1, set_pass, 31)
	
	if(!set_pass[0])
	{
		//The password is null!
		set_cvar_string("sv_password", "progather")
	}
	else
	{
		set_cvar_string("sv_password", set_pass)
	}
	
	server_exec()
	
	for(new i = 1; i <= MAX_PLAYERS; i++)
	{
		if(is_user_admin(id))
		{
			client_print(id, print_chat, "* sv_password changed to ^"%s^"", set_pass)
		}
	}
	
	return PLUGIN_HANDLED
}
stupok is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 07-12-2007 , 15:25   Re: Change server pass...
Reply With Quote #12

Quote:
<m3r1in> Does server_exec() only affect server_cmd() or set_cvar_*() too?
<BAILOPAN> set_cvar is unrelated
Lee is offline
Qlim4X
Member
Join Date: Jun 2007
Old 07-12-2007 , 18:28   Re: Change server pass...
Reply With Quote #13

Quote:
Originally Posted by stupok69 View Post
It's still not correct, I don't understand why you don't use the code I've written for you. It's like you're trying to make this more difficult. The code below is correct and does exactly what you want:

Code:
/* AMXMOD X script.
*
* (c) Copyright 2007 Qlim4X
* This file is provided as is (no warranties).
*
* For #Pro.Gather in GrNet. Internal use only.
*
*/

#include <amxmod>
#include <amxmisc>

#define MAX_PLAYERS 32

public plugin_init()
{
    register_plugin("pro.gather ChangePass", "1.0", "qlim4x")
    
    register_concmd("pro_pass", "set_password", ADMIN_BAN, "<password>")
}


public set_password(id, level, cid)
{
    if(!cmd_access(id, level, cid, 2))
        return PLUGIN_HANDLED
    
    new set_pass[32]
    read_argv(1, set_pass, 31)
    
    if(!set_pass[0])
    {
        //The password is null!
        set_cvar_string("sv_password", "progather")
    }
    else
    {
        set_cvar_string("sv_password", set_pass)
    }
    
    server_exec()
    
    for(new i = 1; i <= MAX_PLAYERS; i++)
    {
        if(is_user_admin(id))
        {
            client_print(id, print_chat, "* sv_password changed to ^"%s^"", set_pass)
        }
    }
    
    return PLUGIN_HANDLED
}

i use the given code but some times doesnt work and i dont know why(the change pass part...)

the server exec command can be used like this?
server_exec(amx_chat Password changed to ^"%s^"", set_pass)
server_exec(
set_cvar_string("sv_password", set_pass)
Qlim4X is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 07-12-2007 , 19:11   Re: Change server pass...
Reply With Quote #14

No, that should be written as:

Code:
//loops over each player and if admin, displays message - much like amx_chat new maxPlayers = get_maxplayers() for(new i = 1; i <= maxPlayers; i++) {     if(is_user_admin(i))     {         client_print(i, print_chat, "[AMXX] The server password has been changed to ^"%s^"", newPassword)     } } //this native does not need to be passed as a parameter to anything.. set_cvar_string("sv_password", newPassword)
server_exec() does nothing but immediately execute previous calls of server_cmd() and does not take any parameters.

What is the problem you're having with the code that has already been provided?

Edit:
stupok69, shouldn't the native calls in your loop be passed the value of i rather than id?

Last edited by Lee; 07-12-2007 at 20:10.
Lee is offline
Qlim4X
Member
Join Date: Jun 2007
Old 07-12-2007 , 22:12   Re: Change server pass...
Reply With Quote #15

finally i did it

take a look

ps. the pro_menu null pass doest work at all just sows a msg to console to add pass


Quote:
/* AMXMOD X script.
*
* (c) Copyright 2007 Qlim4X
* This file is provided as is (no warranties).
*
* For #Pro.Gather in GrNet. Internal use only.
*
*/

#include <amxmodx>
#include <amxmisc>

public plugin_init()
{
register_plugin("pro.gather ChangePass", "1.0", "qlim4x")

register_concmd("pro_pass", "set_password", ADMIN_BAN, "<password>")
}


public set_password(id, level, cid)
{
if(!cmd_access(id, level, cid, 2))
return PLUGIN_HANDLED

new set_pass[32]
read_argv(1, set_pass, 31)

if(!set_pass[0])
{
//The password is null!
set_cvar_string("sv_password", "progather")
server_cmd("amx_chat The Sv_Password is ^"%s^"", set_pass)
}
else
{
set_cvar_string("sv_password", set_pass)
server_cmd("amx_chat The Sv_Password is ^"%s^"", set_pass)
}

server_exec()


return PLUGIN_HANDLED
}
Qlim4X is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 07-13-2007 , 08:46   Re: Change server pass...
Reply With Quote #16

If you don't require any arguments, you need to change a parameter in cmd_access()..

Code:
if(!cmd_access(id, level, cid, 1))
Lee is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 07-13-2007 , 18:25   Re: Change server pass...
Reply With Quote #17

First the tip from LEE.
then
PHP Code:
new set_pass[32]
read_argv(1set_pass31
you should check if there is a pw added to the command.
PHP Code:
new set_pass[32]
if(
read_argc() > 1) {
   
read_argv(1,set_pass,31
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who donīt.

Last edited by |PJ| Shorty; 07-13-2007 at 18:33.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
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 01:57.


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