Jump to content

myonlake

Members
  • Posts

    2,312
  • Joined

  • Days Won

    41

Everything posted by myonlake

  1. Hello there, I was thinking of a random sound fetching from a table with math.random function and decided to try it. However, instead of playing the songs, it gives me an error about that attachElements, which could be relative to the table stuff, something wrong there? By the way, this is not the whole script and it wouldn't help much even if I did give you that. It's somewhere here. I have everything in meta.xml and in the server side. local soundtable = { "images/mmmp.mp3", "images/cv.mp3", "images/rr.wav", "images/mn.mp3", "images/wwd.mp3" } function musicpod(source) local x, y, z = getElementPosition(source) local m3d = playSound3D(math.random(#soundtable), x, y, z, false) setSoundVolume(m3d, 0.5) setSoundMaxDistance(m3d, 50) attachElements(m3d, source) end addEvent("onPodClick", true) addEventHandler("onPodClick", getRootElement(), musicpod)
  2. You had a little mess with the scripts there, fixed some small things and added spaces to make it easier for you to recognize the numbers from the number spam. However, you had few missing addEventHandlers for the GUIs and possibly that's the reason why it didn't show up. And for your information, 'localPlayer' is 1.1 afterwards been an built-in abbrevation for getLocalPlayer() This is the current version, I might make some changes to it. Command to open the skin selection screen: /skins local playerName = getPlayerName(localPlayer) local sx, sy = guiGetScreenSize() local thisRoot = getResourceRootElement(getRootElement()) local root = getRootElement() function createShopWindow() guiSkinShop = guiCreateWindow(0.37 * sx, 0.80 * sy, 0.3 * sx, 0.15 * sy, "Choose a skin!", false) guiWindowSetSizable(guiSkinShop, false) guiSetVisible(guiSkinShop, false) guiCreateStaticImage(0.0001, 0.49, 0.99, 0.02, "red.png", true, guiSkinShop) guiCreateStaticImage(0.0001, 0.25, 0.99, 0.02, "red.png", true, guiSkinShop) done = guiCreateButton(0.25, 0.60, 0.50, 0.30, "Done", true, guiSkinShop) left = guiCreateButton(0.07, 0.60, 0.15, 0.30, "<-", true, guiSkinShop) right = guiCreateButton(0.78, 0.60, 0.15, 0.30, "->", true, guiSkinShop) skinLabel = guiCreateLabel(0.05, 0.30, 0.90, 0.17, "Skins can be bought once in game", true, guiSkinShop) guiLabelSetHorizontalAlign(skinLabel, "center", false) guiSetFont(skinLabel, "default-bold-small") guiLabelSetColor(skinLabel, 255, 255, 255) guiSetAlpha(skinLabel, 1) addEventHandler("onClientGUIClick", right, goRight, false) addEventHandler("onClientGUIClick", done, doneButton, false) addEventHandler("onClientGUIClick", left, goLeft, false) end addEventHandler("onClientResourceStart", thisRoot, createShopWindow) function createLoginWindow(title, logo, content) local xml = xmlLoadFile("server.xml") local content = xmlNodeGetValue(xml) windowLogin = guiCreateWindow(0.02 * sx, 0.05 * sy, 0.4 * sx, 0.8 * sy, "Xeno's Login System", false) guiSetSize(windowLogin, 270, 400, false) guiWindowSetSizable(windowLogin, false) guiCreateMemo(01, 170, 500, 220, content, false, windowLogin) guiSetAlpha(windowLogin, 1) labelUsername = guiCreateLabel(10, 52, 59, 24, "Username:", false, windowLogin) guiSetAlpha(labelUsername, 1) guiLabelSetColor(labelUsername, 255, 255, 255) guiLabelSetVerticalAlign(labelUsername, "center") guiLabelSetHorizontalAlign(labelUsername, "left", false) labelPassword = guiCreateLabel(10, 86, 59, 24, "Password:", false, windowLogin) guiSetAlpha(labelPassword, 1) guiLabelSetColor(labelPassword, 255, 255, 255) guiLabelSetVerticalAlign(labelPassword, "center") guiLabelSetHorizontalAlign(labelPassword, "left", false) labelInfo = guiCreateLabel(10, 26, 250, 17, "Please login or register.", false, windowLogin) guiSetAlpha(labelInfo, 1) guiLabelSetColor(labelInfo, 255, 255, 255) guiLabelSetVerticalAlign(labelInfo, "top") guiLabelSetHorizontalAlign(labelInfo, "center", false) guiSetFont(labelInfo, "default-bold-small") editUsername = guiCreateEdit(79, 52, 181, 25, "", false, windowLogin) guiSetAlpha(editUsername, 1) guiEditSetMaxLength(editUsername, 50) editPassword = guiCreateEdit(79, 86, 181, 25, "", false, windowLogin) guiSetAlpha(editPassword, 1) guiEditSetMasked(editPassword, true) guiEditSetMaxLength(editPassword, 50) buttonLogin = guiCreateButton(10, 121, 117, 21, "Log in", false, windowLogin) guiSetAlpha(buttonLogin, 1) buttonRegister = guiCreateButton(149, 121, 117, 21, "Register", false, windowLogin) guiSetAlpha(buttonRegister, 1) guiCreateStaticImage(0.0001, 0.370, 0.99, 0.006, "red.png", true, windowLogin) guiCreateStaticImage(0.0001, 0.415, 0.99, 0.006, "red.png", true, windowLogin) newsLabel = guiCreateLabel(0.35, 0.372, 0.300, 0.17, "Server News", true, windowLogin) guiSetAlpha(newsLabel, 1) guiLabelSetColor(newsLabel, 255, 255, 255) guiCreateStaticImage(0.0001, 0.11, 0.99, 0.006, "red.png", true, windowLogin) guiCreateStaticImage(0.0001, 0.06, 0.99, 0.006, "red.png", true, windowLogin) guiLabelSetHorizontalAlign(newsLabel, "center", false) guiSetFont(newsLabel, "default-bold-small") guiSetVisible(windowLogin, false) showChat(false) addEventHandler("onClientGUIClick", buttonLogin, clientSubmitLogin, false) addEventHandler("onClientGUIClick", buttonRegister, showReg, false) end function createRegisterWindow() regMenu = guiCreateWindow(0.357 * sx,0.05 * sy,0.33 * sx,0.3 * sy, "Register Menu", false) guiCreateStaticImage(0.0001, 0.13, 0.99, 0.010, "red.png", true, regMenu) guiCreateStaticImage(0.0001, 0.25, 0.99, 0.010, "red.png", true, regMenu) guiWindowSetSizable(regMenu, false) guiSetAlpha(regMenu, 1) guiSetVisible(regMenu, false) regUsername = guiCreateLabel(10, 52, 59, 24, "Username:", false, regMenu) guiSetAlpha(regUsername, 1) guiLabelSetColor(regUsername, 255, 255, 255) guiLabelSetVerticalAlign(regUsername, "center") guiLabelSetHorizontalAlign(regUsername, "left", false) editRegUsername = guiCreateEdit(70, 52, 181, 25, "", false, regMenu) guiSetAlpha(editRegUsername, 1) guiEditSetMaxLength(editRegUsername, 50) regPassword = guiCreateLabel(10, 86, 59, 24, "Password:", false, regMenu) guiSetAlpha(regPassword, 1) guiLabelSetColor(regPassword, 255, 255, 255) guiLabelSetVerticalAlign(regPassword, "center") guiLabelSetHorizontalAlign(regPassword, "left", false) editRegPassword = guiCreateEdit(70, 86, 181, 25, "", false, regMenu) guiSetAlpha(editRegPassword, 1) guiEditSetMasked(editRegPassword, true) guiEditSetMaxLength(editRegPassword, 50) regComPassword = guiCreateLabel(10, 122, 59, 24, "*Email:", false, regMenu) guiSetAlpha(regComPassword, 1) guiLabelSetColor(regComPassword, 255, 255, 255) guiLabelSetVerticalAlign(regComPassword, "center") guiLabelSetHorizontalAlign(regComPassword, "left", false) editEmail = guiCreateEdit(70, 120, 181, 25, "", false, regMenu) guiSetAlpha(editEmail, 1) guiEditSetMasked(editEmail, true) guiEditSetMaxLength(editEmail, 50) buttonReg = guiCreateButton(10, 150, 120, 21, "Register", false, regMenu) guiSetAlpha(buttonReg, 1) buttonCan = guiCreateButton(143, 150, 117, 21, "Cancel", false, regMenu) guiSetAlpha(buttonCan, 1) labelRegister = guiCreateLabel(10, 26, 250, 17, "Register with a user and pass here.", false, regMenu) guiSetAlpha(labelRegister, 1) guiLabelSetColor(labelRegister, 255, 255, 255) guiLabelSetVerticalAlign(labelRegister, "top") guiLabelSetHorizontalAlign(labelRegister, "center", false) guiSetFont(labelRegister, "default-bold-small") addEventHandler("onClientGUIClick", buttonCan, cancelWindow, false) addEventHandler("onClientGUIClick", buttonReg, clientSubmitRegister, false) end function showSkinSelection() local state = guiGetVisible(guiSkinShop) if state == false then guiSetVisible(guiSkinShop, true) else guiSetVisible(guiSkinShop, false) end end addCommandHandler("skins", showSkinSelection) function cancelWindow() guiSetVisible(regMenu, false) end function resourceStart() createLoginWindow() if (windowLogin ~= nil) then guiSetVisible(windowLogin, true) else outputChatBox("An error has occurred.") end showCursor(true) guiSetInputEnabled(true) end function changePw() createPasswordWindow() guiSetVisible(windowChangepw, true) showCursor(true) guiSetInputEnabled(true) end function clientSubmitLogin(button, state) if button == "left" and state == "up" then local username = guiGetText(editUsername) local password = guiGetText(editPassword) if username and password then showChat(true) triggerServerEvent("submitLogin", getRootElement(), localPlayer, username, password) else guiSetText(labelInfo, "Enter username and password.") end end end function showReg(button, state) guiSetVisible(regMenu, true) end function clientSubmitRegister(button, state) if button == "left" and state == "up" then local username = guiGetText(editRegUsername) local password = guiGetText(editRegPassword) if username and password then showChat(false) triggerServerEvent("submitRegister", getRootElement(), localPlayer, username, password) end end end function clientSubmitChangepw(button, state) if button == "left" and state == "up" then local oldpassword = guiGetText(editOldpw) local newpassword = guiGetText(editNewpw) if oldpassword and newpassword then triggerServerEvent("submitChangepw", getRootElement(), localPlayer, oldpassword, newpassword) else outputChatBox("Enter old and new password.") end end end function hideLoginWindow() guiSetInputEnabled(false) guiSetVisible(windowLogin, false) showCursor(false) guiSetVisible(regMenu, false) setTimer(guiSetVisible, 3100, 1, guiSkinShop, true) showCursor(true) end function hideLoginWindow1() guiSetInputEnabled(false) guiSetVisible(windowLogin, false) showCursor(false) guiSetVisible(regMenu, false) call(getResourceFromName("guiText"),"outputGuiText","[RPG] You have been logged in!",255,0,0) end function hidePasswordWindow() guiSetInputEnabled(false) guiSetVisible(windowChangepw, false) showCursor(false) end function unknownError() guiSetText(labelInfo, "An unknown error occured.") end function loginWrong() guiSetText(labelInfo, "Wrong username and/or password.") end function registerTaken() guiSetText(labelRegister, "This username is in use.") end function goRight(player) local newSkin = getElementModel(localPlayer) + 1 while not setElementModel(localPlayer, newSkin) do newSkin = newSkin + 1 end end
  3. MySQL server is suggested by me (xampp)
  4. Oh, right... dayum. I thought it was so simple..
  5. MySQL is permanent and is only available on server-side. Account data is half-permanent and is only available on server-side. Element data is not permanent and is available on both sides. XML is permanent and is available on both sides. setAccountData setElementData Links XML Functions MySQL Module
  6. Hello there, I've been trying to make a fireworks script which seems to be a little bit hardcored though.. So, the problem is that the marker doesn't move there. function startshow(player, cmd) local launch1 = createMarker(95.51, 101.06, 2.07, "corona", 2, 255, 255, 80, 155) local blip1 = createBlipAttachedTo(launch1, 0, 2, 255, 255, 255, 255) setTimer(launch, 1000, 1, launch1, blip1) end addCommandHandler("startshow", startshow) function launch(launch1, blip1) moveObject(launch1, 2000, 94, 103, 30, 0, 0, 0, "OutQuad") setTimer(destroyElement, 2000, 1, blip1) setTimer(createExplosion, 2000, 1, 2000, 94, 30, 0) end
  7. myonlake

    Scripting help

    I did that at the first time, I just copied the example from wiki. This is the wrong board to put the thread, however, I'd like to see the lines from 0-10.
  8. myonlake

    no warp!

    function warpMe(targetPlayer) local interior = getElementInterior(targetPlayer) setElementInterior(source, interior) setCameraInterior(source, interior) if getElementData(targetPlayer, "IsWarpLocked") then outputChatBox("The player you want to warp to has locked warping.", source, 255, 0, 0, false) return end if isPedDead(source) then spawnMe() end local vehicle = getPedOccupiedVehicle(targetPlayer) if not vehicle then -- target player is not in a vehicle - just warp next to him local x, y, z = getElementPosition(targetPlayer) clientCall(source, 'setPlayerPosition', x + 2, y, z) else -- target player is in a vehicle - warp into it if there's space left if getPedOccupiedVehicle(source) then --removePlayerFromVehicle(source) outputChatBox('Get out of your vehicle first.', source) return end local numseats = getVehicleMaxPassengers(vehicle) for i=0,numseats do if not getVehicleOccupant(vehicle, i) then if isPedDead(source) then local x, y, z = getElementPosition(vehicle) spawnMe(x + 4, y, z + 1) end warpPedIntoVehicle(source, vehicle, i) return end end outputChatBox("No free seats left in " .. getPlayerName(targetPlayer) .. "'s vehicle.", source, 255, 0, 0) end end addCommandHandler("lockwarp", function(player) setElementData(player, "IsWarpLocked", true) end) addCommandHandler("unlockwarp", function(player) removeElementData(player, "IsWarpLocked") end)
  9. Hello everyone, I am not one hundred per cent sure, but I think my maps from 1.1 are outputting some numbers and empty lines to the console. Any way fixing this? I cannot follow the chat discussion or errors in the console.
  10. MTA doesn't run on any engine. MTA is just a modification for GTA games. GTA:SA is made with RenderWare game engine.
  11. Then the source doesn't have that data. Make a check like this: if loses and wins then -- stuff here else -- stuff here end
  12. Are you sure you've put it on client side? Check if the meta.xml is type="client".
  13. Just set the trailer's position like X+1 or such.
  14. You need to add it in the meta.xml aswell.
  15. Who's "she"? ... ever heard of a sexuality jokes before? -.- - Make sure you don't slip over in the bathroom. - That's what she said! - Did you have hard time yesterday? - That's what she said! - I only do stupid things at home. - That's what she said!
  16. function start() executeSQLCreateTable("RaceStats", "serial STRING, RaceWins INT, RaceLoses INT") end addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), start) function onPlayerJoinLoadStats() local serial = getPlayerSerial(source) local result = executeSQLSelect("RaceStats", "*", "serial = '" .. tostring(serial) .. "'") if (type(result) == "table" and #result == 0) or not result then setElementData(source, "Race Wins", tonumber(re[1]["RaceWins"]) or 0) setElementData(source, "Race Loses", tonumber(re2[1]["RaceLoses"]) or 0) else executeSQLInsert("RaceStats", "'" .. tostring(serial) .. "', '0', '0', '0', '0'") end end addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoinLoadStats) function publicstatsinfo() local askdname = getPlayerName(source) local wins = getElementData(source, "Race Wins") local loses = getElementData(source, "Race Loses") outputChatBox("* You won " .. wins .. " times and you losed " .. loses .. " times", source, 255, 12, 15) end addEvent("stats", true) addEventHandler("stats", getRootElement(), publicstatsinfo) function checkCommand(message, messageType) if (messageType == 0) then if (message == "!stats") then cancelEvent() setTimer(triggerEvent, 100, 1, "stats", source) end end end addEventHandler("onPlayerChat", getRootElement(), checkCommand) function DestructionMoney2() local alivePlayers = getAlivePlayers() if info == "Destruction derby" then if #alivePlayers == 1 then local playername = getPlayerName(alivePlayers[1]) local serial = getPlayerSerial(alivePlayers[1]) local oldData = executeSQLSelect( "RaceStats", "RaceWins","serial = '" .. serial .. "'") local oldData = executeSQLSelect( "RaceStats", "RaceWins","serial = '" .. serial .. "'") newData = tonumber(oldData[1]["RaceWins"]) + 1 setElementData(alivePlayers[1], "Race Wins", tonumber(getElementData(alivePlayers[1], "Race Wins")) + 1) executeSQLUpdate("RaceStats", "RaceWins = '" .. newData .. "'","serial = '" .. serial .. "'") outputChatBox(getPlayerName(alivePlayers[1] ) .. " is the last player alive!", rootElement, 0, 255, 0) end end end addEventHandler("onPlayerWasted", getRootElement(), function() local serial = getPlayerSerial(source) local oldData = executeSQLSelect("RaceStats", "RaceLoses", "serial = '" .. serial .. "'") setElementData(source, "Race Loses", tonumber(getElementData(source, "Race Loses")) + 1) newData = tonumber(oldData[1]["RaceWins"]) + 1 executeSQLUpdate("RaceStats", "RaceLoses = '" .. newData.. "'","serial = '" .. serial .. "'") end)
  17. myonlake

    Why don't work?

    No problem, remember to specify the special function names first
  18. myonlake

    Why don't work?

    In the first script version you showed us, you had a problem with the rootElement stuff. Script always runs the non-functions first, then functions. The local was inside the function, so the event cannot reach the data because it's triggered after the event is started. It outputs an error. Here you hadn't specified the 'database:' and 'scoreboard:'. That's why you need to put tables for it. --[[ -- made by Shick -- credits to -------- for helping -- 22/12/2011 --]] -- getResourceRootElement local gRR_Element = getResourceRootElement(getThisResource()) local database = { } local scoreboard = { } -- SQL Database function database:SQLTable() executeSQLCreateTable ( 'Money', 'player_serial STRING, money INT' ) executeSQLCreateTable ( 'Points', 'player_serial STRING, points INT' ) addEventHandler('onResourceStart', gRR_Element, database:SQLTable ) -- Dx Scoreboard function scoreboard:addAColumn() call(getResourceFromName('dxscoreboard'), "addScoreboardColumn", "Money") call(getResourceFromName('dxscoreboard'), "addScoreboardColumn", "Points") end addEventHandler('onResourceStart', gRR_Element, scoreboard:addAColumn )
  19. myonlake

    Help pls.

    He just made the GUI, and he's asking for help with the rest. That's right, and with a GUI editor. How hard can that be? You need to make the events and functions yourself... GUI scripting is basically the easiest part in LUA.
  20. Everything that you crypt can be encrypted. At the moment, highest SHA crypt haven't been encrypted yet.
  21. No need for events for markers or such if you want to create it on start. local casinoMarker = createMarker(1966, 1026, 991, "cylinder", 2, 255, 0, 0, 128) setElementInterior(casinoMarker, 10) addEventHandler("onMarkerHit", getRootElement(), function(hitElement, matchingDimension) if (getElementType(hitElement) == "player") then if (source == casinoMarker) then triggerClientEvent(hitElement, "viewInfoGUIWindow", hitElement, "Casino\n\nBuy ticket?") end end end )
×
×
  • Create New...