Jump to content

Need sql help :/


Agressivelol

Recommended Posts

Posted

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:

Posted
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

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

Posted

The Order For Person-correctly-using-quote-feature is going to you, Agressivelol, congratulations!

Really, I'm impressed :P

If you don't get my message - simply ignore it ^^

Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online!

programista php rzeszów

Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting.

Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!

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...