Jump to content

Tails

Members
  • Posts

    740
  • Joined

  • Days Won

    16

Everything posted by Tails

  1. Already stolen. working on it now...
  2. You don't have to unbind anything: https://wiki.multitheftauto.com/wiki/GuiSetInputEnabled
  3. I don't see anything wrong with the first function addEventHandler("onPlayerCommand",function(cmd) if cmd == "me" then cancelEvent() end end)
  4. Tails

    Counter

    I'm not entirely sure as to what you're trying to accomplish. If you want to count the players in a team and compare them in any way, take a look at: https://wiki.multitheftauto.com/wiki/CountPlayersInTeam
  5. Take Walid's example and use this outputChatBox("Hello, "..getPlayerName(localPlayer)..". Developer Mode is enabled!", 0, 200, 0)
  6. You've put the table locally in your devenable function. Put it above the function or remove local then devaccess function should work.
  7. Ah, just ignore those changes on Github I wasn't paying attention to the "return false end". I will take a better look at it tonight. Apologies! Can you answer BluePie's question, though? What is it exactly that's not working in your code? Are the pages not loading or are you unable to navigate? What's happening in-game?
  8. https://wiki.multitheftauto.com/wiki/OnPlayerChat local chars = {',','-','+'} for _,chr in ipairs(chars) do msg = msg:gsub(chr,'') end Hope this helps.
  9. Well, then something is conflicting in your script or you're not doing it right. Can you show us what you have that doesn't work?
  10. No problem. Look here for more info: https://wiki.multitheftauto.com/wiki/Ev ... ce_Element To understand what they are, just look at any event's wiki page and read the Source section. Server-side they can also be the player.
  11. I suspect the setElementInterior function interupts the camera fading. Try fadeCamera( playerSource, false, 2.0, 255, 0, 0 ) setTimer(function() setElementInterior( playerSource, 3, 387.18585, 173.86874, 1008.38281 ) fadeCamera( playerSource, true, 1.0 ) end,2000,1) There's no difference in your case, you can name the player anything you want. However in some cases you're required to use 'source' for the player. Not playerSource or thePlayer, these are just names, but source. Source is only used when you want to get the the root element of an event.
  12. You can try something like this: -- define these two at the start history = {} curPos = 1 -- define these when navigating total = #history history[url] = getBrowserURL(browser) -- store the current page url -- in example function back() if curPos > 1 then curPos = curPos - 1 end setBrowserURL(browser,history[curPos]) end function forward() local total = #history if curPos < #history then curPos = curPos + 1 end end There are some mistakes here and there but you get the idea.
  13. @Walid if thePlayer and isElement(thePlayer) then Is completely unnecessary with onCommandHandler as it'll always be a player element. @shaman123 It's not recommended nor necessary to use setElementData (read here). Try a table: local carsBeingFixed = {} function fixVeh(thePlayer) if isObjectInACLGroup("user.".. getAccountName(getPlayerAccount(thePlayer)),aclGetGroup("DL3")) then if getElementDimension(thePlayer) == 366 then local vehicle = getPedOccupiedVehicle(thePlayer) if vehicle then if carsBeingFixed[vehicle] then outputChatBox("Your car is already being fixed.",thePlayer) return end outputChatBox("Your car is being fixed. Please wait a few moments.",thePlayer) carsBeingFixed[vehicle] = setTimer(function() fixVehicle(vehicle) carsBeingFixed[vehicle] = nil outputChatBox("Your car has been fixed.",thePlayer) end,15000,1) end else outputChatBox("You can only use this command in dimension 366",thePlayer) end end end addCommandHandler("fixv",fixVeh) Cool thing about this is you could also use it in roleplay evironments if you add some small changes (colshape etc..) where you have to leave your car at the repair shop and pick it up later. Sorry, no disrespect to you guys providing examples! Hope this will help. @DonOmar This fixes the vehicle of the player that executes the command: local vehicle = getPedOccupiedVehicle(thePlayer) This would fix vehicle in the server when you execute the command: for _, vehicle in ipairs ( getElementsByType ( 'vehicle' ) ) do
  14. No problem! Sorry that I didn't look at your code before you edited your post. Glad to see you've fixed it!
  15. The size is 1.8 MB packed and 4.3 MB unpacked. If you need any help installing it, let me know here Also, check our latest thread on this Custom World: https://forum.multitheftauto.com/viewtopic.php?f=93&t=71782 It has some info and screenshots in the comments.
  16. Hi G-Stefan, I don't know if it's what you're looking for but our Custom World resource contains a complete set of custom-made road models. They aren't like GTA's but you can do a lot with it.. they're specially built so that you can build your own cities with it. Check it out here: https://forum.multitheftauto.com/viewtopic.php?f=93&t=71782 Also, I plan on releasing a pack seperately in the future for anyone that likes to build their own cities, but for now you can just take them from the resource.
  17. Yeah that's neat. I feel like you could write that with much fewer code than that though. The code/func I'm using is perfect for what it needs to do, the point was the concatenation I did on a single line. Same idea as " local variable = (Condition and "yes") or "no" " with the 'or' and stuff. It's only a few lines of code, and you don't have to seperate the keys and values into tables to do table.concat afterwards, even though you could. I wrote something like it already before to output a table to a text file.
  18. I wrote this recently to concatenate the keys and values of a table to display them in a list fashion: for k,v in pairs(data) do Key = (Key or "") .. k..":\n" Value = (Value or "") .. v.."\n" end dxDrawText(Key..... dxDrawText(Value..... Think this will be useful for some people if they have named keys in their tables and they want to display the content. Just using table.concat() wouldn't be possible in this situation. The trick is in the way I'm defining and concatenate the strings. You can use it for anything.
  19. You can test it with an element that's not a player like a ped for example. The error was: 'expected element' so all you need to do is add a check: if isElement(target) then Like so: function getDistance(playerSource, _, target) local x, y, z = getElementPosition(playerSource) local target = getPlayerFromPartialName(target) if isElement(target) then local x1, y1, z1 = getElementPosition(target) local distance = getDistanceBetweenPoints3D(x, y, z, x1, y1, z1) outputChatBox("Distance between you and "..getPlayerName(target)..": "..distance.." meters", playerSource, 0, 255, 0) else outputChatBox("We couldn't find a player with that name", playerSource, 255, 0, 0) end end addCommandHandler("entfernung", getDistance) For the player alpha you can do setElementAlpha(playerSource,150)
  20. Tails

    Question

    If the objects should only be visible to the localPlayer then yes, you can move the whole function to the client. function create() if ( source == button ) then if ( getPlayerMoney (localPlayer) <= 4999 ) then return end --triggerServerEvent("object", localPlayer) object() guiSetVisible(classWnd, false) showCursor(false) end end addEventHandler("onClientGUIClick", getRootElement(),create) function object() local object = createObject ( 1337, 5540.6654, 1020.55122, 1240.545, 90, 0, 0 ) outputChatBox("created") end Because you're using onClientGUIClick, any client-side code will only be executed for the client that clicked.
  21. The edges don't look straight to me. Try enabling anti-aliasing in your video settings. http://imgur.com/NmfW3Ku Your text is out of shape as well.
  22. Tails

    Question

    Hi Shaman123, The object gets created on the server, so it will be visible for everyone. You could use setElementVisibleTo on the server but I've had bad experience with it. I've used it on markers and what I found is that the marker would still be there (onMarkerHit etc.) just not visible. Might be different for objects, or maybe I did something wrong. I can't say for sure. What Anubhav is trying to say is, you can have clients execute commands from the server and use triggerClientEvent( source, "someEvent", source) to trigger a function only for that particular client. You can also use triggerClientEvent to trigger functions on the client for everyone like so: triggerClientEvent("eventName", resourceRoot). This one has no source at the beginning so it gets triggered for every client. Source just stands for the player, it can be any name if you had to define it first. An example: function testFunc(plr,cmd) triggerClientEvent(plr,"myEvent",resourceRoot) end addCommandHandler("trigger",testFunc) Plr could be anything but it's always the player in this particular case (check the wiki for addCommandHandler). Sometimes you don't have to define the player and you can you just use source. On the client you don't have to define it but you can use localPlayer. triggerServerEvent(localPlayer,"myEvent",resourceRoot) is not going to work though. You can't put a player element in front but you can do triggerServerEvent("myEvent",localPlayer). It gets triggered on the server and the player is being sent with it. In the function on the server you can use source as the player. function testFunc(player,cmd) outputChatBox("You're now triggering a client event for everyone",player) triggerClientEvent("myEvent",resourceRoot) end addCommandHandler("trigger",testFunc) Above is self-explanatory Both functions above are server-sided. Keep in mind that you don't always have to trigger everything from the server. You can do a lot via the client alone if it's only meant for the client. To get the player on the client, you can use localPlayer. I'm still learning myself as to what is safe and whether something should be server or client-side and stuff but I know when something is or isn't triggered for a single player. Hopefully this gives you some ideas. Let me know if you have any more questions or if you need someone to test your code.
  23. You don't have to put the values in a table. Just do: function getServerMoney() local moneyS = 0 for k,v in ipairs(getElementsByType("player")) do local moneyP = getPlayerMoney(v) moneyS = moneyS + moneyP end return moneyS end local moneyS = getServerMoney() outputChatBox(moneyS)
  24. Tails

    Help me

    local message = table.concat({...}, " ") not "" but " " will add a space between every word. "," would add a comma between every word. "" adds nothing.
  25. Tails

    .

    You're welcome. But like I said, it gets a bit more difficult with other colors than red, green and blue. It may involve different kind of maths if you want to keep everything short and simple. I can't really help you with it, because I know very little about maths. Hopefully you'll figure it out or someone is able to help you. Good luck.
×
×
  • Create New...