Raised This Month: $ Target: $400
 0% 

auto-name change problem


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xiaojian
Member
Join Date: Jan 2009
Location: the world's end
Old 10-14-2010 , 00:05   auto-name change problem
Reply With Quote #1

Use rename.ini file to change one's name,rename.ini is like this
PHP Code:
;currentname newname
name1 newname1
name2 newname2 

Last edited by xiaojian; 11-07-2010 at 00:50.
xiaojian is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-14-2010 , 00:33   Re: need help,Thanks
Reply With Quote #2

Well, try to go through the loop to understand...

You're changing the player name to default name on each fail to compare the name, you should use somethnig to detect if the name wasn't changed.

Code:
new bool:changed = false

for(new i =0; i < g_totalNames; i++)
{
   if(equali(name, g_szName[i]))
   {
      set_user_info(id, "name", g_NewName[i])
      changed = true /* note that the name was changed */
      break /* stop the loop */
   }
}

if(!changed) /* if player's name wasn't in the list, set to default name */
   set_user_info(id, "name", g_DefaultName)
You should also stick to hungarian notation or NOT, because you note some and some not... wich is quite confusing.

You should also provide a informative title about what the problem is, I was one step away from skipping this thread if I wasn't so bored :}
__________________
Hunter-Digital is offline
Old 10-14-2010, 02:36
xiaojian
This message has been deleted by xiaojian.
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-14-2010 , 04:05   Re: need help,Thanks
Reply With Quote #3

A short name about the thread's text, that's a title, in your case: "naming problem", "name loop problem", "auto-name change problem", etc.

This is scripting help not requests and you obviously didn't learn anything since you just placed my code inside a loop when I deliberly posted the loop so you'll see that there are some things that must NOT be in the loop... but now you're back to your initial problem.

And client_infochanged() is called when a player changes his name... or any other information using setinfo or such, you might want to search for the corect info getting methods.
__________________
Hunter-Digital is offline
xiaojian
Member
Join Date: Jan 2009
Location: the world's end
Old 10-14-2010 , 04:19   Re: auto-name change problem
Reply With Quote #4

i chaged the title.
when a player changes his name,my idea is :if his new name isn't in the name list of name.ini ,then plugin handled.
xiaojian is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-14-2010 , 04:20   Re: auto-name change problem
Reply With Quote #5

Then why do you keep changing it to default name ?
Do you even understand what those codes do ?
__________________
Hunter-Digital is offline
xiaojian
Member
Join Date: Jan 2009
Location: the world's end
Old 10-14-2010 , 05:08   Re: auto-name change problem
Reply With Quote #6

Quote:
Originally Posted by Hunter-Digital View Post
Then why do you keep changing it to default name ?
Do you even understand what those codes do ?
i just wonder why
if (equali(name, g_szName[i]))
{
//
}
else
{
//
} is useless.
i want to learn how to make it sense.
xiaojian is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-14-2010 , 05:18   Re: auto-name change problem
Reply With Quote #7

Quote:
Originally Posted by xiaojian View Post
i just wonder why
if (equali(name, g_szName[i]))
{
//
}
else
{
//
} is useless.
i want to learn how to make it sense.
Quote:
Originally Posted by Hunter-Digital View Post
You're changing the player name to default name on each fail to compare the name ...
I guess you don't understand LOOPS, that code is executed multiple times, and if you use an else and change the name there, it would change the name every time the if() is not true, it's logic.

I also added comments to the code to reinforce the information.

And I didn't said it's useless, I just explained your issue.

If you don't really know anything about amxx scripting I recommend you start reading the pawn tutorial: http://wiki.amxmodx.org/Pawn_Tutorial
__________________

Last edited by Hunter-Digital; 10-14-2010 at 05:21.
Hunter-Digital is offline
xiaojian
Member
Join Date: Jan 2009
Location: the world's end
Old 10-14-2010 , 05:44   Re: auto-name change problem
Reply With Quote #8

Quote:
Originally Posted by Hunter-Digital View Post
I guess you don't understand LOOPS, that code is executed multiple times, and if you use an else and change the name there, it would change the name every time the if() is not true, it's logic.

I also added comments to the code to reinforce the information.

And I didn't said it's useless, I just explained your issue.

If you don't really know anything about amxx scripting I recommend you start reading the pawn tutorial: http://wiki.amxmodx.org/Pawn_Tutorial
thank you!

Last edited by xiaojian; 11-07-2010 at 00:51.
xiaojian 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 10:28.


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