• How can I make a check for the player name lenght?
    3 replies, posted
Hey, I use the DarkRP Variable "rpname" and I want to generate a lenght check for it. My Code: playername = (LocalPlayer():getDarkRPVar("rpname")) playernamel = #playername if playername < playernamel(16) then draw.SimpleText(playername,"FontArial",ScrH() - 630,ScrH() - 145,Color(205, 0, 0),TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP) elseif playername > playernamel(16) then draw.SimpleText("Name too long","FontArial",ScrH() - 630,ScrH() - 145,Color(205, 0, 0),TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP) end
First: localise the vars. Second: It works like that: playernamel > 16 Please learn basic lua https://www.lua.org/
local playername=LocalPlayer():Name() if playername:len()<16 then draw.SimpleText(playername,"FontArial",ScrH()-630,ScrH()-145,Color(205,0,0),TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP) else draw.SimpleText("Name too long","FontArial",ScrH()-630,ScrH()-145,Color(205,0,0),TEXT_ALIGN_LEFT,TEXT_ALIGN_TOP) end by the way in darkrp the player:Name() meta function returns their RP name rather than their steam name like it does in sandbox
Hey, thanks for the answer it worked! I know, I'm new in Lua Coding, I'll check the basics. To your first point, I did it local, but I thought local means it's outside my if statement so I removed the local. Cheers
Sorry, you need to Log In to post a reply to this thread.