Jump to content

Saml1er

Retired Staff
  • Posts

    1,058
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Saml1er

  1. Saml1er

    Gate Script

    Hahahahahah. I was just going through your old posts for a good laugh and I was hoping that you changed your way of thinking because 2 years passed but nah you're still the same. I wonder why would someone rewrite functions? May God guide you....
  2. Saml1er

    Dead Peds

    I believe bons already found the solution. Solution: Just use setCameraMatrix in onClientRender event. That's the only way to do it. Race resource did it in this way.
  3. Saml1er

    MySQL

    dbPoll - It is used for querying. Use -1 which will wait till result is ready and then return. Currently there is 0 which will instantly return and may sometimes return nil. So use -1. Line 2 checks if result is success and checks only if 1 row is returned. Line 4 result variable is set to first row or in other words, result variable has the first row data. Line 6 string.lower will make convert the string to lower case letters. For md5, check https://wiki.multitheftauto.com/wiki/Md5
  4. Thanks You're welcome.
  5. Where is the link to your resource? Great job btw. It will be better if you put the github link at bottom or top of your post. Before you dive deep into the concepts of meta tables, le t me tell you that this is the most challenging part in lua you'll ever face. Go to lua.org for better explanations. You can also search for examples on forum to understand how they work. Also you can check out setfenv, setmetatable and lua environments. It took me like a month to understand them. Keep practising and you'll eventually learn.
  6. Add this check to both functions: if Vehicles[getElementModel(source)] then -- timer here end
  7. I believe you are looking for https://wiki.multitheftauto.com/wiki/OnClientKey
  8. Instead of finding the player, why don't you simply send the player element using triggerClientEvent. Currently you are sending name which is not the right way to do it.
  9. Replace the function with this: function siramiayarla(name, i) local player = getPlayerFromPartialName(name) if not player then outputChatBox ( "Player not found. Name" ..name.. "/ i: "..i ) else outputChatBox("player found") end setElementData(player,"Sıra",i) end After running the code let me know what it outputs.
  10. Saml1er

    events issue

    You mean you want to check which time variable has more time passed/eplased? If that's the case then you can simply check it with milliseconds before converting them to string format. If you meant string time format then you can use a function: -- I'm using this function since many years. I took this from coronalabs forum. local function mstostr( newfresh ) local floor = math.floor local ms = floor(newfresh % 1000) local hundredths = floor(ms / 10) local seconds = floor(newfresh / 1000) local minutes = floor(seconds / 60); seconds = floor(seconds % 60) return string.format("%02d:%02d", minutes, seconds) end Usage: local str =mstostr ( milliSeCondsHERE )
  11. Saml1er

    events issue

    Yep but you're using bad technique there. Here: function onQuit() local c = EventCore.GetPlayersInEvent ( ) if ( #c == 1 ) then theRealWinner = c[1] EventCore.WinPlayerEvent ( c[1] ) end end Also I did a small fix there of my own code: local theRealWinner -- nil for now function thisEventFunctions.OnPlayerWasted ( _, killer ) local plrs = EventCore.GetPlayersInEvent ( ) local winner = nil if ( table.len ( plrs ) == 0 ) and theRealWinner ~= source then -- if the last player standing has already received the reward then don't give it to him again winner = source theRealWinner =nil elseif ( table.len ( plrs ) == 1 ) then winner = plrs [1] theRealWinner = winner end end if winner then EventCore.WinPlayerEvent ( winner ) end end addEventHandler ( "onPlayerWasted", root, thisEventFunctions.OnPlayerWasted )
  12. Saml1er

    events issue

    local theRealWinner -- nil for now function thisEventFunctions.OnPlayerWasted ( _, killer ) local plrs = EventCore.GetPlayersInEvent ( ) local winner = nil if ( table.len ( plrs ) == 0 ) and theRealWinner ~= source then -- if the last player standing has already received the reward then don't give it to him again winner = source elseif ( table.len ( plrs ) == 1 ) then winner = plrs [1] theRealWinner = winner end end if winner then EventCore.WinPlayerEvent ( winner ) end end addEventHandler ( "onPlayerWasted", root, thisEventFunctions.OnPlayerWasted ) if this doesn't work then there must be a flaw in EventCore.GetPlayersInEvent ( ) function. Make sure that you are not using element data to get alive player.
  13. Sorry for late reply.. Well you will need to do that in c++. You can use boost serialization for datagrams ( packets ) and then send them over the network and unpack them at the server side but the easy way would be to use RakNet as RakNet is open source since 2015 so you take full advantage of it to send/receive packets as it is the most easy way to do so. Also yeah you will need to use a module for server side as you will need to unpack the packets. I'll quote myself:
  14. You first create a socket > Bind the destination address to it > Now if it is server then you listen on the TCP socket otherwise you connect to server if it is client > Accept connections on server side > establish the connection client to server > Now you can send/ receive packets. You must open the TCP port for server side and you can't send/receive on the same port as 22005 or 22003 because they are used by MTA so choose a different port like 66553 or something else.
  15. Syncing will always be worse if you're not using UDP. I know most programmers will not agree to this because its too much technical work for a small gamemode but thats the only efficient way. Basically triggerClientEvent/triggerServerEvent uses TCP so that no packet is lost but its very slow as compared to UDP and it will usually lagg if it is used for syncing. Newbies usually use setElementData for FPS in onClientRender but these poor souls never realise that its a complete disaster when you have 100+ players in your server. However, if you don't increase the maximum player limit then your script should do fine. ^^
  16. Element data is a bad solution in this case. Do it like this: create a colshape in server side for every individual player and attach them to players, when a player is shooting/rotation with a weapon then simply get the current players in the colshape and trigger. This will reduce a huge amount of traffic. Also when you trigger use triggerClientEvent then pass a table of player elements that you want to sent data to instead of looping through table and triggering for each client ( It will help a lot if you don't belive me then try sending 3 mb of data using triggerLatentClientEvent using a loop for 20 players and see what happens )
  17. Just remove line 9 (timer) from the code that you posted and add this code at bottom addEventHandler("onPlayerSpawn", root, function () setPedHeadless( source, false) end )
  18. Saml1er

    Dx Library?

    I wrote a dx library which makes use of dx functions to make gridlists, rectangles, buttons and edit boxes. It also plays a click sound. I don't have any use for it so I guess you can use it. I will upload it to community tomorrow. I will let you know.
  19. Your first code is right. Just add this before loop. math.randomseed (getTickCount () ) -- Now you can loop through table and use math.random
  20. What are you trying achieve? I think you are looking for this: https://wiki.multitheftauto.com/wiki/FindRotation
  21. Can I know what are you trying to achieve?
  22. This is all you need: engineSetModelLODDistance(model, 170) -- 170 is the best greater value as suggested by wiki
  23. 000webhost does not accept remote connections if you're using the free version. It might not allow you to connect to db.
  24. Simple answer: It is equivalent to server side function createObject. EDIT: You really spinned my head. I will check whether if I see that download bar when using server side scripts.
×
×
  • Create New...