Hello, I'm wondering how to check whether an RPName already exists in DarkRP, I'm currently doing this below, which is what I saw in some DarkRP Forum Thread, but it doesn't seem to work, not sure what I'm doing wrong, any help would be appreciated!
for k, v in pairs( player.GetAll() ) do
local alreadytaken = sql.Query( "SELECT rpname FROM darkrp_player WHERE uid = '"..v:UserID().."'" )
for a, b in pairs(alreadytaken) do
if charname:GetValue() == b then
charname:SetText( "That RP name is already taken!")
else
net.Start( "ChangeRPName" )
net.WriteString( charname:GetValue() )
net.SendToServer()
if IsValid(bg) then
bg:Remove()
end
end
end
end
[ERROR] addons/character-creation/lua/autorun/client/cc_vgui.lua:4: bad argument #1 to 'pairs' (table expected, got boolean)
1. pairs - [C]:-1
2. DoClick - addons/character-creation/lua/autorun/client/cc_vgui.lua:4
3. unknown - lua/vgui/dlabel.lua:232
alreadytaken will return false instead of a table when your query is invalid - change UserID to SteamID64.
Alright, changed it to SteamID64, but still seem to get the same error as above?
you need to do this serverside, not client sided.
Only way that wouldn't work is if the player hasn't declared a unique rpname (used the /rpname command) - otherwise, it will just use their Steam name.
DarkRP already prevents one from having the same name as another through /name. The only way to overcome this is if you join a server with the same name as another person on the server. So you can find it through the DarkRP repository on GitHUB.
Sorry, you need to Log In to post a reply to this thread.