Jump to content

pa3ck

Members
  • Posts

    1,141
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by pa3ck

  1. It says it's using the old MTA-MySQL module, which is now built in to MTA. You don't need this resource at all. MTA handles MySQL: MySQL page
  2. btn and state is not defined. function graveyard() = > function graveyard(btn, state) Make yourself an admin on your server if you haven't already and use /debugscript 3 command at ALL times. You could have easily spotted this error.
  3. Put the mini-game resource to the top of your resource list in server.conf so it will be the first one to download.
  4. There's a client side function to check if the transfer box is active => user is still downloading. Make a timer that checks every x seconds if the box is still active and as soon as it's not, get rid of the game. Function: IsTransferBoxActive
  5. There is an object preview resource on the community. I tried it, it's pretty cool link
  6. Yea, sorry, my bad, was meant to use getPedOccupiedVehicleSeat (localPlayer) ~= 0 He has thePlayer and seat there for no reason, he is not actually using it in the code anyway.
  7. Believe me, LUA is one of the easiest languages you will learn (if you're planning to become a programmer, obviously). It's simple, you just have to practice to get familiar with the MTA functions, methods etc.
  8. We usually don't just write the code for you without you making an effort, but because you said you just started, I wrote the code for you with heavy documentation. Hopefully you will get the gist of it -- Server Side local crimz = createTeam("Criminal", 255, 0, 0) local enfz = createTeam("Enforcer", 0, 0, 255) addEvent("onClientTeamPicked", true) -- its essential to enable the event so we can actually use it in this script file -- notice the name is same as we had client side -- the client is enabled, now lets assign a function to it addEventHandler("onClientTeamPicked", root, function(name) -- the variable "name" is coming from the client local team = getTeamFromName(name) -- this is where our variable comes in to play -- its gonna be either "Criminal" or "Enforcer" so we can find the team by its name -- we can be 100% that we found the team as we have hard coded names both end setPlayerTeam(client, team) -- client is a "predefined" variable that comes with the the event and it is the player element that triggered from client side -- we have the team element, we have the client, so we can enroll them to the team end) -- Client Side local sScreen, bCrim, bEnf local screenW, screenH = guiGetScreenSize() addEventHandler("onClientResourceStart", resourceRoot, function() -- basic stuff, I guess you already know this, as this is your code showCursor(true) sScreen = guiCreateStaticImage((screenW - 1366) / 2, (screenH - 768) / 2, 1366, 768, "images/scrn.png", false) bCrim = guiCreateButton(376, 369, 162, 63, "", false, sScreen) guiSetAlpha(bCrim, 0.00) bEnf = guiCreateButton(743, 369, 162, 63, "", false, sScreen) guiSetAlpha(bEnf, 0.00) function closePanel() destroyElement(sScreen) -- we can just destroy the image as the buttons are children removeEventHandler("onClientGUIClick", resourceRoot, guiClicked) -- remove the event listener for GUI clicks showCursor(false) end function guiClicked(btn, state) if btn == "left" and state == "up" then -- left mouse button, when user released it if source == bCrim then triggerServerEvent("onClientTeamPicked", localPlayer, "Criminal") -- pass "Criminal" with the trigger as string -- triggerServerEvent "triggerName", playerWeWantToSendItTo, variable closePanel() -- destroy the panel and remove event listener elseif source == bEnf then triggerServerEvent("onClientTeamPicked", localPlayer, "Enforcer") -- pass "Enforcer" with the trigger as string closePanel() end end end addEventHandler("onClientGUIClick", resourceRoot, guiClicked) -- add the GUI button click listener end ) This code tag is a bit messy, it's fine in Notepad++, but comes out with bad indent here...
  9. So you want to restrict the command to passengers only? If so, here's the code: bindKey ( "o", "down", function ( thePlayer, seat) local vehicle = getPedOccupiedVehicle ( localPlayer ) if ( vehicle and getElementModel (vehicle) == restrictedTo and getPedOccupiedVehicle (localPlayer) ~= 0) then -- seat 0 -> driver x,y,z = getElementPosition(getLocalPlayer()) if not createProjectile(getLocalPlayer(), 19, x, y, z - 5, 1, nil, nil, nil, nil, -1, -1, -1, 0) then end end end) I changed line 3 so it checks if the player is not the driver.
  10. You have a check that makes sure text1 == text2 so let's say text1 = "F1" text2 = "F1" Would this make sense? bindKey("F1", "down", binds) bindKey("F1", "down", binds) Of course not, why are you trying to bind the same thing twice?
  11. 1. Create team server side 2. Handle the GUI button click client side and triggerServerEvent with a variable that indicates which team has been clicked 3. Handle the server event, set the team of the player according the value you passed in step 2. If you don't know how to trigger a server side event, look at the wiki page and try to do it on your own, if you can't manage to get it working, come back with your code and the problem you are facing.
  12. WorldSounds have different ID's, so you can enable/disable them 1 by 1. If you want to find a sound ID, follow the instructions on the wiki: "The values for group and index can be determined by using the client command showsound in conjunction with setDevelopmentMode"
  13. It's actually not that simple, I already tried to do it twice, but no success. My code so far: local tbl = {} local x = 5 for row = 1, x do tbl[row] = {0, 0, 0} -- create dummy data so we can loop through the rows without error end function getNumCount(num) -- get the number of times a digit is in the array local count = 0 for row = 1, x do for i = 1, 3 do if tbl[row][i] == num then count = count + 1 -- increment when we have a match end end end return count end function isNumbersAllowed(n1, n2, n3) if n1 == n2 or n2 == n3 or n1 == n3 then -- check if all 3 numbers in a row are different return false end return true end function isGroupAllowed(n1, n2, n3) -- make sure we dont have 2 of the same rows like 1,2,3 and 2,1,3 local numOccurance = 0 for row = 1, x do for i = 1, 3 do if tbl[row][i] == n1 or tbl[row][i] == n2 or tbl[row][i] == n3 then -- if a column in a row is equial to any of the 3 random numbers generated numOccurance = numOccurance + 1 -- count the number of matches end end if numOccurance > 2 then -- we have 2 of the same rows, dont let it insert return false else numOccurance = 0 -- make sure its initialized to 0 after checking a row end end return true end function seedTable() for row = 1, x do local num1, num2, num3 repeat num1 = math.random(1, x) -- get 3 random numbers between 1 and x num2 = math.random(1, x) num3 = math.random(1, x) until isNumbersAllowed(num1, num2, num3) and isGroupAllowed(num1, num2, num3) and getNumCount(num1) < 3 and getNumCount(num2) < 3 and getNumCount(num3) < 3 -- shouldnt be 2 of the same groups or 1 digit occuring twice in the same row print(num1 .. " " .. num2 .. " " .. num3) tbl[row] = {num1, num2, num3} -- these 3 numbers passed all of our checks, put them in the table end end seedTable() It's not working 100%, I can only get it to create x - 1 rows because the last row never has 3 digits that occurred less than 3 times, it's quite tricky.
  14. We would have already helped you if you could take your time and *READ BEFORE POSTING*
  15. Uhm yes, hi. This forum section, as it says in it's title, is for scripting. You can search for resources on the community site, which you can access at https://community.multitheftauto.com/index.php?p=resources
  16. You don't really need to do that server side, you can achieve the same thing client side, which in my opinion much better. local cdTimer function antiSpamRPG(weap) if isTimer(cdTimer) then return end local slot = getPedWeaponSlot(localPlayer) if (slot == 7) then toggleControl("aim_weapon", false) toggleControl("fire", false) cdTimer = setTimer( function() toggleControl("aim_weapon", true) toggleControl("fire", true) end, 7000, 1 ) end end addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), antiSpamRPG)
  17. Are you sure you edited this: triggerServerEvent("clothes.buySkin", root, id) and used localPlayer instead of root?
  18. addCommandHandler("skins", function( player, cmd ) local skins = getSkinsTable() triggerClientEvent(player, "clothes.showSkin", player, skins) end) Server side
  19. pa3ck

    help

    loki didn't just copy your code, he fixed your for loop. Check line 3 in your and his code.
  20. Procedures or stored procedures (sprocs) are basically SQL functions (methods) and they work the same way as a LUA function does. They have inputs, outputs, if statements and loops and a whole lot of other things. For multiple WHERE values, you can use the SQL IN operator. For your other question, have a look at this topic: update-multiple-columns-for-multiple-rows-in-one-query-of-sql
  21. It surely works, but it's terrible advice to use triggerClientEvent inside a loop for no reason. I mean, why can't you just send the whole table over and loop through it there? -- server function sendRowsToClient() local result = dbPoll(dbQuery( connection, "SELECT * FROM `VList`", -1)) if result and #result > 0 then triggerClientEvent(source, "SendRows", source, result) end end -- client -- addEvent("SendRows", true) addEventHandler("SendRows", root, function(tableData) local data = tableData for k, v in ipairs(data) do local row = guiGridListAddRow ( PlayerVehicleList ) guiGridListSetItemText ( PlayerVehicleList, row, 1, v["id"], false, false ) guiGridListSetItemText ( PlayerVehicleList, row, 2, v["name"], false, false ) guiGridListSetItemText ( PlayerVehicleList, row, 3, v["price"], false, false ) end end)
  22. If you are getting more than one rows from a database, you will obviously need a loop to go through each of the rows.
  23. pa3ck

    get Max value

    The first value is either higher than the initial (0) or is 0, so having it initialised to 0 is the same as using your code, but yea, yours would work too.
  24. pa3ck

    Help

    Yea, not used to the "then" in the if's after C#, thanks.
  25. pa3ck

    Help

    local playerDamages = {} function healer( playerSource ) local lastPlayerDamage = playerDamages[playerSource] or 0 if lastPlayerDamage == 0 or lastPlayerDamage + 3000 <= getTickCount() then local money = getPlayerMoney ( playerSource ) local health = getElementHealth ( playerSource ) if money >= 3000 and health < 100 then takePlayerMoney ( playerSource , 3000 ) setElementHealth ( playerSource , 100 ) outputChatBox ("You got 100 health" , playerSource, 21 , 241 , 32 , true ) elseif money >= 3000 and health >= 100 then outputChatBox("Your health already: "..health,playerSource) elseif money < 3000 then outputChatBox("Your don't have enough money",playerSource) end else outputChatBox("This function is on cooldown.",playerSource) end end addCommandHandler ( "hp", healer ) function playerDamage ( attacker, weapon, bodypart ) playerDamages[source] = getTickCount() end addEventHandler ( "onPlayerDamage", root, playerDamage ) Something like that should work
×
×
  • Create New...