GUI is triggering it from client side.
function clientSubmitLogin(button,state)
if button == "left" and state == "up" then
local parole = guiGetText(edtUser)
if parole then
triggerServerEvent("submitLogin", getRootElement(), parole)
guiSetInputEnabled(false)
guiSetVisible(wdwLogin, false)
showCursor(false)
else
outputChatBox("Lūdzu ievadiet paroli.")
end
end
end
amm.. i thought that source is always the element who triggers the function.
FIXED!!!!
I just add a trigger argument to the event and used it as player variable. Now it works well. Thanks for responses.
Hey, users. I have a problem here, its about login with mysql. It shows a error and i cant fix it, thats why i'm asking for help. So here's the code
function loginHandler(parole)
if parole then
if (client) then
local res = mysql_query(sqlConnection,"SELECT * FROM users WHERE Name='"..getPlayerName(source).."' AND Pass='"..parole.."'")
if res then
if(mysql_num_rows(res)>0) then
while true do
local row = mysql_fetch_assoc(res)
if(not row) then break end
spawn(client)
setPlayerMoney(client,row["Money"])
setElementModel(client,row["Skin"])
end
mysql_free_result(res)
else
outputChatBox("Nepareiza parole!",source)
triggerClientEvent("ShowLoginGUI",client)
end
end
end
else
outputChatBox("Ievadiet paroli.",client)
triggerClientEvent("ShowLoginGUI",client)
end
end
And the error
Error: server.lua:71: attempt to concatenate a boolean value
this is the error line
local res = mysql_query(sqlConnection,"SELECT * FROM users WHERE Name='"..getPlayerName(source).."' AND Pass='"..parole.."'")
No, thats not what i want..
Ah.. You don't understand me.
I know, about control structures..
I want to know about mysql in MTA scripting...
In sa-mp pawno it will be like this, without mysql. But i want to know how can server get info from sql database.
if(PlayerData[playerid][pFaction] == 1)
{
SendClientMessage(playerid, ORANGE, "Hello, officer! Have a good day, Sir!");
return 1;
}
else
{
SendClientMessage(playerid, RED, "You are not a Police officer!");
return 1;
}
Above code in MTA... Not from .xml files account base, but from mySQL database.
So, i want to know how can i check if player is bla bla bla, from mySQL..
In sa-mp that is something like this
if(PlayerInfo[playerid][pFraction] == 1)
{
blablabla
}
else
{
Shows that you cant use that command, or what.
}
--------------------
And I want to know how can i make this in MTA?
So, i am learning that scripting thing and that all stuff, and i want some account system with MySQL database.
And i want some tutorial, how to create that thing with mysql database, i have already created user files in that database, only thing i need is that lua script. Maybe someone can give me an example for that. I will really appreciate that. Thanks
No, it doesn't work. That showChat function disables/enables all chat, i can't type anything when ir disabled... And all chat box dissapears, maybe there is some other function to disable it?
Thanks for helping, and i have a question. How to disable the original chat? I made a another chat with radius and when i type something it shows two lines, the one with radius and the other one without it( Original )
and where can i make commands? In resources or Gamemode? I just created a command in fr_server, restart resource and command didn't worked. Or maybe i need it to make it in fr_client?
Command must work, i take it from wiki
function showLocalHealth()
-- get the player's health and output it
local playerHealth = getElementHealth ( getLocalPlayer() )
outputChatBox ( "Your health: " .. playerHealth )
-- get the player's vehicle: if he is in one, output its health as well
local playerVehicle = getPedOccupiedVehicle ( getLocalPlayer() )
if playerVehicle then
local vehicleHealth = getElementHealth ( playerVehicle )
outputChatBox ( "Your vehicle's health: " .. vehicleHealth )
end
end
addCommandHandler ( "showhealth", showLocalHealth )
Ok, now it works and i have another question. If the server is online and resource is running, i can edit resource while its running, and save it after edit? or i need to turn off my server or stop resource?
Hah, i just start to script MTA, learning from wiki n' stuff, but when i edit a script, save it and start the server that edited script edits back to normal, like i translate ir from english to my language. Server starts, my translated line translates back to normal.. I edited original freeroam resource. Used Lua for windows.
Can someone can tell me how to do it right?
My english is not too good