AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Find players name (https://forums.alliedmods.net/showthread.php?t=23037)

SweatyBanana 01-09-2006 08:10

Find players name
 
Ok...heres what im doing:

Making a plugin that changes anyones name that is "Player" by default, it will change it to something else.

I just need to know how to find if they persons name is player...other than that, I am almost done with this plugin...I am hoping to make it for all mods because i keep playing in DOD and CS servers that ask people with the name "Player" to change their name.

Please and Thank you.

Sandurr 01-09-2006 08:22

Code:
public client_putinserver(id) {      new name[32]      get_user_name(id,name,sizeof(name))      if(equali(name,"Player")) {           new newname[32]           format(newname,31,"ChangeName")           set_user_info(id,"name",newname)      }      return PLUGIN_HANDLED } public client_infochanged(id) {      new name[32]      get_user_name(id,name,sizeof(name))      if(equali(name,"Player")) {           new newname[32]           format(newname,31,"ChangeName")           set_user_info(id,"name",newname)      }      return PLUGIN_HANDLED }

Brad 01-09-2006 09:27

Alternately, stop reinventing the wheel and use something like Restrict Names since it has the ability to do exactly what you're trying to do.

SweatyBanana 01-09-2006 11:09

Well brad...you could just tell me nicely that it has already been made...

Thanks...i was hoping that i would be the first to make it.

XxAvalanchexX 01-09-2006 16:42

Sandurr, sizeof(name) will return 32. Putting 32 digits into a 32 sized array doesn't save space for the string terminator. sizeof(name)-1 would be correct.

sodiumchloride91 01-09-2006 18:35

Ermm...
 
Ermm....I havent saw the 'sizeof' function before. Where did you found it.
Can't find it in the doc.

So i only make it like this.

Quote:

new name[32]

get_user_name(id, name, 31)
I think that will do just the same, rite?

XxAvalanchexX 01-09-2006 19:41

I don't think sizeof is a native.

Anyway, yes, that would be the same. There isn't much of a point to using sizeof if you already know the size of the array, unless you plan on changing it and don't want to change two numbers at once.

Brad 01-09-2006 19:51

Re: Ermm...
 
Quote:

Originally Posted by sodiumchloride91
Ermm....I havent saw the 'sizeof' function before. Where did you found it.

It's in the Pawn documentation. I believe it's defined on page 58.

Unidentified 01-09-2006 21:41

Re: Ermm...
 
Quote:

Originally Posted by sodiumchloride91
Ermm....I havent saw the 'sizeof' function before. Where did you found it.
Can't find it in the doc.

So i only make it like this.

Quote:

new name[32]

get_user_name(id, name, 31)
I think that will do just the same, rite?

Yes, It will function. Unless 32 users come onto the server. Bailopan one day said that It subtracts one.
So the correct way to do this would be.

new name[33];

You would also have to change your get_user_name.

get_user_name(id, name, 32)

XxAvalanchexX 01-09-2006 22:14

The size of the name array has nothing to do with the player count.


All times are GMT -4. The time now is 16:13.

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