change name

i have 2 questions
1 - How do i change a players name
2 - How do i search for certain letters in a players name

1- do i change a players name like this


 ply:SetName("John Doe")

2 - Do i search for certain letters in a players name like


if ply:Nick() == "joe" then

thats searching for joe in a name joeycorasd

for 1, you have to detour the name functions (like :GetName(), :Nick(), etc)

for 2,

string.find

so could i do


if string.find( ply:GetName(), "joe", 0, false ) then

Change that false to true (although it shouldn’t matter much).

I’m not sure whether it works in an if statement, but you can easily test that yourself :wink:

Try printing its results, once on a successful find, and once on a failed find. See what you get.

i am trying that and thanks

[editline]13th March 2015[/editline]

it doesnt work as an if statement, but i need it to, any help?

[editline]13th March 2015[/editline]

could i maybe do this


if ply:Nick(string.find( ply:Name(), "yd", -1, true )) == true then

although it still does nothing

What does string.find return when no match is found?

it just prints No Match Found

No it doesn’t. What’s your code?

not that code but the one i have


function Test( ply )
	if ply:Nick(string.find( ply:Name(), "yd", -1, true )) == true then
	print("No Match Found!")
	
	end
end

What the hell did you do to your code? :S

[lua]function Test( ply )
if string.find( ply:Name(), “yd”, 1, true ) then
– name includes “yd”
else
– name doesn’t include “yd”
end
end[/lua]

wait so that code you just made works?

I didn’t test it but it should work.

You already posted it before, I have no idea why you changed it since then (except for changing false to true like I suggested). If you had only tried it, you’d see that it works.