Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SQL:
- 1.SELECT * FROM Orders WHERE OrderDate >= '2000-01-01'
- 2.SELECT * FROM Customers ORDER BY ContactName DESC;
- 3.SELECT * FROM Customers WHERE City = 'Mexico' AND CustomerName LIKE '%M%';
- 4.SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID = Customers.CustomerID WHERE Customers.CustomerName = 'Alfreds Futterkiste';
- 5.SELECT DISTINCT City FROM Customers;
- 6.SELECT Customers.CustomerName, Orders.OrderID, Orders.OrderDate FROM Orders RIGHT JOIN Customers ON Orders.CustomerID = Customers.CustomerID ORDER BY Orders.OrderID;
- 7.SELECT COUNT(*) AS TotalOrders FROM Orders;
- 8.SELECT Customers.CustomerName, COUNT(*) AS 'Total Orders' FROM Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID WHERE Customers.CustomerName = 'Around the Horn';
- 9.UPDATE Customers CONCAT(LEFT(PostalCode, 0), 'A', SUBSTRING(PostalCode, 1));
- 10.Two Queries:
- DELETE FROM Orders WHERE CustomerID IN (SELECT DISTINCT CustomerID FROM Customers WHERE City = 'London');
- DELETE FROM Customers WHERE City = 'London';
- OR
- DELETE Customers, Orders FROM Customers INNER JOIN Customers WHERE Customers.CustomerID = Orders.CustomerID AND Customers.City = 'London'
- Question 1:
- LOCAL tab = {
- {"Maxime", 5000},
- {"aaufppxf4", 2323},
- {"Sibrecht", 1},
- {"Smith", 542},
- {"Mickel", 542},
- {"Theno", 425},
- {"Mirazoka", 54200}
- }
- LOCAL output = "" -- The output string, still not formatted.
- FOR i=1, TABLE.getn(tab) do -- Vertical loop dynamically based on size of table.
- FOR j=1, TABLE.getn(tab[i]) do -- Horizontal loop dynamically based on size of each group within the table.
- IF(j%2 > 0) THEN
- output = tab[i][j] -- First index due to remainder.
- ELSE
- output = string.format("%s - %u", output, tab[i][j]) -- Second index as there is no remainder.
- END
- END
- outputChatBox(output) -- mfw i didn't even have to make a loop to send to all players and get playercount.
- END
- -- A different method, common easier approach using lua (made this after i felt more familiar with the language now):
- FOR i=1, TABLE.getn(tab) do -- Vertical loop dynamically based on size of table.
- outputChatBox(tab[i][1] .. " - " .. tab[i][2])
- END
- Question 2:
- LOCAL tab = {
- {"Maxime", 5000},
- {"aaufppxf4", 2323},
- {"Sibrecht", 1},
- {"Smith", 542},
- {"Mickel", 542},
- {"Theno", 425},
- {"Mirazoka", 54200}
- }
- FUNCTION whatthefuck(player, command, VALUE)
- IF tonumber(VALUE) ~= nil THEN -- Check on value being numeric or nah.
- FOR i=1, TABLE.getn(tab) do
- IF(tab[i][2] > VALUE) THEN -- Check on value before output.
- outputChatBox(tab[i][1] .. " - " .. tab[i][2], player)
- END
- END
- ELSE
- outputChatBox("The value must be numeric.", player)
- END
- END
- addCommandHandler("show", whatthefuck)
- Question 3:
- FUNCTION sort(a,b) -- holy fuck lua's sorting functions are great
- RETURN a[2] < b[2]
- END
- FUNCTION whatthefucklol(player, command, VALUE)
- TABLE.sort(tab, sort) -- this is genius
- FOR i=1, TABLE.getn(tab) do
- outputChatBox(tab[i][1] .. " - " .. tab[i][2], player)
- END
- END
- addCommandHandler("showall", whatthefucklol)
- Question 4:
- FUNCTION herp(player, command, INPUT)
- IF(INPUT == '' OR INPUT == nil) THEN RETURN FALSE END -- Empty/Nil returns false.
- IF(INPUT:MATCH("%W")) THEN RETURN FALSE END -- Contains non-alphanumeric characters, %w is used to test on alphanumeric.
- IF(INPUT:MATCH("%s")) THEN RETURN FALSE END -- Contains a space character.
- IF(string.len(INPUT) <= 3 OR string.len(INPUT) >= 10) THEN RETURN FALSE END -- Input equal to or smaller than 3 or equal to and larger than 10, opposite of requirements.
- RETURN TRUE
- END
- addCommandHandler("randie", herp)
- Question 5:
- addCommandHandler("stats", FUNCTION(thePlayer)
- outputChatBox("IP: " .. getPlayerIP(thePlayer) .. ".")
- outputChatBox("Serial: " .. getPlayerSerial(thePlayer) .. ".")
- END)
- Question 6:
- FUNCTION LuckyPay()
- LOCAL luckyPlayer = getRandomPlayer()
- givePlayerMoney(luckyPlayer, 5000)
- outputChatBox("You have been randomly chosen and won $5000! UAT is great and you should suck our dick.", luckyPlayer)
- outputChatBox("Player ID " .. luckyPlayer .. " has won $5000, UAT is great, fuck you.")
- END
- addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), FUNCTION()
- setTimer(LuckyPay, 3600000, 0)
- END)
- Question 7:
- addCommandHandler("ring", FUNCTION()
- playSound3D("ringtone.mp3", getElementPosition(localplayer))
- END)
- Question 8:
- addCommandHandler("ringnearby", FUNCTION()
- LOCAL tone = playSound3D("ringtone.mp3", getElementPosition(localplayer))
- setSoundMaxDistance(tone, 30)
- END)
- Question 9:
- FUNCTION toglocks(thePlayer)
- guiSetVisible(window, FALSE)
- showCursor(FALSE)
- car = getPlayerOccupiedVehicle(thePlayer)
- IF(car == 0) THEN RETURN FALSE END
- setVehicleLocked(car, bit.bxor(isVehicleLocked(car), 1)) -- Equivalent of setVehicleLocked(car, not isVehicleLocked(car)), bitwise xor.
- END
- FUNCTION togengine(thePlayer)
- guiSetVisible(window, FALSE)
- showCursor(FALSE)
- car = getPlayerOccupiedVehicle(thePlayer)
- IF(car == 0) THEN RETURN FALSE END
- setVehicleEngineState(car, NOT getVehicleEngineState(car))
- END
- addCommandHandler("carcontrols", FUNCTION(thePlayer)
- window = guiCreateWindow(0.375, 0.375, 0.25, 0.25, "Please Log In", TRUE) -- The GUI positions are random pretty much, cba to test them myself in game and repetitively change them.
- locks = guiCreateButton(0.415, 0.4, 0.2, 0.2, "Lock/Unlock", TRUE, window)
- engine = guiCreateButton(0.435, 0.4, 0.2, 0.2, "Start/Stop Engine", TRUE, window)
- showCursor(TRUE)
- addEventHandler("onClientGUIClick", locks, toglocks, FALSE) -- Naturally I'd choose that the event handlers call upon one function with a parameter which decides whether it's the engine or the locks but I have no idea how to do that here.
- addEventHandler("onClientGUIClick", engine, togengine, FALSE)
- END)
- Question 10:
- addCommandHandler("getgun", FUNCTION(thePlayer)
- IF isElementInRange(thePlayer, 0, 0, 0, 10) THEN
- giveWeapon(thePlayer, 22) -- Spawns a colt with 30 ammo to the player.
- ELSE
- outputChatBox("You are not in the gun spawning area.", thePlayer)
- END
- END)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement