-
Posts
827 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Cadu12
-
http://www.w3schools.com/sql/sql_orderby.asp
-
function updateRank() for i, v in ipairs(getElementsByType("player")) do if getElementData(v, "guest_") ~= 1 then local res = sqlC:query("SELECT * FROM accounts WHERE username='"..getElementData(v, "username_").."'") if res then local result = mysql_fetch_assoc(res) local rank = sqlC:query("SELECT * FROM accounts WHERE points>='" .. result["points"].."'") local r = mysql_fetch_assoc(rank) if r then setElementData(v, "Rank", r["points"]) end end end end end
-
libmysql.dll is only in "server" folder, and mta_mysql.dll is only in "modules" folder.
-
Navegando pelos elementos de uma tabela
Cadu12 replied to Stanley Sathler's topic in Tutoriais em geral
Esqueça que criar novo table no table? Por exemplo: local tables = {} tables["frutas"] = { "maca", "laranja", "banana", "melancia", "ameixa" } for i, nome_fruta in ipairs(tables["frutas"]) do outputChatBox(nome_fruta) end (Nao testei) -
It's just compiled Lua using LuaC. no just put it in gameplay and try it on the game and see .. MOJRM-511 is a hack he's trying to hack by this code . What is your problem? I dont see his problem. Can you post a screenshot about his script, please?
-
Stole script. We wont help who is steal.
-
You're welcome
-
It worked for me, in my host. It's mysql_fetch_assoc
-
function loginHandler(username,password) local result = mysql_query(handler, "SELECT * FROM accounts WHERE accname='" .. username .. "' AND accpassword='" .. password .. "'") local row = mysql_fetch_assoc(result) if(result)then outputChatBox("You have successfully logged in!", client, 0, 255, 0) setElementData(client, "logged", 1) setElementData(client, "account:admin", tonumber(row["admin"])) local AStatus = tonumber(row["admin"]) if (AStatus == 1) then outputChatBox("You are playing as a PR Moderator.", client, 0, 0, 255) elseif (AStatus == 2) then outputChatBox("You are playing as a PR Administrator.", client, 0, 0, 255) elseif (AStatus == 3) then outputChatBox("Welcome back, Phoenix.", client, 0, 0, 255) end return true else outputChatBox("Your username and/or password is incorrect!", client, 255, 0, 0) triggerClientEvent(client, "displayLogin", getRootElement()) return false end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler) Try my code, I tested in my localhost.
-
Try use https://wiki.multitheftauto.com/wiki/Mod ... _fetch_row Should work
-
Im not sure, but maybe use "row[1]["admin"]" at 2 and 3 lines.
-
Hmm, try my code, if it didnt worked, try debug with outputChatLog
-
restriction = {} function findPlayer(namepart) for i, player in ipairs(getElementsByType("player")) do local name = getPlayerName(player) local name2 = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") if string.find(name:lower(), namepart:lower(), 1, true) then return player, name elseif string.find(name2:lower(), namepart:lower(), 1, true) then return player, name end end return false end function luck(player, cmd, who) if (not restriction[player]) then restriction[player] = {} end if not restriction[player][cmd] then if who then local target = findPlayer ( who ) if target then outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky "..getPlayerName(target).."!", root, 255, 255, 255, true) restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) end else outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky!", root, 255, 255, 255, true) restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) end else outputChatBox("#FF0000You must wait #FFFFFF5 seconds#FF0000 to write this command again.", player, 255, 255, 255, true) end end addCommandHandler("lu", luck)
-
restriction = {} function luck(player, cmd, who) if (not restriction[player]) then restriction[player] = {} end if not restriction[player][cmd] then if tostring(who) then local target = getPlayerFromName ( who ) if target then outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky "..getPlayerName(target).."!", root, 255, 255, 255, true) restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) end else outputChatBox("#FFFFFF".. getPlayerName(player) .."#5DACD1 say: Lucky!", root, 255, 255, 255, true) restriction[player][cmd] = true setTimer(function () restriction[player][cmd] = false end, 5000, 1) end else outputChatBox("#FF0000You must wait #FFFFFF5 seconds#FF0000 to write this command again.", player, 255, 255, 255, true) end end addCommandHandler("lu", luck) Nick with colors wont work, you have to make your own getPlayerFromName.
-
setElementData(client, "logged", 1) setElementData(client, "account:admin", tonumber(row["admin"]) or 3) local AStatus = tonumber(row["admin"]) or 3 if (AStatus == 1) then outputChatBox("You are playing as a PR Moderator.", client, 0, 0, 255) elseif (AStatus == 2) then outputChatBox("You are playing as a PR Administrator.", client, 0, 0, 255) elseif (AStatus == 3) then outputChatBox("Welcome back, Phoenix.", client, 0, 0, 255) end Did you forget about tonumber? ;/
-
row[1]["accname"] or row["accname"] Not tested it.
-
I thought it was "password" column, sorry, did it worked?
-
Hmm, is there 'password' column in your mysql(?), try check it.
-
Try my code, I edited it.
-
function loginHandler(username,password) local row = mysql_query(handler, "SELECT * FROM accounts WHERE accname='" .. username .. "' AND password='" .. password .. "'") if row then outputChatBox("You have successfully logged in!", client, 0, 255, 0) mysql_free_result(row) return true else outputChatBox("Your username and/or password is incorrect!", client, 0, 255, 0) triggerClientEvent(client, "displayLogin", getRootElement()) return false end end addEvent("submitLogin",true) addEventHandler("submitLogin",root,loginHandler)
-
We don't accept request here. Also stop posting for request.
-
local row = mysql_query( handler, "SELECT * FROM `accounts` WHERE accname = '"..username.."' AND password = '" .. password .. "'" ); if( mysql_num_rows( row ) == 1 ) then return true else return false end