Raised This Month: $ Target: $400
 0% 

Can this plugin works?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
AlejandroSk
BANNED
Join Date: Nov 2008
Location: Aqui, en mi casa. Karma:
Old 03-12-2009 , 22:41   Can this plugin works?
Reply With Quote #1

hi , im a noob on scripting and im training and i make a little script for my server and wanna know if its correct =(

PHP Code:
 #include <amxmodx>

#define plugin_name "Block Change Name"
#define plugin_version "0.1"
#define plugin_author "AlejandroSk"

new name[32]
new 
name2[32]

public 
plugin_init()
{
    
register_plugin(plugin_nameplugin_versionplugin_author)
    
register_logevent("EventRoundStart"2"1=Round_Start");
}

public 
client_connect(id)
{
    
name[id] = get_user_name(idname31)
    
client_print(idprint_chat"Welcome %s to %hostname%"name)
}

public 
EventRoundStart(id)
{
    
name2[id] = get_user_name(idname231)
    if (
name[id] != name2[id])
    {
        
client_cmd(id"name %s" name)
        
client_print(id print_chat"%s , You cant change your name in this server !" name)
    
    }

please dont -karma me just for dont be a pro scripter
AlejandroSk is offline
Send a message via MSN to AlejandroSk
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-13-2009 , 00:19   Re: Can this plugin works?
Reply With Quote #2

There's no such thing as "%hostname%"
You will have to use
Code:
new hostname[64]; get_cvar_string("hostname", hostname, 63);

Also client_connect is way before they are able to see the chat. Use client_putinserver() and then set_task() to show the message.
Here's an example:
Code:
public client_putinserver(id)  set_task(5.0, "show_message", id);   public show_message(id) {  new name[32];  get_user_name(id, name, 31);    new hostname[64];  get_cvar_string("hostname", hostname, 63);    client_print(id, print_chat, "Welcome %s to %s", name, hostname); }

There are better ways to check if player changes his name.
Code:
public client_infochanged(id) {  if ( ! is_user_connected(id) )   return;    new newname[32], oldname[32];    get_user_name(id, oldname, 31);  get_user_info(id, "name", newname, 31);    if ( ! equal(newname, oldname) ) {         client_cmd(id, "name %s" , name);         client_print(id , print_chat, "%s , You cant change your name in this server !" , name);  } }

Last edited by [ --<-@ ] Black Rose; 03-13-2009 at 00:28.
[ --<-@ ] Black Rose is offline
grankee
Member
Join Date: Jun 2008
Old 03-13-2009 , 04:41   Re: Can this plugin works?
Reply With Quote #3

Quote:
client_cmd(id, "name %s" , name);
should be
Code:
 client_cmd(id, "name %s" , oldname);
but if client is death, his name is player and type in console
Code:
name test
name player
(like this plugin), name will not change to old, some bug

Last edited by grankee; 03-13-2009 at 04:45.
grankee is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 03-13-2009 , 05:17   Re: Can this plugin works?
Reply With Quote #4

Actually:
PHP Code:
client_cmdid"name ^"%s^""whatever ); 
But this is more efficient:
Code:
#include <amxmodx> #include <fakemeta> #include <amxmisc> #define PLUGIN_NAME "No Name Change" #define PLUGIN_VERSION "0.1" #define PLUGIN_AUTHOR "VEN" new const g_reason[] = "[NNC] Sorry, name change isn't allowed on this server!" new const g_name[] = "name" public plugin_init() {     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)     register_forward(FM_ClientUserInfoChanged, "fwClientUserInfoChanged") } public fwClientUserInfoChanged(id, buffer) {     if (!is_user_connected(id))         return FMRES_IGNORED;     if ( is_user_admin ( id ) )         return PLUGIN_HANDLED;     static name[32], val[32]     get_user_name(id, name, sizeof name - 1)     engfunc(EngFunc_InfoKeyValue, buffer, g_name, val, sizeof val - 1)     if (equal(val, name))         return FMRES_IGNORED;     engfunc(EngFunc_SetClientKeyValue, id, buffer, g_name, name)     console_print(id, "%s", g_reason)     return FMRES_SUPERCEDE; }
I can't find the thread, so i posted the code.
__________________

anakin_cstrike is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 03-13-2009 , 12:06   Re: Can this plugin works?
Reply With Quote #5

Quote:
Originally Posted by anakin_cstrike View Post
Actually:
PHP Code:
client_cmdid"name ^"%s^""whatever ); 
But this is more efficient:

Code:
</p><p>#include <amxmodx></p><p>#include <fakemeta></p><p>#include <amxmisc></p><p>&nbsp;</p><p>#define PLUGIN_NAME "No Name Change"</p><p>#define PLUGIN_VERSION "0.1"</p><p>#define PLUGIN_AUTHOR "VEN"</p><p>&nbsp;</p><p>new const g_reason[] = "[NNC] Sorry, name change isn't allowed on this server!"</p><p>&nbsp;</p><p>new const g_name[] = "name"</p><p>&nbsp;</p><p>public plugin_init() {</p><p> register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)</p><p> register_forward(FM_ClientUserInfoChanged, "fwClientUserInfoChanged")</p><p>}</p><p>&nbsp;</p><p>public fwClientUserInfoChanged(id, buffer) {</p><p> if (!is_user_connected(id))</p><p> return FMRES_IGNORED;</p><p> if ( is_user_admin ( id ) )</p><p> return PLUGIN_HANDLED;</p><p>&nbsp;</p><p> static name[32], val[32]</p><p> get_user_name(id, name, sizeof name - 1)</p><p> engfunc(EngFunc_InfoKeyValue, buffer, g_name, val, sizeof val - 1)</p><p> if (equal(val, name))</p><p> return FMRES_IGNORED;</p><p>&nbsp;</p><p> engfunc(EngFunc_SetClientKeyValue, id, buffer, g_name, name)</p><p> console_print(id, "%s", g_reason)</p><p>&nbsp;</p><p> return FMRES_SUPERCEDE;</p><p>}</p><p>&nbsp;</p><p>


I can't find the thread, so i posted the code.
No, it is not more efficient.
[ --<-@ ] Black Rose is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 03-13-2009 , 12:57   Re: Can this plugin works?
Reply With Quote #6

And why you say that? because is more code ?
__________________

anakin_cstrike is offline
IneedHelp
Veteran Member
Join Date: Mar 2007
Location: Argentina
Old 03-13-2009 , 13:29   Re: Can this plugin works?
Reply With Quote #7

Why in that code there's a fakemeta forward instead of the normal client_infochanged ?
__________________
IneedHelp is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 03-13-2009 , 13:48   Re: Can this plugin works?
Reply With Quote #8

Quote:
Originally Posted by IneedHelp View Post
Why in that code there's a fakemeta forward instead of the normal client_infochanged ?
I test and have the same reaccion.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-13-2009 , 14:23   Re: Can this plugin works?
Reply With Quote #9

The FM forward is an alternate (better?) method to hook the event of changing one's info.
__________________
fysiks is offline
AlejandroSk
BANNED
Join Date: Nov 2008
Location: Aqui, en mi casa. Karma:
Old 03-13-2009 , 14:40   Re: Can this plugin works?
Reply With Quote #10

thanks for ur help
AlejandroSk is offline
Send a message via MSN to AlejandroSk
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 08:59.


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