Raised This Month: $ Target: $400
 0% 

Checking player's name?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arion
Senior Member
Join Date: Mar 2007
Old 07-16-2007 , 00:33   Checking player's name?
Reply With Quote #1

I'm totally newbie on scripting for AMXX and I'm with some difficulty to make a function:

Code:
 When player connects  <- public client_connect ?
  If (name == "Arion")  <- strcmp (name, "Arion") ?
    Player sends command ("say \"Arion connecting\"")<- client_cmd (don't know)
I don't know what (id) (on public client_connect(id)) means too ..



Someone could make this little code so I can study on it?


A little help with get_user_name(id, name, 17) is much appreciated too (Where did you get id? And name is where it will save the result? 17 is the number of letters it will save in the variable?


One day I'll be good
Arion is offline
Send a message via MSN to Arion
stupok
Veteran Member
Join Date: Feb 2006
Old 07-16-2007 , 01:09   Re: Checking player's name?
Reply With Quote #2

Here's the code:

Code:
#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "stupok69"

public plugin_init() // This is executed when the plugin starts, typically on a mapchange.
{
	register_plugin(PLUGIN, VERSION, AUTHOR) // This let's AMXX know some information about the plugin.
}

public client_putinserver(id)
// id is a number that identifies a user in your server
// if the maximum number of players in your server is 32, then id can be from 1 to 32
// this function is generally executed after client_connect() and client_authorized()
{
	new name[32]
	// this is an array, the typical way to store strings in AMXX
	
	get_user_name(id, name, 31)
	// this function grabs the name of the client who has caused
	// client_putinserver() to be executed
	
	// id is the client's identifying number, so the function knows
	// which client to get the name of
	
	// 31 is the last slot of the array "name"
	// the function will only get the first 32 characters of the user's name
	
	
	// let's say the client's name is "Gaben the Turtle"
	// in this case, name would look like this:
	//
	// name[0] = 'G'
	// name[1] = 'a'
	// name[2] = 'b'
	// name[3] = 'e'
	// name[4] = 'n'
	// name[5] = ' '
	// name[6] = 't'
	// name[7] = 'h'
	// name[8] = 'e'
	// name[9] = ' '
	// name[10] = 'T'
	// name[11] = 'u'
	// name[12] = 'r'
	// name[13] = 't'
	// name[14] = 'l'
	// name[15] = 'e'
	// name[16] = 0
	
	
	client_print(0, print_chat, "%s is connecting", name)
	
	// this function is used to send text messages to clients
	
	// id is 0 here, which means that no client is specified, so all clients
	// will receive the text message
	
	// print_chat means that the message will look like a chat message
	
	// "%s is connecting" is the message that will be sent
	// %s is used as a placeholder for a string, in this case for the array "name"
	
	// finally, name is put after the message so %s can be replaced with the contents
	// of the array "name"
}
I suggest that you read these:

http://wiki.alliedmods.net/index.php/Pawn_Tutorial

http://wiki.alliedmods.net/index.php...od_X_Scripting
stupok is offline
Arion
Senior Member
Join Date: Mar 2007
Old 07-16-2007 , 13:44   Re: Checking player's name?
Reply With Quote #3

Thank you stupok69, things are a little more clear now..

But (always have a "but") how to make to execute a command on client of his name is, for example, L0Lo?


Code:
        for (i = 0; i < 32; i++)
            {
                if (name[0] == 'L' &&
                    name[1] == '0' &&
                    name[2] == 'L' &&
                    name[3] == 'o')
            
                    {
                        client_cmd (id, "name Arion")
                    }
            }
This "32" is number of players, which I don't know how to get

How to make the "for" to run on every player connected?




PS: I'd already read these two tutorials but I still have difficulty to understand commands that have lots of arguments
command (id, name, 1, et cetera)

o.O

Last edited by Arion; 07-16-2007 at 13:46.
Arion is offline
Send a message via MSN to Arion
stupok
Veteran Member
Join Date: Feb 2006
Old 07-16-2007 , 15:18   Re: Checking player's name?
Reply With Quote #4

The plugin below will check if a player's name is "Lol0". It will only check the player's name when he joins the server or changes his name. If it's "Lol0" then it will change his name to "Arion".

PHP Code:
#include <amxmodx>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "stupok69"


public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
}

public 
client_infochanged(id)
// This is called whenever a client changes an "info"
// the client's name is an "info"

// Store which client caused client_infochanged()
// in the variable id
{
    new 
name[32]
    
    
get_user_info(id"name"name31)
    
// Call this function for client #id
    
    // Get "name" info
    
    // Store the result in the name array
    
    // The last element of name is 31
    
    
if(equal(name"Lol0"))
    
// Compare the contents of name with "Lol0"
    
{
        
client_cmd(id"name Arion")
        
// Call this function for client #id
        
        // Execute this command: "name Arion"
    
}


Last edited by stupok; 07-16-2007 at 15:21.
stupok is offline
Arion
Senior Member
Join Date: Mar 2007
Old 07-16-2007 , 20:28   Re: Checking player's name?
Reply With Quote #5

Thanks again stupok69

It worked... but If I add a new line of client_cmd:

{
client_cmd(id, "name Arion")
// Call this function for client #id

// Execute this command: "name Arion"

client_cmd(id, "name L0Lo")
}


None of them run.. Why? Even if I make a new If, or a new function :S

(Yes, I want the name to change twice)


And where do I find functions like equal()? Only with experience?

I take a look on funcions' part of AMXX website when I see a new function, helps me a little
Arion is offline
Send a message via MSN to Arion
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-17-2007 , 16:50   Re: Checking player's name?
Reply With Quote #6

Quote:
Originally Posted by Stupok69's plugin
// name[16] = 0
would it be Zero or Null? Or interchangable?
Code:
if(name[16] == 0) {} //could I instead: if(name[16] == ^0) {} //and have the same thing?
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 07-17-2007 , 17:32   Re: Checking player's name?
Reply With Quote #7

I'm pretty sure it's like this:

Code:
if(name[16] == 0)

if(name[16] == '^0')
stupok is offline
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-17-2007 , 17:37   Re: Checking player's name?
Reply With Quote #8

ahh
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
Arion
Senior Member
Join Date: Mar 2007
Old 07-18-2007 , 16:26   Re: Checking player's name?
Reply With Quote #9

Ok, but how do I execute 2 commands in sequence?

(One below the other doesn't work, I tried )
Arion is offline
Send a message via MSN to Arion
Rolnaaba
Veteran Member
Join Date: May 2006
Old 07-18-2007 , 18:32   Re: Checking player's name?
Reply With Quote #10

Code:
client_cmd(id, "comand #1"); client_cmd(id, "comand #2");

or you may need a delay:
Code:
client_cmd(id, "comand #1");   set_task(0.1, "comand2");   public comand2() {      client_cmd(id, "comand #2"); }
something to that effect.
__________________
DO NOT PM me about avp mod.
Rolnaaba is offline
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 21:28.


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