Jump to content

IIYAMA

Moderators
  • Posts

    5,973
  • Joined

  • Last visited

  • Days Won

    191

Everything posted by IIYAMA

  1. I don't think you understand what I mean. I am talking about something very simple. But now I know it is impossible, without using timers.
  2. ah yes, but then I am sending this trigger. It doesn't really matter if it have been send, it was more meant to save data travel by preventing the trigger. Well it is just a trigger... but it is handy to know if there is a possibility to find a way to do this on client side, without using any extra bandwidth.
  3. aha well it may will work, but one trigger is something you can't compare with: elementdata*playerCount Thx anyway guys.
  4. Well as sample: There 3 players in-game and 1 player is going to join. When I start the resource, the 3 players are triggering to serverside. Next the other player joins the server and he triggered too. <-- and this is what I want to be prevent from happening. I tried to use getTickCount(), to get: This function returns amount of time that your system has been running in milliseconds. By comparing two values of getTickCount, you can determine how much time has passed (in milliseconds) between two events. This could be used to determine how efficient your code is, or to time how long a player takes to complete a task. But some how the tickcount is already changing after I started mta or when I reconnect to the server. (so I can't check if this player is new or already in game) ElementData isn't a solution, this script probably triggerd faster then the elementData reached the player who is downloading, next to that is is laggy, because all new client players have to download each other status. NL: Ik wil gewoon weten of de speler nieuw is of al in game is, so dat ik kan bepalen of ik het wil sturen of niet.
  5. IIYAMA

    helppp!!!

    Also what will happen when a new player joins the server.
  6. Well then you have to create it manually. engineImportTXD (engineLoadTXD ( "file" ), ID ) engineReplaceModel ( engineLoadDFF ( "file", ID ), ID ) Weapon ID's https://wiki.multitheftauto.com/wiki/Weapon Replace sounds isn't possible. (you have to play them with playSound or playSound3D)
  7. http://mta.dzek.eu/peds/ http://mta.dzek.eu/vehicle/
  8. If I start my script it will trigger to server side, to check if the player is login. What is the best way to check if the player did not just joined. This one must only be triggered(to server side) when the player is already in game. (client) addEventHandler( "onClientResourceStart", resourceRoot, function () triggerServerEvent("clientLoaded",localPlayer) end)
  9. He uses client side. You will see your self invisible(with the script under this), but other players won't see it. Use the script of Mr.Pres[T]ege at serverside. -- client, but not synced for all players. addCommandHandler ( "god", function (command )--toggleInvis if getElementAlpha(localPlayer ) == 0 then setElementAlpha ( localPlayer, 130) --not 255? else setElementAlpha ( localPlayer, 0 ) end end) Use this also serverside. function togglestaffMode(thePlayer) local account = getPlayerAccount(thePlayer) if (not account or isGuestAccount(account)) then return end local accountName = getAccountName(account) if ( isObjectInACLGroup ( "user.".. accountName, aclGetGroup ( "Admin" ) ) ) then if getElementData(thePlayer,"invincible") then setElementData(thePlayer,"invincible",false) outputChatBox("#ff0000God Mode Off",thePlayer,255,255,255,true) else setElementData(thePlayer,"invincible",true) outputChatBox("#00ff00God Mode On.",thePlayer,255,255,255,true) end end end addCommandHandler("god",togglestaffMode)
  10. Why don't you go reading what triggerServerEvent is? and maybe also take a close look at the wiki sample. To send information back. triggerClientEvent
  11. yes it is a kind of bug. Maybe you can try something like this: (not tested) setElementCollidableWith ( vehicle, root,false )
  12. IIYAMA

    helppp!!!

    Even is the "setWeaponOwner" does not work very well(sync damage), you can get the player with "getWeaponOwner".
  13. yes, that is true, it is because when you reconnect your userdata got changed. To safe this per-ma, you have to use account data(mysql lite) or mysql. Account data is easier, my mysql gives more performance at bigger data bases, but is harder to script. https://wiki.multitheftauto.com/wiki/SetAccountData https://wiki.multitheftauto.com/wiki/GetAccountData
  14. yes, see my sample. (tostring is making sure that when I put it the chatbox, it won't give any errors. Userdata have to be a string to output.) function Perennial_buy () local Perennial = createVehicle(404, -2600, 2268, -- s8) --> setElementData(Perennial, "save", "save")--for the save script takePlayerMoney(source, 2000) --take money setTimer(warpPedIntoVehicle, 50, 1, source, Perennial)--warp player in vehicle setElementData(source, "owner", source)--set the owner outputServerLog("[AUTOHÄNDLER] "..getPlayerName(source).." kaufte einen Perennial")--server log end function lockcar ( player ) local posX, posY, posZ = getElementPosition ( player ) local lockSphere = createColSphere ( posX, posY, posZ, 20 ) for index,nearbyVehicle in pairs(getElementsWithinColShape ( lockSphere, 'vehicle' )) do -- just use pairs instead of ipairs if getElementData ( nearbyVehicle, 'owner') == player then setVehicleLocked ( nearbyVehicle, true ) end end destroyElement ( lockSphere ) end addEventHandler ( 'onPlayerLogin', root, function () bindKey ( source, 'L', 'down', lockcar ) end) BTW to many element data will start lagging, it is recommended to learn working with tables. Like: vehicleOwnGroup = {} vehicleOwnGroup[player]= { , , , } Why is element data laggy? Because when you create it it will be send to all the players in the game. (only client element data have an option that disallow the server to share it.)
  15. You already have the user data and that is the player. local vehicle = createVehicle ( 270, 0, 0, 0) -- create a vehicle, when you create an element it will returns a userdata. outputChatBox(tostring(vehicle)) A player does also have a user data. addCommandHandler ( "myUserData", function ( player) outputChatBox(tostring(player)) end)
  16. You should not store the player name or the serial, just use the player userdata. Elements can't have the same userdata..... -_-"
  17. IIYAMA

    helppp!!!

    The weapon fire should be elementdata or it have to be registered at server side which weapon is firing. and no the code isn't yet fully synced. It took me 6 hours to create the perfect lagg free code.
  18. You can't scale gta san world-objects. You should copy them with the world-object-select-tool and then scale them.
  19. You can try: https://wiki.multitheftauto.com/wiki/SetCursorPosition
  20. It is the same as Cadu12 said, only it is already complete.
  21. GO for performance!!! muhahaha ok I am not funny... for index,vehicle in pairs ( { -- table and will be gone in a few sec's ! createVehicle(462, -2458.33398, 779.5, 34.842, 0, 0, 90, "1"), createVehicle(462, -2463, 774.5, 34.842, 0, 0, 0, "2"), createVehicle(462, -2464.5, 774.5, 34.842, 0, 0, 0, "3"), createVehicle(462, -2466, 774.5, 34.842, 0, 0, 0, "4"), createVehicle(462, -2472, 774.5, 34.842, 0, 0, 0, "5"), createVehicle(462, -2473.5, 774.5, 34.842, 0, 0, 0, "6"), createVehicle(462, -2467.5, 774.5, 34.842, 0, 0, 0, "7"), createVehicle(462, -2478, 774.5, 34.842, 0, 0, 0, "8"), createVehicle(462, -2470.5, 774.5, 34.842, 0, 0, 0, "9"), createVehicle(462, -2476.5, 774.5, 34.842, 0, 0, 0, "10"), createVehicle(462, -2475, 774.5, 34.842, 0, 0, 0, "11"), createVehicle(462, -2469, 774.5, 34.842, 0, 0, 0, "12"), createVehicle(462, -2479.5, 774.5, 34.842, 0, 0, 0, "13"), createVehicle(462, -2481, 774.5, 34.842, 0, 0, 0, "14"), createVehicle(462, -2482.5, 774.5, 34.842, 0, 0, 0, "15"), createVehicle(462, -2484, 774.5, 34.842, 0, 0, 0, "16"), createVehicle(462, -2485.5, 774.5, 34.842, 0, 0, 0, "17"), createVehicle(462, -2458.33398, 790, 34.842, 0, 0, 90, "18"), createVehicle(462, -2458.33398, 785.5, 34.842, 0, 0, 90, "19"), createVehicle(462, -2458.33398, 784, 34.842, 0, 0, 90, "20"), createVehicle(462, -2458.33398, 781, 34.842, 0, 0, 90, "21"), createVehicle(462, -2458.33398, 782.5, 34.842, 0, 0, 90, "22"), createVehicle(462, -2458.33398, 787, 34.842, 0, 0, 90, "23"), createVehicle(462, -2458.33398, 788.5, 34.842, 0, 0, 90, "24"), createVehicle(462, -2458.33398, 791.5, 34.842, 0, 0, 90, "25"), createVehicle(462, -2458.33398, 793, 34.842, 0, 0, 90, "26"), createVehicle(462, -2458.33398, 794.5, 34.842, 0, 0, 90, "27"), createVehicle(462, -2458.33398, 796, 34.842, 0, 0, 90, "28"), createVehicle(462, -2495.17603, 779, 34.842, 0, 0, 270, "29"), createVehicle(462, -2495.17603, 780.5, 34.842, 0, 0, 270, "30"), createVehicle(462, -2495.17603, 782, 34.842, 0, 0, 270, "31"), createVehicle(462, -2495.17603, 783.5, 34.842, 0, 0, 270, "32"), createVehicle(462, -2495.17603, 785, 34.842, 0, 0, 270, "33"), createVehicle(462, -2495.17603, 786.5, 34.842, 0, 0, 270, "34"), createVehicle(462, -2495.17603, 788, 34.842, 0, 0, 270, "35"), createVehicle(462, -2495.17603, 789.5, 34.842, 0, 0, 270, "36"), createVehicle(462, -2495.17603, 791, 34.842, 0, 0, 270, "37"), createVehicle(462, -2495.17603, 792.5, 34.842, 0, 0, 270, "38"), createVehicle(462, -2495.17603, 794, 34.842, 0, 0, 270, "39"), createVehicle(462, -2492.5, 796, 34.842, 0, 0, 180, "40"), createVehicle(462, -2491, 796, 34.842, 0, 0, 180, "41"), createVehicle(462, -2489.5, 796, 34.842, 0, 0, 180, "42"), createVehicle(462, -2488, 796, 34.842, 0, 0, 180, "43"), createVehicle(462, -2486.5, 796, 34.842, 0, 0, 180, "44"), createVehicle(462, -2485, 796, 34.842, 0, 0, 180, "45"), createVehicle(462, -2483.5, 796, 34.842, 0, 0, 180, "46"), createVehicle(462, -2482, 796, 34.842, 0, 0, 180, "47"), createVehicle(462, -2480.5, 796, 34.842, 0, 0, 180, "48"), createVehicle(462, -2479, 796, 34.842, 0, 0, 180, "49") } ) do setVehiclePaintjob(vehicle, 3) toggleVehicleRespawn (vehicle, true) setVehicleRespawnDelay (vehicle, 300000) setVehicleIdleRespawnDelay (vehicle, 600000) setElementData (vehicle, "freeCar", true) end and btw, this does not work: for i = 1, 49, 1 do noobnoobcars[tostring("noobcar"..i)] = true end After you create a car it will returns a user data, not a string with the data name.
  22. I am very far with building my gamemode and I was thinking about testing the performance on it. I am not sure if this is the right section, but it is quiet related to scripting. Also scripters may test their scripts and may know the answers. I did the testing with the performance stats, I am at the moment the only player in game. Name: SPY-vs-SPY change: 0 current: 178 kb max: 178 kb XMLFiles: nil refs: 20 Timers: 0 (timers only running when needed and there aren't much timers) Elements: 10 TextDisplays: nil TextItems: nil DB Queries: nil DB Connections: nil Is this a good score?(just for the core running)
  23. The only thing that worked for me was creating double objects. So one normal object and a lowlod. I am not sure if they work with interiors. I created this, but it wasn't very successfully when I use to many objects in the map. But you can always try to make it better then mines local LODMODEL_T = {} local objectLoaderCol = createColCircle ( 0, 0, 200) local objectUnLoaderCol = createColCircle ( 0, 0, 300) attachElements ( objectLoaderCol, localPlayer) attachElements (objectUnLoaderCol, localPlayer) addEventHandler("onClientRender",root, function () for i, LOD_OB in pairs (LODMODEL_T) do if isElement(LOD_OB[2]) then if getElementDimension (LOD_OB[1]) == 0 then if isElementWithinColShape ( LOD_OB[2], objectLoaderCol ) then setElementDimension ( LOD_OB[1], 6 ) setElementDimension ( LOD_OB[2], 0 ) end else if not isElementWithinColShape ( LOD_OB[2], objectLoaderCol ) and isElementWithinColShape ( LOD_OB[2], objectUnLoaderCol ) then setElementDimension ( LOD_OB[1], 0 ) setElementDimension ( LOD_OB[2], 6 ) end end else LODMODEL_T[i] = nil end end -- checking (not required) local amount = 0 -- When starting the command, we don't have any objects looped. for k,v in pairs ( LODMODEL_T ) do -- Looping all the objects in the server if isElement(v[2]) then if isElementStreamedIn ( v[2] ) then -- If the object is streamed in amount = amount + 1 -- It's an object more streamed in end end end dxDrawText (amount,5,10) -- end checking end)
  24. Nope, that isn't going to work. First of all when you get damage, there is most of the time a weapon, and gta will see that was weapon 16. "if not weapon then return end" and next to that gta/mta does have a very annoying bug. If you set a player his health at the same time he got damaged, his event won't be cancelled. This works, but I won't say it is the best solution. addEventHandler("onClientPlayerDamage", getLocalPlayer(), function (attacker, weapon) if weapon == 16 then setTimer(setMyHealth,50,1) cancelEvent() end end ) function setMyHealth () local health= getElementHealth(localPlayer) if health-20 > 0 then setElementHealth(localPlayer, health-20) else setElementHealth(localPlayer, 0) end end
  25. You can't, you can only make that if you are very good in scripting. That is more like, creating your own damage system.
×
×
  • Create New...