Jump to content

LabiVila

Members
  • Posts

    272
  • Joined

  • Last visited

Everything posted by LabiVila

  1. LabiVila

    GUI Scoreboard

    Sorry for going off topic but why don't you make a dx scoreboard? It's not harder, it just takes a bit more time but it's worth it...
  2. Funny how I got exactly the same problem, yet can't seem to find the solution
  3. Are you sure your modules are rightly placed? Try doing /loadmodule mta_mysql.dll or mta_mysql.so for linux and tell us what you get
  4. local host = "127.0.0.1" local user = "root" local pass = "" local db = "ps" connect = dbConnect ("mysql", "dbname = "..db.."; host = "..host, user, pass) if connect then local query = dbQuery (connect, "SELECT * FROM `members`") if query then outputChatBox ("query finalizing") else outputChatBox ("no query") end local poll = dbPoll (query, -1) if poll then outputChatBox ("poll found") else outputChatBox ("poll not found") end else outputChatBox ("fail") end so I get the error at 'local poll = dbPoll (query, -1)', and in my outputChatBox I see 'poll not found', any kind of help? EDIT: Solved, for all you who get into this problem, removing spaces from dbConnect solves your problem
  5. LabiVila

    GUI msg

    Hello there, first of all you've set: triggerServerEvent("onMessagePM",lp,msgPMText,choosedPlayer) - two arguments there, 'msgPMText' and 'choosedPlayer', while at server you have set 5 arguments, from there you can understand source == msgPMText and command == chosedPlayer, all other stuff is turned nil (choosedPlayer from serverside is nil, so is msgPMText and those three dots which I don't know why they are even there). So try fixing the arguments. Secondly, choosedPlayer is defined in client side, so 're-defining' it server side would make totally no sense. You either define it client side or server side, not both (getPlayerFromName (choosedPlayer)). Here I would as well suggest you to use https://wiki.multitheftauto.com/wiki/Ge ... artialName as it is much more advanced and useful, ignores color codes and stuff like that. Third, your lines 13 and 14 aren't so useful, you can't make a 'player name' receive the text, it must be a player element. so instead of your line 13 & 14, use these: outputChatBox("[PM] PM to " .. choosedPlayer .. ": " .. msgPMText, source, 255, 0, 0, false) outputChatBox("[PM] PM from " .. getPlayerName(source) .. ": " .. msgPMText, getPlayerFromName(choosedPlayer), 255, 215, 0, false) outputChatBox ("PM to "..getPlayerFromName (choosedPlayer)..": "..msgPMText, source, 255, 0, 0, false) outputChatBox ("PM from "..getPlayerName (sourceplayer)..": "..msgPMText, choosedPlayer, 255, 0, 0, false) make sure to define sourceplayer, an easy way is to trigger that lp from client side
  6. you should declare on top of your script this: local x,y = guiGetScreenSize () then after that you do that do this: spalteGuiImage[1] = guiCreateStaticImage(0, (270/600)*x, (160/800)*y, (24.04/600)*x, "images/scrollmenu_1.png",false) you should do this for every image and stuff in your script, and don't forget, 6th argument is false
  7. So hey, what I need is something to return decimal numbers, so if I have a number like: 1.34123, I need a function to return two strings, first one the number before decimals (1) and second string (34123 - the decimal numbers). I'm not expecting the full function, I just need a hand as I have no clue what to use Thanks in advance
  8. Okay I totally get it, thank you so much
  9. Awesome, it's working startCount was triggered 'onRaceStateChanging (state == "running")', however, I tried settingut = 0 but it didn't work, shouldn't it?
  10. addEvent ("startCount", true) addEventHandler ("startCount", getRootElement(), function () ableToStart = true if (ableToStart == true) then addEventHandler ("onClientRender", getRootElement(), drawYourtime) end end ) function handlerOnStart () ableToStart = false if (ableToStart == false) then removeEventHandler ("onClientRender", getRootElement(), drawYourtime) end end addEvent ("onClientMapStarting", true) addEventHandler ("onClientMapStarting", getRootElement(), handlerOnStart) function drawYourtime () if not ut then ut = getTickCount () end aut = getTickCount () yourTime = formatMilliseconds (aut - ut) dxDrawText (yourTime, 1275, 35, x, y, tocolor (255, 255, 255, 200), 1, "default-bold") end I want 'yourTime' to reset everytime the map changes, but it's actually continuing where it left off, any help?
  11. And how can I fix that? Any tip maybe? As far as I know, it should be absolute coordinates, shouldn't it?
  12. Thanks for answering, I see it was my bad for not writing the reason (I'm surprised with myself lol, I thought I did)... however, the code is working so well, however, it doesn't fit in every screen resolution. It is supposed to fit every, but I really don't know what's wrong. I've already searched a lot of topics about this but couldn't really find the problem (almost all were same as mine)
  13. Bumping this, I've been told to not but... I have no reason to repost it
  14. You can even open it with notepad
  15. local keys = {} function isMouseInPosition ( x, y, width, height ) if ( not isCursorShowing ( ) ) then return false end local sx, sy = guiGetScreenSize ( ) local cx, cy = getCursorPosition ( ) local cx, cy = ( cx * sx ), ( cy * sy ) if ( cx >= x and cx <= x + width ) and ( cy >= y and cy <= y + height ) then return true else return false end end addEventHandler ("onClientResourceStart", getRootElement(), function () showCursor (true) end ) function isClickingOnRectangle (button, state) local position = isMouseInPosition (350, 350, 150, 200) if position and (state == "down") then addEventHandler ("onClientCharacter", getRootElement(), insertCharsInTable) bindKey ("backspace", "down", removeLastChar) else removeEventHandler ("onClientRender", getRootElement(), insertCharsInTable) unbindKey ("backspace", "down", removeLastChar) end end addEventHandler ("onClientClick", getRootElement(), isClickingOnRectangle) function insertCharsInTable (charac) table.insert (keys, charac) end function removeLastChar () local lastNum = table.maxn (keys) table.remove (keys, lastNum) end function drawIt () local sentence = table.concat (keys, "") dxDrawRectangle (350, 350, 150, 35, tocolor (255, 255, 255, 150)) if sentence then dxDrawText (sentence, 400, 354, x, y, tocolor (255, 255, 255), 1.2, "default-bold") end end addEventHandler ("onClientRender", getRootElement (), drawIt) function mouseDrawingLine () dxDrawRectangle (355, 353, 2, 30, tocolor (0, 0, 0, 100)) end addEventHandler ("onClientRender", getRootElement(), mouseDrawingLine) Have a look at this, it's a way how edit works. It was made so fast but you can look at the example, and make your own. Make sure you have to click on the rectangle to be able to write on it. Then the way to get the text from there is by table.concating the whole table keys
  16. LabiVila

    Question

    You have absolutely no clue about LUA, go read and stop crying, it won't get you a good result. How can we help you with a MGM when you have no clue even how to create a working file? I already told you a post to create a MGM, you want one on a silver plate? Well, you won't have it
  17. Well thanks for taking time and reading that first, I've fixed it by adding a command handler server-side, and it worked (surprisingly), then if you may notice, 'res' isn't a player element, it is the name of the resource (defined in server side). Checked meta again, it's 'gamemodes', not 'gamemode' (yes I don't understand why would they do that either). Thanks anyway EDIT: I won't bump again, sorry
  18. local fonts = dxCreateFont ("fonts.ttf", 20) local x,y = guiGetScreenSize () local nm function mapInformations (mapInfo) startingPositionOfMapRectangle = 0 name = mapInfo.name or "Not defined" lengthOfCurrentMap = (string.len (name)*10) - (string.len (name) + (string.len (name) / 2)) startingPositionOfMapName = ( - string.len (name) * 10) addEventHandler ("onClientRender", root, animation) addEventHandler ("onClientRender", root, drawThisMap) end addEvent ("onClientMapStarting", true) addEventHandler ("onClientMapStarting", getRootElement(), mapInformations) function removeMapInfo () removeEventHandler ("onClientRender", root, drawThisMap) removeEventHandler ("onClientRender", root, animation) removeEventHandler ("onClientRender", root, drawNextmap) removeEventHandler ("onClientRender", root, animTextNM) end addEvent ("onClientMapStopping", true) addEventHandler ("onClientMapStopping", getRootElement(), removeMapInfo) function drawThisMap () dxDrawRectangle (0, (740/768)*y, (startingPositionOfMapRectangle/1366)*x, (25/768)*y, tocolor (0, 0, 0, 155)) -- current map dxDrawRectangle ((startingPositionOfMapRectangle/1366)*x, (740/768)*y, (5/1366)*x, (25/768)*y, tocolor (255, 113, 3, 155)) -- current map dxDrawText (name, (startingPositionOfMapName/1366)*x, (744/768)*y, x, y, tocolor (255, 255, 255, 175), 0.5, fonts) end function drawNextmap () dxDrawRectangle (0, (710/768)*y, (lengthOfNextmap/1366)*x, (25/768)*y, tocolor (0, 0, 0, 155)) -- next map dxDrawRectangle ((lengthOfNextmap/1366)*x, (710/768)*y, (5/1366)*x, (25/768)*y, tocolor (255, 113, 3, 155)) -- next map dxDrawText (nm, (startingPositionOfNextmap/1366)*x, (714/768)*y, x, y, tocolor (255, 255, 255, 175), 0.5, fonts) end function passMapName (nextmap) nextMapRectangleStart = 0 nm = nextmap lengthOfNextmap = (string.len (nm)*10) - (string.len (nm) + (string.len (nm) / 2)) startingPositionOfNextmap = ( - string.len (nm) * 10) addEventHandler ("onClientRender", root, drawNextmap) addEventHandler ("onClientRender", root, animTextNM) end addEvent ("nextMapName", true) addEventHandler ("nextMapName", getRootElement(), passMapName) function animation () if (startingPositionOfMapRectangle < lengthOfCurrentMap) then startingPositionOfMapRectangle = startingPositionOfMapRectangle + 4 end if (startingPositionOfMapName < 10) then -- stops at 10 coord startingPositionOfMapName = startingPositionOfMapName + 4 end end function animTextNM () if (startingPositionOfNextmap < 10) then startingPositionOfNextmap = startingPositionOfNextmap + 4 end if (nextMapRectangleStart < lengthOfNextmap) then nextMapRectangleStart = nextMapRectangleStart + 4 end end I was just wondering, what's wrong here? Why isn't it working?
  19. LabiVila

    Question

    viewtopic.php?f=91&t=90836#p815961 you can find there all the functions needed, the post of GTX
  20. server: function dooutput (player) resources = {} for _,v in pairs (getResources()) do if (getResourceInfo (v, "gamemodes") == "race") then local map = getResourceInfo (v, "name") if map then table.insert (resources, map) end end end triggerClientEvent (player, "all", player, resources) end addEvent ("goforit", true) addEventHandler ("goforit", getRootElement(), dooutput) function nextOne (map) executeCommandHandler ("nextmap", source, map) triggerClientEvent ("nextMapName", getRootElement(), map) end addEvent ("setNextMap", true) addEventHandler ("setNextMap", getRootElement(), nextOne) client local everyRes = {} local x,y = guiGetScreenSize () function enableNMonstart () isNM = false end addEvent ("onClientMapStarting", true) addEventHandler ("onClientMapStarting", getRootElement(), enableNMonstart) function mapGUI (res) everyRes = res main = guiCreateWindow ((480/1366)*x, (160/768)*y, (400/1366)*x, (450/768)*y, "Map Shop", false) local mainList = guiCreateGridList ((10/1366)*x, (30/768)*y, (700/1366)*x, (370/768)*y, false, main) local mainListColumn = guiGridListAddColumn (mainList, "Map name:", 0.85) local searchBar = guiCreateEdit ((10/1366)*x, (410/768)*y, (210/1366)*x, (50/768)*y, "", false, main) local nextmapButton = guiCreateButton ((230/1366)*x, (410/768)*y, (100/1366)*x, (50/768)*y, "Buy as next map", false, main) local X = guiCreateButton ((340/1366)*x, (410/768)*y, (40/1366)*x, (50/768)*y, "X", false, main) if mainListColumn then for _,res in pairs (everyRes) do local mainListRow = guiGridListAddRow (mainList) guiGridListSetItemText (mainList, mainListRow, mainListColumn, res, false, false) end end addEventHandler ("onClientGUIClick", nextmapButton, function () if (isNM == false) then clickedName = guiGridListGetItemText (mainList, guiGridListGetSelectedItem (mainList), 1) triggerServerEvent ("setNextMap", getLocalPlayer(), clickedName) isNM = true else outputChatBox ("#ff7100[server]#ffffff Next map is already bought.", 255, 255, 255, true) end end ) addEventHandler ("onClientGUIClick", X, function () guiSetVisible (main, false) showCursor (false) end ) showCursor (true) end addEvent ("all", true) addEventHandler ("all", getRootElement(), mapGUI) function sendTrigger () triggerServerEvent ("goforit", getRootElement(), getLocalPlayer()) end addCommandHandler ("mapshop", sendTrigger) The error is: Bad argument @ 'guiGridListSeTItemText' [Expected string at argument 4, got player] I thought maybe I made a global variable or something and I messed up, tried to change the looping for every resource to another value-name but it didn't work. So the window opens itself on any map start (while state running) and it's all blank
  21. Fixed, that isn't the problem, that's why I'm checking if there is one.. thanks anyway
  22. local clans = {} function createClan (player, cmd, password, ...) local acc = getPlayerAccount (player) local cName = table.concat ({...}, " ") if not password or not (...) then return outputChatBox ("t Syntax error, /addc password clanName", player, 255, 255, 255) end if acc and isGuestAccount (acc) then return outputChatBox ("This command is disabled for guests.", player, 255, 255, 255) end if clans[cName] then return outputChatBox ("There is a clan with such name.", player, 255, 255, 255) end for a,b in ipairs (clans[cName].members) do if (b == player) then outputChatBox ("You are in a clan already.", player, 255, 255, 255) end end outputChatBox ("You have created a clan called '"..cName.."', password is '"..password.."'.", player, 255, 255, 255) clans [cName] = {members = {player}, cPass = {password}} setAccountData (acc, "currentClan", cName) setAccountData (acc, "LeaderState", cName) end addCommandHandler ("addc", createClan) The error is: Attempt to index field '?' (a nil value), line 15 and 19
×
×
  • Create New...