Jump to content

Need sql help :/


Agressivelol

Recommended Posts

Hi

function ach1() 
local players = getElementsByType ( "player" ) -- get a table of all the players in the server 
for k,v in ipairs(players) do 
local serial = getPlayerSerial(v) 
local yx    = executeSQLSelect ( "Mysqltable", "yx","serial = '" .. serial .. "'") 
if yx == 1 then 
outputChatBox ( "1", getRootElement(), 255, 0, 0, true ) 
elseif yx == 0 then 
outputChatBox ( "0", getRootElement(), 255, 0, 0, true ) 
else 
local pn = getPlayerName(v) 
outputChatBox ( "#ffff00**"..pn.."#ffff00 else", getRootElement(), 255, 0, 0, true ) 
triggerClientEvent ( "onGreeting", getRootElement(), "Hello World!" ) 
  
end 
end 
end 

its rude but how to get it work like

yx is sql value and how to check it ? like if xy == 1 then blabla but it isnt working atM :/

sorry for terrible english -.- need sleep :wink:

Link to comment
local result = executeSQLSelect ( "Mysqltable", "yx","serial = '" .. serial .. "'") 
if ( type( result ) == "table" and #result == 0 ) or not result then 
  -- there is no such rows, or sql execution failed 
else 
  if result[1]["yx"] == 1 then -- first row (1), column called "yx" (as you can select multiple columns on one query) 
    -- and i'm not sure if it will return integer number or string on select - maybe you have to write == "1" 
  end 
end 

edit: wiki is your friend

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...