Jump to content

pa3ck

Members
  • Posts

    1,141
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by pa3ck

  1. pa3ck

    Need help

    addCommandHandler("double", function(p, cmd, money) if tonumber(money) then local mny = tonumber(money) local rnd = math.random(1, 100) if rnd <= 50 then takePlayerMoney(p, mny) else givePlayerMoney(p, mny) end end end) As simple as that, you probably over-complicated it.
  2. No offence here at all, I know you just started programming(?) and new to MTA scripting.. but you should really think about certain things. Stop coding and before you touch your mouse and keyboard, which is really hard, I know, do the logic in your head. You want to spawn a truck when player enters the marker -> simple. But how am I gonna do that? Well, do I need client or server? Server, because cars must be spawned on the server. This brings up the question, do I create the marker client or server side? Well, I can do it client side, but that wouldn't make sense since I still need to trigger to server.. why don't I create the marker on server to spawn my truck right away? The problem in your code is that you assumed you will have hitElement on the server, but you won't, since you never passed the "hitElement" argument in your triggerServerEvent. I know this community here is great, people will always help you, but you should really trace down the problems yourself. I'm pretty sure MTA is complaining about that hitElement not being defined...
  3. pa3ck

    random Pos

    local posTable = { {{-1341.5460205078, -149.02934265137, 14.1484375}}, {{-1586.5443115234, -214.85159301758, 14.1484375}}, {{-1478.2484130859, 12.554589271545, 14.369514465332}} } You have double {{ }} brackets, meaning if you wanted to get the first 3 positions, you'd need posTable[1][1][1], posTable[1][1][2], posTable[1][1][3] or with unpack( posTable [ math.random ( #posTable ) ] [ 1] )
  4. There are good few client side events that will be triggered to every client, not just one. Most of the time, there's an element coming from source or a parameter which let's you restrict the event to a single client. function outputLoss(loss, attaker) -- check if the 'attaker' is the localPlayer, it will only run for the attacker, AKA the client who is damaging the object if attaker == localPlayer and getPedWeapon (attaker ) == 0 and getElementType ( source ) == "object" and getElementModel ( source ) == 1985 then --action end end addEventHandler("onClientObjectDamage",root, outputLoss)
  5. getElementType =/= getElementsByType, you are using the wrong function to get the buttons.
  6. You just realized that you'll need to create a script? Wow, you thought if you concentrate really hard MTA will be able to do it for you without any code?
  7. triggerServerEvent, you should avoid creating vehicles client side, unless you want them to be static "objects".
  8. local deathX, deathY, deathZ function onPWasted() if source == localPlayer then deathX, deathY, deatZ = getElementPosition(localPlayer) addEventHandler("onClientPreRender", root, renderPedWasted) end end addEventHandler("onClientPedWasted", root, onPWasted) function renderPedWasted() setCameraMatrix(deathX + 2, deathY + 2, deathZ + 15, deathX, deathY, deathZ) end function onPSpawned() if source == localPlayer and deathX then removeEventHandler("onClientPreRender", root, renderPedWasted) deathX, deathY, deathZ = nil, nil, nil end end addEventHandler("onClientPlayerSpawn", root, onPSpawned) Try this, not tested.. use debugscript to fix any problems that might occur, if you can't fix it, come back with the results / errors. Never use setElementHealth to spawn a player after death.
  9. local X, Y, Z, ID, TYPE, PICKUP_ID, DESCRIPTION, COL_ID = 1, 2, 3, 4, 5, 6, 7, 8, 3 COL_ID = 8, you only have 1-3 in the table for i = 1, maxPickups do pickupCollision[i] = {} for j = 1, 3 do --> from 1 to 3, 8 will not be defined pickupCollision[i][j] = 0 end end
  10. local diffTimer, paydayTimer local lastPayDay = false addEventHandler("onResourceStart", resourceRoot, function() diffTimer = setTimer(function() local time = getRealTime() local hours = time.hour local minutes = time.minute paydayTimer = setTimer(payDay, 60 * 60000, 0) if hours == 7 then -- in case you were lucky enough to start the resource between 6 and 7 payDay() end end, (60 - minutes) * 60000, 1) -- timer that will start the actual payday timer exactly at hour:00 minutes -- 60 - currentMinutes; if the time is 12:44 |-> 60 - 44 = 12 -> 12 * 60000ms = 12 mins so the timer will start in 12 minutes end) function payDay() local time = getRealTime() local hours = time.hour local minutes = time.minute if hours == 7 and not lastPayDay then outputChatBox("payday...") lastPayDay = true -- just to be safe and make sure it cannot run twice else lastPayDay = false end end Make sure you are using getRealTime server side.. it will use the client PC's timer on client side.. not tested, but should work.
  11. pa3ck

    CEF using MDBootstrap

    Thank you for your reply, Josunex. Quite strangely, the problem fixed itself, 4 of us tried, we all had the same result, the input boxes lost focus.. The next day we all tried again and it worked without any code changes.
  12. Hi, post the code you tried, so we will be able to help you.
  13. That only cancels the outputChatBox, since it is attached to onClientChatMessage event, you will still be logged in.
  14. Don't forget that the search function is fully functional: As for the vote/help manager, you never mentioned what you want to change, the outputChatBox messages?
  15. getTeamFromName check the wiki, that will explain your problem also take a look at getTeamName
  16. You should set interior/dimension server side only. I had problems with this in the past as well.
  17. Maybe you set the dimension client side and it's not synced with the server? Not too sure.. How do you set the player's dimension, client or server?
  18. addCommandHandler("changemydim", function(p) setElementDimension(p, 15) outputServerLog("You are in dim: " .. tostring(getElementDimension(p))) end) Add this function to your server side script, use "/changemydim" and quit and see what it returns.
  19. Check your meta, make sure the script is referenced and is set to type "server"
  20. pa3ck

    [TUT] Debugging

    Great tutorial, although it should be common sense... But I'm amazed by the number of people that come to the forum looking for help without any type of debug done by themselves... should be a sticky post.
  21. Look at this topic next time to save yourself some time.. Put an outputChatBox / outputDebugString with the value of variable "dim" inside the if statement and come back with the result.
  22. Well the question is, which part you don't know? The scrolling part? Drawing part? Maybe sorting? There's a function I wrote in one of the websites I developed that had pagination, I think the basic idea can be applied to the scoreboard as well. This code might help you with the scrolling: local players = {} -- dummy player table local itemOnPage = 10 -- maximum 10 players / page local currPage = 3 -- get the players on page 3 for i = 1, 35 do -- create 35 dummy players table.insert(players, 'plr ID: ' .. i) end function getMaxPage() print( "Maximum pages (starts from 0): " .. math.ceil(#players / itemOnPage)) end function currPageItems() -- reads in currPage var. and returns the players that belong to that particular page local returnedPlayers = {} -- loop from the start of the page, ie if currPage * itemOnPage = 3 * 10 = 30 is our starting point -- loop until currPage + 1 * itemOnPage = (3 + 1) * 10 = 40 for i = currPage * itemOnPage, (currPage + 1) * itemOnPage do if players[i] then -- the last page might not have full list table.insert(returnedPlayers, i) -- this table will be returned, which you can use in your onClientRender else break end end return returnedPlayers end getMaxPage() for k, v in ipairs(currPageItems()) do print(players[v]) -- get a list of players depending on the variable: currPage and print their 'names' end All you have to do is manually (using binds, ie. mouse scroll) change the variable currPage + 1 or currPage - 1.
  23. pa3ck

    CEF using MDBootstrap

    Hi, I was trying to implement a bootstrap framework called MDBootstrap, which can be found here and it has an animated text input, so when I click in any of the edit boxes, the placeholder moves out of the way and the color changes as well (the usual animation). That kind of works fine in CEF, except that I have to hold down the mouse to be able to write into it, as soon as I let go, the text input looses focus and I cannot type anymore. I was wondering if it is something that can be fixed? I just want to know if I should look for a different framework, or it's something that will / can be fixed. @Jusonex any help would be appreciated
  24. pa3ck

    inventory?

    local inventorySlots = {} local playerItems = { [12] = {itemID, itemData..., itemImage} -- an item on slot 12 } for i = 1, 15 do local itemID = -1 local img if playerItems[i] then img = guiCreateStaticImage( (i-1) * 20, 15, 18, 18, playerItems[i][3]) -- the inventory slot image setElementData(img, "itemID", i, false) -- don't need to sync with other clients else img = guiCreateStaticImage( (i-1) * 20, 15, 18, 18, defaultImageLocation) setElementData(img, "itemID", itemID, false) end table.insert(inventorySlots, img) end addEventHandler("onClientGUIClick", root, function() if source and getElementData(source, "itemID") then outputChatBox("you clicked an item...") else outputChatBox("you clicked an empty slot...") end end) Not tested at all, should give you a rough idea, although I would use dx functions, but that's a bit harder to do..
×
×
  • Create New...