Jump to content

IIYAMA

Moderators
  • Posts

    6,084
  • Joined

  • Last visited

  • Days Won

    215

Everything posted by IIYAMA

  1. IIYAMA

    Animation

    Block the progress local timeNow = getTickCount() local iProgress = (timeNow - iStartTick)/1000 if iProgress > 1 then iProgress = 1 end Stop the animation 3 seconds after the end time. if ((timeNow - iStartTick) / 1300) >= 1 then
  2. Conditions are used for excluding actions. Which is not what you want, when you want: shooting OR killing Instead you want to have a variable value which only exist when all conditions are met. local victim = isElement(hitElement) and getElementType(hitElement) == "player" and hitElement or false You can't hit yourself with your own bullets: hitElement ~= source As I said before: addEventHandler("onClientPlayerWeaponFire", root, cameraFireing) addEventHandler("onClientPlayerWeaponFire", localPlayer, cameraFireing) triggerServerEvent("sendGroupMessage", resourceRoot, hitElement) Do this on serverside: if hitElement then local message = "#ffffffThe camera: #ca5454("..getElementData(hitElement,"char.MarkerZoneName")..") #ffffffdetected shots." end addEventHandler("onClientPlayerWasted", getLocalPlayer(), cameraKilling) onClientPlayerWasted, so this is not needed: if (getElementType(source) == "player") then
  3. As your code is programmed now, you have to hit another player in order to trigger the server event. Are you sure you have met that condition? Also attach the eventhandler to the localPlayer: addEventHandler("onClientPlayerWeaponFire", localPlayer, cameraFireing) Even though this event is fired on each client/player. The event is also fired for each player when attached to the root. When there are 5 players in the server, 1 player hits another player, the triggerServerEvent is activated max 5 times.
  4. @ilnaz Re-used data, with a buffer. local songBuffer = {} addEvent("onSearchRequest", true) addEventHandler("onSearchRequest",getRootElement(),function(txt) local buffer = songBuffer[txt] if buffer then onSongReturn(buffer, 0, player) else fetchRemote( "http://5music.online/?song="..(txt:gsub(' ', '+')),onSongReturn,'',true,client, txt) end end) function onSongReturn(data, errno, player, txt) if errno == 0 and txt then songBuffer[txt] = data end if player and isElement(player) then local str1 = string.find(data,"<ul>") local _,str2 = string.find(data,"</ul>") if str1 ~= nil then local data = string.sub(data,str1,str2) triggerClientEvent(player,"onSongReceived", player, data) end end end -- clear buffer setTimer(function () songBuffer = {} end, 1000 * 60 * 60 * 4, 0)
  5. Locked for the following reasons. 1. Suspicion release. (Leaving a link on a topic, which leads to a ZIP file. Without a description of any kind except for the title) 2. Unsupported at all. (Which makes it looks like, it is not yours to begin with) 3. Wrong section. Because of those 3 reasons, I am not even going to check your ZIP file.
  6. Is your issue now solved with xFabel his explanation? You can convert names to id's with this function: https://wiki.multitheftauto.com/wiki/GetVehicleModelFromName local model = getVehicleModelFromName ("bandito") if model then -- is there an id based on that name? end
  7. Where is that suppose to come from? It is not as if groupid is something from default MTA.
  8. Clientside? Btw you are missing an argument: (model) createVehicle ( int model, float x, float y, float z
  9. Have you noticed that the event system is Asynchronous? (You can't make use of the return keyword functionality after all. Stopping the code with it does work.) And exports are Synchronous. (You can use the return keyword to return values) An understanding of what I am talking about in JavaScript: After you watched this, you know which one is way faster.
  10. By just looking at the initial setup, it looks very logic. That is without looking at syntax and any other issues at all.
  11. The variable name localPlayer isn't suppose to be used on serverside, because it only makes sense for the player that runs the MTA application and the server on his own pc. No other player in your server will be able to met that condition. Note: If this code is fully clientside, you will not be able to send a message to other players. Do you remember this loop you posted in your other topic? It will allow you to go through all the players in the server.
  12. Wait until the bug has been solved. https://github.com/multitheftauto/mtasa-blue/issues/1091 No video on your server, is not the end of your world atleast. (Hope hope)
  13. A small example/hack to rotate (multiple) vehicles. With very little code. This code is untested local rotationElement = createElement("rotationElement") local duration = 1000 addEventHandler("onClienRender", root, function () setElementRotation(rotationElement, 0,0, (getTickCount() % duration) / duration * 360 ) end) local vehicle1 = createVehicle(--[[ fill in]]) setElementParent(vehicle1, rotationElement) local vehicle2 = createVehicle(--[[ fill in]]) setElementParent(vehicle2, rotationElement) local vehicle3 = createVehicle(--[[ fill in]]) setElementParent(vehicle3, rotationElement) setElementFrozen(rotationElement, true)
  14. You can also change the rotate (velocity) with this function: https://wiki.multitheftauto.com/wiki/SetElementAngularVelocity But for exact 360, you will need the setElementRotation function. It just depends on what you are going to make.
  15. Correct. This section has as start point "learning how to code", which is for everyone to make use of. So private code and requests(like this one without code) will not fit in this section.
  16. IIYAMA

    Get keys

    For debugging or for your players? In case of debugging you can do just this: dxDrawText(inspect(keys), 1083, 190+zz, 1149, 206, tocolor(255, 255, 255, 255), 0.9, "default-bold") Not recommended for showing it to your players.
  17. Incorrect MySQL syntax, see here an insert example. https://www.tutorialspoint.com/mysql/mysql-insert-query.htm SET is afaik for variables.
  18. Yup. if args[1] == "success" then if minigameData.successEvent then triggerEvent(minigameData.successEvent, localPlayer, unpack(minigameData.customData)) end else if minigameData.failEvent then triggerEvent(minigameData.failEvent, localPlayer, unpack(minigameData.customData)) end end From saving minigameData.customData = {select(5, ...)} to loading + unpacking as arguments. unpack(minigameData.customData)
  19. Correction. Trigger the event on clientside. This successEvent. minigameData.successEvent = successEvent Which is not triggering anything in the code you posted.
  20. This is a bit complex. Note: ... = leftover parameter that doesn't have variables to store in. Doesn't matter how much arguments you pass in to the function. function functionName (parameter1, parameter2) end functionName(argument1, argument2) -- calling the function There are the first 3 parameters:(line 1) (gameType, successEvent, failEvent, ...) This table(arguments) will collect all leftover parameters: (line 4) local args = {...} After: gameType, successEvent, failEvent From those leftover parameters, until the 4e are used for something. (line 17) minigameData.maxButtonNum = args[4] or 75 If we want to be able to save everything after parameter 4. We can use the select function. print(select(5,"arg1","arg2","arg3","arg4","arg5","arg6","arg7","arg8","arg9","arg10")) Run this code here, to see how it works: https://www.Lua.org/cgi-bin/demo So what you need to do, is modifying it, so that it saves data in the minigameData. The function select, will select from a specific index (5) it's item and all items that come after that. minigameData.customData = {select(5, ...)} Add it for example on line 10. In your code: startMinigame("balance", "successPlayerHelpup", "failedPlayerHelpup", 1, 10000, nil, nil, playerSource, "you can add here something else", "etc...") Arguments 1. "balance", 2. "successPlayerHelpup", 3: "failedPlayerHelpup" ... 4 | 1: 1 5 | 2: 10000 6 | 3: nil 7 | 4: nil 8 | 5: playerSource < saving from here. 9 | 6: more? The thing left to do, is sending it with the triggerClientEvent. But that code is not visible for me.
  21. You go from your code. To the Minigame code And back to Your code But currently your target player, is not passed in to the minigame. See: exports.s_minigames:startMinigame("balance", "healSuccess", "healFailed", 1, 10000) There is no sourcePlayer included in to the export. Which means it is not available there and also not available to where you want to re-use that specific player. So what you need to figure out is the syntax of this export function and if it allows you to add your own data to it. If not, then you need to modify it, so that it does: Yes We Can.
  22. A lot more than exports yes. Events are global. But that doesn't mean they are bad. They can be very useful for `events`. But if you can use exports, those can handle really a lot of data. If you observe those closely, you could even write your own event scope based on exports. The main issues lie with: Propagation (while triggering) Like you do this: setElementPosition(root, 0,0,0) This will move every possible element to 0,0,0. Players, vehicles, objects, peds, elements without physics. And for triggerServerClient event, no it probably doesn't send multiple messages (I hope lol). But it does go over every element. This might give the lowest impact. Not sure if propagation will help if there are no children, but at least it will not search for children. local element = createElement("triggerElements", "resource-" .. getResourceName(getThisResource())) setElementCallPropagationEnabled ( element, false) With the amount of listeners. The longer this list the longer it takes. (depending on the context)
  23. This is a loop, it goes trough all items, in this case all players. And can be stopped with the keyword break or return. What if you add another export function, for the call : (The only strange thing about it is that in the orginal code the slot id is not being used. Could itemsTable be a meta table?) function hasItemAndData1(sourceElement, itemId, data1) if itemsTable[sourceElement] then for k, v in pairs(itemsTable[sourceElement]) do if v.itemId == itemId and v.data1 == data1 then return v end end end return false end
  24. Are you telling me that there is no function for? Maybe search a little bit more? local ownerId = tonumber(getElementDatabaseId(player)) local ownerType = getElementType(player) -- "player" if ownerId then end query should look a bit like this. SELECT data1 FROM items WHERE itemId = 43 AND ownerId = ? AND ownerType = ? LIMIT 1
  25. No. The bug is caused, because you are only storing the phonenumber. But not using it when checking if the number is matching. Where in this code do you see that value is used? function hasItem(sourceElement, itemId) if itemsTable[sourceElement] then for k, v in pairs(itemsTable[sourceElement]) do if v.itemId == itemId then return v end end end return false end I do not see it. Only matching the itemid, which is not the value. Is there perhaps this function: getItemValue ?
×
×
  • Create New...