Jump to content

FlyingSpoon

Members
  • Posts

    749
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by FlyingSpoon

  1. local endtime = 0 local function renderCountdown ( ) local lefttime = endtime - getTickCount() if lefttime > 0 then dxDrawText(math.ceil ( lefttime ), screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) elseif lefttime >= -3000 then dxDrawText("GO!", screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) else removeEventHandler ( "onClientRender", root, renderCountdown ) end end addCommandHandler ( "timer", function ( _, timeinsec ) endtime = getTickCount() + timeinsec * 1000 -- To save the time when the countdown will end addEventHandler ( "onClientRender", root, renderCountdown ) end ) attempt to perform arithmetic on local 'timeinsec' (a nil value)
  2. local endtime = 0 local function renderCountdown ( ) local lefttime = endtime - getTickCount() if lefttime > 0 then dxDrawText(math.ceil ( lefttime ), screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) elseif lefttime >= -3000 then dxDrawText("GO!", screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) else removeEventHandler ( "onClientRender", root, renderCountdown ) end end addCommandHandler ( "test", function ( _, timeinsec ) endtime = getTickCount() + timeinsec * 1000 -- To save the time when the countdown will end addEventHandler ( "onClientRender", root, renderCountdown ) end ) Doesn't display my time left.
  3. Bonus, how can I create a timer using your script to do a countdown, so the player can see how long is left.
  4. screenX,screenY = guiGetScreenSize() function startTheClock () systemUpTime = 2000 --Store the system tick count, this will be 0 for us currentCount = getTickCount () dxDrawRectangle (screenX *.40, screenY * .09, 250, 50, tocolor(0,0,0,150)) dxDrawText ( currentCount - systemUpTime, screenX * .48, screenY * .1, screenX, screenY, tocolor(255,255,255), 2) end addEventHandler ( "onClientRender", root, startTheClock )
  5. How can I create a 2 minute timer, using getTickCount() on DX Text? Someone help please!
  6. How can I create a timer, and do like a countdown of 2 minutes on Dx Text?
  7. Full Tutorial! Need any help comment in the video:
  8. I don't understand how it works, so I was thinking maybe someone can explain it to me, because I dont understand the Wiki.
  9. How can I use interpolateBetween or something similar so my Dx Window with everything linked to it opens. Can anyone show me an example? Thanks! local screenW, screenH = guiGetScreenSize() addEventHandler("onClientRender", root, function() dxDrawRectangle(screenW * 0.0947, screenH * 0.1784, screenW * 0.8369, screenH * 0.6445, tocolor(62, 62, 62, 255), false) dxDrawRectangle(screenW * 0.0947, screenH * 0.1654, screenW * 0.8369, screenH * 0.0638, tocolor(0, 0, 0, 255), false) dxDrawText("#MvP!", screenW * 0.1045, screenH * 0.1771, screenW * 0.1846, screenH * 0.2161, tocolor(255, 136, 8, 255), 2.00, "sans", "left", "top", false, false, false, false, false) dxDrawText("Dashboard", screenW * 0.1846, screenH * 0.1771, screenW * 0.3154, screenH * 0.2161, tocolor(255, 255, 255, 255), 2.00, "sans", "left", "top", false, false, false, false, false) dxDrawRectangle(screenW * 0.3076, screenH * 0.2474, screenW * 0.6143, screenH * 0.5521, tocolor(255, 255, 255, 197), false) dxDrawImage(screenW * 0.3174, screenH * 0.2539, screenW * 0.5947, screenH * 0.2839, ":mvpDashboard/images/home.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawRectangle(screenW * 0.1025, screenH * 0.2474, screenW * 0.2002, screenH * 0.0521, tocolor(90, 90, 90, 255), false) dxDrawRectangle(screenW * 0.1025, screenH * 0.3073, screenW * 0.2002, screenH * 0.0521, tocolor(90, 90, 90, 255), false) dxDrawRectangle(screenW * 0.1025, screenH * 0.3672, screenW * 0.2002, screenH * 0.0521, tocolor(90, 90, 90, 255), false) dxDrawRectangle(screenW * 0.1025, screenH * 0.4271, screenW * 0.2002, screenH * 0.0521, tocolor(90, 90, 90, 255), false) end ) I want to make this all bounce in/open using interpolate animation! Thanks.
  10. Error(s) Outputted: When someone tries to login... Line 40: "Expected player at argument 1, got nil" Also when someone does press the login it makes the other players login as well! LUA CODE addEvent("playerWantToLogin",true) addEventHandler("playerWantToLogin",root, function(userName,Password) if not (userName == "") then if not (Password == "") then callRemote("[LINK]", function(response, extra, player, userName, Password) if response == true then checkLoginCallback("success", player, userName, Password) outputDebugString("Succesfully logged in (MySQL)!") else if extra == 1 then outputDebugString(toJSON({"Wrong Password!"})) elseif extra == 2 then outputDebugString(toJSON({"User doesnt exist!"})) end end end, "verifyPasswords", source, userName, Password) else outputChatBox("** Please enter your password! **", source, 191, 99, 0 ) end else outputChatBox("** Please enter your Username! **", source, 191, 99, 0 ) end end) function checkLoginCallback(gAccount, player, userName, Password) if gAccount == "success" then if not getAccount (userName) then acc = addAccount(tostring(userName),tostring(Password)) end if not getAccount(userName,Password) then setAccountPassword(getAccount(userName),Password) end local acc = getAccount ( userName,Password) if(not isGuestAccount(acc)) then logOut(player); end logIn (player, acc, Password) triggerClientEvent("loginHide", getRootElement()) outputChatBox("** You have logged in! **", player, 191, 99, 0 ) end end PHP CODE <?php // PHP include 'mta_sdk.php'; // Correct path if you use a different one $servername = "localhost"; // Change these details $username = "**********"; // Change these details $password = "**********"; // Change these details $dbname = "**********"; // Change these details $table = "mvp_core_members"; $accountColumn = "name"; // change to "email" if you prefer logging in through email $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { mta::doReturn(false, "Connection failed: " . mysqli_connect_error()); // Account not found #die("Connection failed: " . mysqli_connect_error()); } $input = mta::getInput(); if (isset($input[0]) && isset($input[2]) && isset($input[3]) && $input[0] == "verifyPasswords" ) { $sql = "SELECT `members_pass_salt`, `members_pass_hash` FROM `".$table."` WHERE `".$accountColumn."`='".strtolower($input[2])."' LIMIT 1"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { $row = mysqli_fetch_assoc($result); if (crypt($input[3], '$2a$13$' . $row['members_pass_salt']) == $row['members_pass_hash']) { mta::doReturn(true, 0, $input[1], $input[2], $input[3]); // Password correct } else { mta::doReturn(false, 1); // Passwords don't match } } else { mta::doReturn(false, 2); // Account not found } } // Author: MrTasty ?>
  11. function addServerAccount(username, password) callRemote("[LINK]", function(response, extra) if response == true then addAccount(username, password) logIn(source, username, password) triggerClientEvent("loginHide", getRootElement()) else outputDebugString("Something went wrong!") end end, "verifyPasswords", username, password) end Outputs something went wrong
  12. Say if I was to use givePlayerMoney(source, 500) Would I be able to use the callRemote to save data and fetch data from the database? If yes, can I have an example? UPDATE: Say if I was to do this for each account, would this work? function getPlayerGroup(username) local groupID = callRemote("[LINK]", callbackFunction, "databaseExec", "SELECT `member_group_id` FROM `mvp_core_members` WHERE `name`= ?",username) outputChatBox(groupID, source, 209, 125, 0) end addEvent("getPlayerGroup",true) addEventHandler("getPlayerGroup",getRootElement(),getPlayerGroup) Bad argument @ 'callRemote' [Expected string at argument 2, got nil] Bad argument @ 'outputChatBox' [Expected string at argument 1, got boolean]
  13. Exactly, I know the internal money system, but I was worried.. that how would I save the actual money and then get it again, because we're using remote's here.
  14. I know I haven't used callRemote before, but like how would I get data for each separate account? Say if I did this, function getPlayerMoney() callRemote("[LINK]", callbackFunction, "databaseExec", "SELECT `money` FROM `mvp_core_members`") end ('I created the column already') How would I actually like do it for the actual accounts in the database?
  15. Okay, so I have done that, now I can do this right? callRemote("[Link]", callbackFunction, "databaseExec", UPDATE `mvp_core_members` SET `somecolumn`='somedata')
  16. Where would I put that? UPDATE: Like this? if ($_SERVER['REMOTE_ADDR'] == "IP of the server on which MTA is running") { else if (isset($input[0]) && isset($input[1]) && $input[0] == "databaseExec") { // this is the first line of the addition mta::doReturn(mysqli_query($conn, $input[1])); } }
  17. What if I was to change the file name completely so it's not guessable. e.g. login_x9204949dlg.php
  18. Also, one more thing, what if I want to update tables in the Database, how would I go about doing that?
  19. You said something to me like dont use 'name' instead use 'members_seo_name' ?
  20. mta::doReturn(true, 0); // Password correct After this?
  21. Thank you so much, this helped a lot. One last question how can I fetch data like, say if I want to save money, because I see this is all done via callRemote, say if I was to save money in the database, how would I get that type of data?
  22. Got it to work! I accidentally used the wrong mta_sdk.php (MACOSX) Which was the wrong one.
  23. <?php // PHP include 'mta_sdk.php'; // Correct path if you use a different one $servername = "localhost"; // Change these details $username = "forum"; // Change these details $password = "******"; // Change these details $dbname = "forum"; // Change these details $table = "mvp_core_members"; $accountColumn = "name"; // change to "email" if you prefer logging in through email $conn = mysqli_connect($servername, $username, $password, $dbname); if (!$conn) { mta::doReturn(false, "Connection failed: " . mysqli_connect_error()); // Account not found #die("Connection failed: " . mysqli_connect_error()); } $input = mta::getInput(); if (isset($input[0]) && isset($input[1]) && isset($input[2]) && $input[0] == "verifyPasswords" ) { $sql = "SELECT `members_pass_salt`, `members_pass_hash` FROM `".$table."` WHERE `".$accountColumn."`='".strtolower($input[1])."' LIMIT 1"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { $row = mysqli_fetch_assoc($result); if (crypt($input[2], '$2a$13$' . $row['members_pass_salt']) == $row['members_pass_hash']) { mta::doReturn(true, 0); // Password correct } else { mta::doReturn(false, 1); // Passwords don't match } } else { mta::doReturn(false, 2); // Account not found } } // Author: MrTasty ?>
×
×
  • Create New...