Jump to content

myonlake

Members
  • Posts

    2,312
  • Joined

  • Days Won

    41

Everything posted by myonlake

  1. myonlake

    Money...

    We gave you 100 examples and you haven't understood a single one of them? Give us a break. Test the money function by typing /ctest in-game. You should lose $100.00 and when you logout/quit the game, it will save your money. When you log in, it will return back your money. This is just an example, you must understand the code and please take time to read and understand it. Client-side addCommandHandler("ctest", function(cmd) triggerServerEvent("onMoneyTaken", localPlayer) end ) Server-side addEventHandler("onPlayerQuit", root, function(quitType, reason, responsibleElement) if isGuestAccount(getPlayerAccount(source)) then return end setAccountData(getPlayerAccount(source), "player:money", getPlayerMoney(source)) end ) addEventHandler("onPlayerLogout", root, function(previousAccount, currentAccount) if isGuestAccount(getPlayerAccount(source)) then return end setAccountData(getPlayerAccount(source), "player:money", getPlayerMoney(source)) end ) addEventHandler("onPlayerLogin", root, function(previousAccount, currentAccount, autoLogin) if getAccountData(currentAccount, "player:money") then setPlayerMoney(source, tonumber(getAccountData(currentAccount, "player:money"))) else setPlayerMoney(source, 200) end end ) addEvent("onMoneyTaken", true) addEventHandler("onMoneyTaken", root, function() takePlayerMoney(source, 100) end )
  2. myonlake

    Help

    Perhaps look at your own script before asking for help for every single thing you need. Client-side addEvent("onClientPlayerSerialFetched", true) addEventHandler("onClientPlayerSerialFetched", root, function(serial) guiSetText(aSerial, "Serial: " .. serial) end ) addEventHandler("onClientGUIClick", aGrid, function() local pRow = guiGridListGetSelectedItem(aGrid) if (pRow and pRow ~= -1) then triggerServerEvent("onClientPlayerSerialRequested", localPlayer, guiGridListGetItemText(aGrid, pRow, 1)) end end ) Server-side function findPlayer(name, player) if name == "*" and getElementType(player) == "player" and not isGuestAccount(getPlayerAccount(player)) then return player else local matches = {} for i,v in ipairs(getElementsByType("player")) do if getPlayerName(v) == name and not isGuestAccount(getPlayerAccount(v)) then return v end local playerName = getPlayerName(v):gsub("#%x%x%x%x%x%x", "") playerName = playerName:lower() if playerName:find(name:lower(), 0) and not isGuestAccount(getPlayerAccount(v)) then table.insert(matches, v) end end if #matches == 1 then return matches[1] end return false end end addEvent("onClientPlayerSerialRequested", true) addEventHandler("onClientPlayerSerialRequested", root, function(player) local target = findPlayer(player, source) if target then triggerClientEvent(source, "onClientPlayerSerialFetched", source, getPlayerSerial(getPlayerFromName(target))) else outputChatBox("DEBUG: 'onClientPlayerSerialRequested' returned false.", source, 245, 40, 40, false) end end )
  3. myonlake

    Help

    Is the playername listed on the first column?
  4. myonlake

    Help

    Forgot to remove it, I use it in my scripts and I added that to make sure the player is logged in. Does your gridlist have the names of the players on it? Also, are you logged in?
  5. myonlake

    Help

    Probably because the gridlist doesn't show his hex color codes if he has any and they have been removed by your script. Also if the gridlist shows partial names, it won't find the player. You can try the following code: Server-side function findPlayer(name, player) if name == "*" and getElementType(player) == "player" then return player else local matches = {} for i,v in ipairs(getElementsByType("player")) do if getPlayerName(v) == name and isLogged(v) then return v end local playerName = getPlayerName(v):gsub("#%x%x%x%x%x%x", "") playerName = playerName:lower() if playerName:find(name:lower(), 0) and isLogged(v) then table.insert(matches, v) end end if #matches == 1 then return matches[1] end return false end end addEvent("onClientPlayerSerialRequested", true) addEventHandler("onClientPlayerSerialRequested", root, function(player, row) local target = findPlayer(player, source) if target then triggerClientEvent(source, "onClientPlayerSerialFetched", source, getPlayerSerial(getPlayerFromName(target)), row) else outputChatBox("DEBUG: 'onClientPlayerSerialRequested' returned false.", source, 245, 40, 40, false) end end )
  6. If you mean your very own F11 map, then you can replace it easily from your /Multi Theft Auto 1.3/MTA/cgui/images/ folder. If you want to change everybody's map, then you'll have to do do some type of bind as uhm already mentioned.
  7. myonlake

    Help

    This means the player was not found.
  8. Don't start scripting if you don't know the basics of anything. https://wiki.multitheftauto.com/wiki/Scr ... troduction
  9. Perhaps don't make a table for all weapons if you don't want to change them from zero to anything. Only make a table for the weapons you want to change.
  10. Hmm, perhaps this? I haven't really worked around on separate MySQL resources so I don't know how they return values, sorry. addCommandHandler("testsql", function(player, cmd, uniqueid) local uniqueid = tonumber(uniqueid) if uniqueid then if mysql:query("SELECT `username` FROM `accounts` WHERE id = '" .. uniqueid .. "'") then triggerClientEvent(player, "onDataSelect", player, query.username) else outputChatBox("MySQL error.", player, 255, 0, 0, false) end else outputChatBox("Syntax: /" .. cmd .. " [unique id]", player, 255, 180, 0, false) end end )
  11. Thanks for the heads up, forgot to change that totally. You're right, edited my code.
  12. Tested it myself. Works perfectly. Client-side local spawnmarker = createMarker(1969.9000244141, -1517.8000488281, 970.79998779297, "cylinder", 2, 9, 30, 213, 255) addEventHandler("onClientMarkerHit", spawnmarker, function(hitElement, matchingDimension) if getElementType(hitElement) == "player" and matchingDimension then if not isElement(g_window) then g_window = guiCreateWindow(147, 141, 749, 548, "The Aviator Spawn Panel by Robbster", false) g_memo = guiCreateMemo(80,56,627,302,'Welcome to to the Aviators Airline Gamemode!t\n\n-----\nINFO\nINFO \nINFO\nINFO\n-------\n\nHere are the ranks\n\nA student pilot is 0 points : These can fly everything except the Andromada, AT-400, military planes and military helicopters (hydra/hunter)\n\nA Private pilot is 150 points : These can fly everything except the Andromada and AT-400, and military planes and helicopters (hydra/hunter) and flying with the shamal will be x1.5 the amount of money a student pilot earns\n\nA Commercial pilot is 250 points : These can fly everything except the military planes and helicopters (hydra/hunter)\n\nArmy pilots is 500 points : These can fly everything\nIn an airline, all airplanes of the airline can be used not matter what \"level\" you are.', false, g_window) g_label = guiCreateLabel(270, 398, 94, 46, "", false, g_window) g_button = guiCreateButton(280, 401, 194, 92, "Lets get to Work Pilot!", false, g_window) showCursor(true) addEventHandler("onClientGUIClick", g_button, function() setElementPosition(localPlayer, 1679.3029785156, 1446.3712158203, 11.043098449707) setCameraTarget(localPlayer) fadeCamera(true) destroyElement(g_window) showCursor(false) end , false) else guiBringToFront(g_window) end end end )
  13. Good try, but wrong. The camera would look very very annoying even at 50ms. The only way to do this is to use onClientPreRender. Not tested, should work though. Client-side lower = true function lowerCamera() local x, y, z = getElementPosition(localPlayer) setCameraMatrix(x, y, z - 2, x, y, z) end addEventHandler("onClientResourceStart", resourceRoot, function() addEventHandler("onClientPreRender", root, lowerCamera) end ) addCommandHandler("togcamera", function(cmd) lower = not lower if lower then removeEventHandler("onClientPreRender", root, lowerCamera) setCameraTarget(localPlayer) outputChatBox("Resetted camera position.", 0, 255, 0, false) else addEventHandler("onClientPreRender", root, lowerCamera) outputChatBox("Lowered camera position.", 0, 255, 0, false) end end )
  14. You can use triggers for the purpose. I made a small example script and I hope it works, can't see anything why it wouldn't. Try it out and change the MySQL query a little so it meets your tables. The script will make a command handler where you are supposed to enter a unique id in-game. For example /testsql 2. After that the script will send the information to the client-side code, which triggers the dxDrawText function. It should display the data we fetched. /testsql [unique id] Server-side addCommandHandler("testsql", function(player, cmd, uniqueid) local uniqueid = tonumber(uniqueid) if uniqueid then local query = mysql:query_free("SELECT username FROM users WHERE id = '" .. mysql:escape_string(uniqueid) .. "'") if query then triggerClientEvent(player, "onDataSelect", player, query.username) else outputChatBox("MySQL error.", player, 255, 0, 0, false) end else outputChatBox("Syntax: /" .. cmd .. " [unique id]", player, 255, 180, 0, false) end end ) Client-side addEvent("onDataSelect", true) addEventHandler("onDataSelect", root, function(username) _username = username addEventHandler("onClientRender", root, showUsername) if isTimer(datatimer) then killTimer(datatimer) end datatimer = setTimer(function() removeEventHandler("onClientRender", root, showUsername) end, 6500, 1) end ) function showUsername() dxDrawText("Fetched username: " .. _username, tx+150, ty+10, tx+size-500, ty, tocolor(0, 255, 0, 200), 0.7, "bankgothic", "center", "center", false, true, true, false, true) end
  15. Try this. A lot less lines and unnecessary stuff and should work, can't see why it wouldn't. Client-side local spawnmarker = createMarker(1969.9000244141, -1517.8000488281, 970.79998779297 , "cylinder", 2, 9, 30, 213, 255) addEventHandler("onClientMarkerHit", spawnmarker, function(hitElement, matchingDimension) if getElementType(hitElement) == "player" and matchingDimension then if not isElement(GUIEditor_Window[2]) then GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Label = {} GUIEditor_Window[2] = guiCreateWindow(147, 141, 749, 548, "The Aviator Spawn Panel by Robbster", false) GUIEditor_Memo[2] = guiCreateMemo(80,56,627,302,'Welcome to to the Aviators Airline Gamemode!t\n\n-----\nINFO\nINFO \nINFO\nINFO\n-------\n\nHere are the ranks\n\nA student pilot is 0 points : These can fly everything except the Andromada, AT-400, military planes and military helicopters (hydra/hunter)\n\nA Private pilot is 150 points : These can fly everything except the Andromada and AT-400, and military planes and helicopters (hydra/hunter) and flying with the shamal will be x1.5 the amount of money a student pilot earns\n\nA Commercial pilot is 250 points : These can fly everything except the military planes and helicopters (hydra/hunter)\n\nArmy pilots is 500 points : These can fly everything\nIn an airline, all airplanes of the airline can be used not matter what \"level\" you are.', false, GUIEditor_Window[2]) GUIEditor_Label[2] = guiCreateLabel(270, 398, 94, 46, "", false, GUIEditor_Window[2]) GUIEditor_Button[2] = guiCreateButton(280, 401, 194, 92, "Lets get to Work Pilot!", false, GUIEditor_Window[2]) showCursor(true) addEventHandler("onClientGUIClick", GUIEditor_Button[2], function(hitElement) setElementPosition(hitElement, 1679.3029785156, 1446.3712158203, 11.043098449707) setCameraTarget(hitElement) fadeCamera(true) destroyElement(GUIEditor_Window[2]) showCursor(false) end , false) else guiBringToFront(GUIEditor_Window[2]) end end end )
  16. How hard can it be. Client-side dxDrawText("#333333C#ffffffurrently #333333S#ffffffpectating:\n" .. getPlayerName(Spectate.target), 44, screenHeight - 43, screenWidth, screenHeight, tocolor(255, 255, 255, 255), 1, "pricedown", "left", "top", false, false, true, true, true)
  17. It works perfectly if you use it correctly. Remember to use the hex color code. Otherwise it won't work of course.
  18. dxDrawText function allows color codes nowadays. You can use that without any problems, do not use dxDrawColorText, which the Wiki also sets as deprecated.
  19. A very great example in how it should be done.
  20. You can always use exported functions or triggers if anything. There is no "object ID" for blood pools since they are not objects.
  21. I thought he is making an export system, which allows him to get functions from that system in another resources. Do forget my posts if I was wrong, but if he's going to use that function all over again in other resources many times then he should put it to a separate lua file and then set it both client and server-side.
  22. onClientKey, which is a client-side event.
  23. Your code has so much unnecessary things and small things to edit. Here you go. Should work perfectly fine, I don't see any errors as I have done the same code myself quite many times. If it doesn't work, make sure the resource is running, meta.xml is set and the script has been defined client-side. Perhaps give us your /debugscript 3 details if it still doesn't work. Client-side bindKey("F1", "down", function() if not isElement(GUIEditor_Window[1]) then -- GUI Tables GUIEditor_Window = {} GUIEditor_TabPanel = {} GUIEditor_Tab = {} GUIEditor_Button = {} GUIEditor_Label = {} -- GUI Window GUIEditor_Window[1] = guiCreateWindow(62, 60, 1549, 931, "US-RP (United States Roleplay)", false) guiSetAlpha(GUIEditor_Window[1], 1) guiWindowSetMovable(GUIEditor_Window[1], false) guiWindowSetSizable(GUIEditor_Window[1], false) showCursor(true) -- GUI Label GUIEditor_Label[1] = guiCreateLabel(20, 23, 1502, 153, "\n\nWelcome to United States Roleplay, where roleplay is made!\n\nThis is a 100% unique server! You can not find servers like this anywhere exept for here. We have the best staff, and the best scripts.\n\nPLEASE BE SURE TO READ ARE RULES SO YOU ARE NOT AT RISK OF BEING JAILED/MUTED/KICKED/BANNED!!!!!", false, GUIEditor_Window[1]) guiLabelSetHorizontalAlign(GUIEditor_Label[1], "center", true) -- GUI Tabs GUIEditor_TabPanel[1] = guiCreateTabPanel(293, 278, 991, 475, false, GUIEditor_Window[1]) GUIEditor_Tab[1] = guiCreateTab("About us", GUIEditor_TabPanel[1]) GUIEditor_Tab[2] = guiCreateTab("Rules", GUIEditor_TabPanel[1]) GUIEditor_Tab[3] = guiCreateTab("Staff", GUIEditor_TabPanel[1]) -- GUI Label GUIEditor_Label[2] = guiCreateLabel(14, 16, 964, 422, "First of all, we are the best server of ALL OF MTA AND SA-MP (SA-MP is :~)\n\nxXMADEXx (server owner) got sick of trying to find a new favorite server after being banned from is favorite one (RRC:RPG) for talking back to an admin.\n\n(He was talking back because the admin was being racist to Americans, his name is Khalil so give him :~ if you want to! We encourage you to give him a hard time)\n\nAnyway, this server was developed in 2012, and was releast to public (IDK).\n\n", false, GUIEditor_Tab[1]) guiLabelSetColor(GUIEditor_Label[2], 0, 100, 255) guiLabelSetHorizontalAlign(GUIEditor_Label[2], "center", false) guiSetFont(GUIEditor_Label[2], "clear-normal") -- GUI Button button = guiCreateButton(300, 773, 979, 143, "Exit Menu!", false, GUIEditor_Window[1]) guiSetFont(button, "sa-gothic") -- GUI events addEventHandler("onClientGUIClick", button, function() destroyElement(GUIEditor_Window[1]) showCursor(false) end, false) else destroyElement(GUIEditor_Window[1]) showCursor(false) end end )
×
×
  • Create New...