Hello!
I'm new on the MTA community, I'm coming from SAMP. Actually I'm developing an RP Server, and I'm new here so I have some questions.
I'm developing a RP Server using MySQL. For the login I'm using, at the end, this function:
addEvent("onPlayerAttemptLogin",true)
addEventHandler("onPlayerAttemptLogin",root,
function(username,password)
if (singleQuery("SELECT * FROM accounts WHERE username=? LIMIT 1",string.lower(username))) then
local accData = singleQuery("SELECT * FROM accounts WHERE username=? AND password=? LIMIT 1",string.lower(username),sha256(password))
if (accData) then
setPlayerName(source, username)
outputChatBox("Welcome again, "..getPlayerName(source),source,0,255,0)
setElementData(source,"accountID",accData.id)
setElementData(source,"accountUsername",accData.username)
fadeCamera(source,false,1.0,0,0,0)
setTimer(fadeCamera,2000,1,source,true,1.0,0,0,0)
setCameraTarget(source,source)
showChat(source,true)
spawnPlayer(source,accData.x,accData.y,accData.z+1,accData.rotation,accData.skin,accData.interior,accData.dimension)
local weapons = fromJSON(accData.weapons)
if (weapons) then
for k,v in pairs(weapons) do
giveWeapon(source,tonumber(k),tonumber(v))
end
end
if (accData.health == 0) then
killPed(source)
else
setElementHealth(source,tonumber(accData.health))
end
setPedArmor(source,tonumber(accData.armor))
setPlayerMoney(source,tonumber(accData.money))
setElementData(source,"isGuestAccount",false)
triggerClientEvent(source,"closeLoginWindow",source)
triggerEvent("onAccountPlayerLogin",source,accData.id,accData.username)
log(source) --store the login data.
else
outputChatBox("The username or the passwords are incorrect.",source,255,0,0)
end
else
outputChatBox("The username entred does not exist.",source,255,0,0)
end
end)
The question is, is there a way to set the username without using setPlayerName(source, username) to prevent this?:
Or there's a way to prevent the text message?
Another question is, how I can share data from scripts? For example I want to link the login with a house system (for example) that is in another resource file.
There's a way to do it? Thanks!