Jump to content

pa3ck

Members
  • Posts

    1,141
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by pa3ck

  1. I don't understand at least one thing here. What are you trying to achieve? client-server-client-server-client, that is not communication between server and client, that's a whole conversation..
  2. I never used getAccountsBySerial myself, but the wiki says it returns a table of accounts, so I assume you get back something like this: { Account1, Account2, Account3} So, what if you try: accounts = oldAccounts[i] -- INSTEAD OF accounts = oldAccounts[i][1]
  3. The way I would do this, instead of having 2 states (opened/closed), I would have 3 states, opened/closed/moving. When I hit the marker and it's in the moving state, don't do anything, if it's in the open state you close it etc..
  4. Szia, alapból kellene működniük, nem kell rá script. Szerintem valamelyik scripted okozza a problémát, ha nem működnek.
  5. Or you can use onClientResourceStart client side, so you can skip on a triggerClientEvent.
  6. Okay, so if I understand correctly, when a player logs in you can add an elementData from their accountData to save their paintjob. When somebody joins you can loop through all players and load the paintjobs client side based on their elementData which you have saved when they logged in. Use the event onPlayerLogout to remove elementData and trigger to every client to remove the paintjob. I guess that kinda does the same thing?
  7. In some scenarios you have no option but to use something like that. Although I see you're using elementData to check whether you'd need to load or unload the paintsjob. Element data somehow needs to be added / removed, right? When you add the elementData, why can't you just use the triggerClient/ServerEvent w/e side it is in and then load/unload?
  8. setPedArmor is server side only, you can't use it client side.
  9. pa3ck

    Ask ID

    local targetPlayer, tinta = exports.global:findPlayerByPartialNick(thePlayer, targerPlayer) ---> local targetPlayer, tinta = exports.global:findPlayerByPartialNick(thePlayer, targetPlayer) targerPlayer --> targetPlayer, just a small typo in your code.
  10. pa3ck

    Team Base

    Well, it depends how you want it to work. If you only want it to open then close after X amount of time, throw in two moveObjects, but you also have to think about the marker, what should happen if the gate is moving and somebody else (or the same guy) enters the marker again. You can put a "state" variable as the 4th argument of the table and when it opens/closes update it's state.
  11. pa3ck

    Team Base

    Because you keep overwriting the variables, if you have 5 gates, which gate do you think will open? Always the last one, since every time you go into the loop, a new value is assigned. for k, v in ipairs(TeamTable) do counter = counter + 1 TableTeamName = TeamTable[k][1] -- theGate and teamMarker are the variables being overwritten theGate = createObject(988, TeamTable[k][2], TeamTable[k][3], TeamTable[k][4], TeamTable[k][8], TeamTable[k][9], TeamTable[k][10]) teamMarker = createMarker(TeamTable[k][2], TeamTable[k][3], TeamTable[k][4] - 2, "cylinder", 5, 255, 0, 0, 150) end Since you have multiple markers and gates, you should store them in a table. local availableGates = {} for k, v in ipairs(TeamTable) do counter = counter + 1 local team = TeamTable[k][1] local theGate = createObject(988, TeamTable[k][2], TeamTable[k][3], TeamTable[k][4], TeamTable[k][8], TeamTable[k][9], TeamTable[k][10]) local teamMarker = createMarker(TeamTable[k][2], TeamTable[k][3], TeamTable[k][4] - 2, "cylinder", 5, 255, 0, 0, 150) table.insert(availableGates, {theGate, teamMarker, team}) end function getTeamGateMarker( markerElement ) for k, v in ipairs(availableGates) do if(v[2] == markerElement) then return v end end return false end addEventHandler("onMarkerHit", resourceRoot, function(player) local gate = getTeamGateMarker(source) if (gate and getElementType(player) == "player") then local playerTeam = getPlayerTeam(player) if playerTeam then outputChatBox("team") local teamName = getTeamName(playerTeam) if teamName == gate[3] then outputChatBox("yee") else outputChatBox("You are not in this team") end else outputChatBox("not in team") end end end) Try something like that, keep in mind I haven't touched MTA or LUA in ages..
  12. BTW: When you use getElementsByType on client side, there's an optional argument, "streamedIn", if you set this to true, only the streamed in vehicles will be returned.
  13. pa3ck

    Binds

    You don't need to write your own function. You can use guiSetInputMode, it doesn't have to be a GUI if you use "no_binds" instead of "no_binds_when_editing". guiSetInputMode("no_binds") guiSetInputEnabled(true)
  14. pa3ck

    ElementData

    Zombies aren't just appearing randomly, some part of the code is spawning them.. go there, add an if statement to check whether a boss is spawned and that's it. There's more than likely a timer or something already there that keeps the code running over and over again, so a simple if statement should be enough.
  15. That is because you're getting the X, Y, Z position of localPlayer, which is basically every single player. You would want to trigger the event like: triggerClientEvent ( playerSource, "onSay1", root) -- server local x, y, z = getElementPosition(source) -- client OR local x, y, z = getElementPosition(playerSource) -- server triggerClientEvent ( root, "onSay1", root, x, y, z) -- server, use X, Y, Z on client side But I think it would be more efficient if you didn't use triggerClientEvent this way. What you could do is, create a colSphere, get the list of players inside it and use triggerClientEvent for those players only.
  16. If you're using the default MTA siren system, there are no siren objects that you need to reference in order to remove them from a vehicle. You just do: removeVehicleSirens(source) If you have your own objects that you attach, you can use the same concept idarrr suggested: local sirens = {} addCommandHandler("addsirens", function(p) local veh = getPedOccupiedVehicle(p) local obj1 = createObject(..) local obj2 = createObject(..) attachElements(obj1, veh) attachElements(obj2, veh) sirens[veh] = { obj1, obj2 } end) addCommandHandler("removesirens", function(p) local veh = getPedOccupiedVehicle(p) if sirens[veh] then for k, obj in ipairs(sirens[veh]) do destroyElement(obj) end sirens[veh] = null end end)
  17. That's right, it only goes as far as fase 1, the reason is, triggerServerEvent requires an element (player or root). Try this: triggerServerEvent('fotofalla', localPlayer, x, y) BTW: variable "secondi" is already the timestamp, you don't really need to get the getRealTime().timestamp, since it's already there.
  18. I don't think it will be as simple as using table.concat.. You'd probably need to implement your own way of string, boolean and number concatenation eg. looping thru the data. local tablaPrueba = { {"object1","valor1","valor1","valor1"}, {"object2","valor2","valor2","valor2"}, {"object3","valor3","valor3","valor3"}, {"object4","valor4","valor4","valor4"}, {"object5","valor5","valor5","valor5"}, {"object6","valor6","valor6","valor6"}, {"object7","valor7","valor7",true}, } local myStr for k, v in ipairs(tablaPrueba) do local myStr = "{" for x, y in ipairs(v) do if type(y) == "string" then myStr = myStr .. '"'..y..'", ' elseif type(y) == "number" then myStr = myStr .. y..', ' elseif type(y) == "boolean" then myStr = myStr .. tostring(y) .. ", " end end myStr = myStr:sub(1, -3) .. "}," outputChatBox(myStr) end But using toJSON and fromJSON would be your best option.
  19. I never actually used this function, always wondered how it worked, maybe it's something you can use? https://wiki.multitheftauto.com/wiki/GetCamera
  20. I would use the easing type SineCurve, this way probably: | ---------------- | ----------------- | your line 0,,,,,,,,,,,,,,,,,,150px,,,,,,,,,,,,,,,,,,300px the arrow pointer 0,,,,,,,,,,,,,,,,,,,,,,,,1,,,,,,,,,,,,,,,,,,,,,,,,0 color progress Red - > Green -> Red Red < - Green < - Red In theory if you start the interpolation from Red to Green (with half the duration of the interpolation of the arrow pointer) with SineCurve, it should automatically start reversing back to 0 (Red) from 1 (Green). Then it should start over. Also, the little arrow pointer should have an interpolation for itself, you can get the progress by using the variable you set up as the progress parameter and when you click, you'd check if the progress is between 0.4 and 0.6, confirming that the pointer is in the green zone. So let's say if the arrow pointer takes 5 seconds to reach the end, you'd have the color interpolation set to 2.5 half second with SineCurve going from 255, 0, 0 (red) to 0, 255, 0 (green) and it should reverse from 0, 255, 0 (green) to 255, 0, 0 (red) by itself. You can use the same SineCurve for the arrow, from 0px to 300px (or w/e size you bar is) then it should reverse from 300px to 0px by itself.
  21. You're using the events onResourceStart and onResourceStop with "source" --> source is never going to be a player, it will always be the resource. What you should do is, when a resource starts, use a for loop to loop through every player.
  22. Can you show us how you set the elementData, because if the isElement() doesn't fail, that means there's an element but not necessarily a vehicle.
  23. When checking if the element exists, try to use if isElement(vehicle) instead of just if vehicle.
  24. Hi, you can search for similar problems other people faced using the search option. Look at for example this one:
×
×
  • Create New...