Jump to content

Bonus

Members
  • Posts

    297
  • Joined

  • Last visited

Everything posted by Bonus

  1. What? Does it really say localPlayer is a nil value? Then you put it serversided - put it clientsided with type="client" But the code is correct, the code from Dimos7 is wrong.
  2. You can use cancelEvent in onClientPlayerDamage. Weapon ID should be 54 I think.
  3. The timer is useless. Just trigger the left time in ms serversided. triggerClientEvent ( "lefttime", root, 10000 ) -- 10sec Then in addEventHandler save this rest time + getTickCount(). To get the rest time you just have to: savedtime - getTickCount() = rest time in ms. -- Client -- local timetoend = 0 addEvent ... addEventHandler ( ..., function ( resttime ) timetoend = getTickCount() + resttime end ) addCommandHandler ( "gettimer", function () outputChatBox ( "It's "..timetoend - getTickCount().."ms left" )
  4. We can't help you if you don't show the code correctly. Put the dxDrawImage in tostring and outputDebugString pls. outputDebugString ( tostring ( dxDrawImage ... ) ) Any outputs in debugscript
  5. I didn't talk about guiSetVisible, I said: "Then save the vehicle to a variable and use this variable in triggerServerEvent in getIntoMacineGun." You can get the vehicle by colshape if you save it in an array like: local colVehicle = {} local vehnearplayer = nil ... colVehicle[col] = vehicle ... addEventHandler ( "onClientColShapeHit", col, function ( hitElement, dim ) if dim and hitElement == getLocalPlayer then vehnearplayer = colVehicle[source] end end )
  6. Bonus

    boss

    You dont use a name when you directly create the function in another MTA-function. function ( weapon, ammo ) setTimer ( function ( ... ) ... end, ... ) addEventHandler ( ..., function ( ... ) ... end ) table.sort ( array, function ( ... ) ... end ) bindKey ( ..., function
  7. That's now a new thing You should use onClientColShapeHit to know when the player entered a colshape. Then save the vehicle to a variable and use this variable in triggerServerEvent in getIntoMacineGun.
  8. Don't you want to learn the basics first? Your scripting-knowledge is terrible and you don't learn anything from my texts. It's more like you are getting worse. I said like 10 times that you can't use veh without getting it. You are using a variable which doesnt even exists. Now you put a colshape (why?) and ask if the localPlayer is NOT in a vehicle. IF NOT IN A VEHICLE Wth are you trying to do?
  9. Show me clientside And better use client instead of source. source is the source of the event, client is the one who triggers it. That means it's possible to fake event like triggerServerEvent ( "eventname", getPlayerFromName ( "Bonus" ) ) I don't really know how to fake events, but it's possible. Some hackers can join game and fake events by injecting LUA code, dunno how. Thats why you should always use client when you wanna get the one, who triggered the event.
  10. I explain the same again now ... bindKey gives you clientsided on a function 2 arguments: key and keystate. key is "h" here keystate is "down" Now there are 2 ways how to get vehicle (cause key and keystate arent vehicle): 1. Check if player is in a vehicle and if he is the driver, then get the vehicle by getPedOccupiedVehicle 2. Use bindKey on vehicle enter, if seat == 0, put the vehicle as argument for bindkey and use it. Unbind it again on vehicle exit. The 2. way is faster and more professional, the first way is not so good, cause why always check if you are a driver when you can directly just bind it, if you are the driver. Thats why I showed you the second way. But before I wrote the 1. way too, you just ignored it and only saw the code, don't do that.
  11. Read the WHOLE text again! You want help but ignore the texts, gj
  12. You mean resetWaterLevel does the same problem?
  13. Did you try resetWaterLevel? And can you try to set the water level to -0.001
  14. local countdownMS = false setTimer ( function() if guiGetVisible ( idlewind ) then if not countdownMS then countdownMS = getTickCount() + 350000 end local m,s = getTimeMS(countdownMS-getTickCount()) guiSetText( timer, " Minutes: "..m.." | Seconds:"..s ); else countdownMS = false -- if you wanna stop the countdown when gui is closed. end end, 1000, 0 ) And just use countdownMS = getTickCount() + 350000 again to reset the Countdown.
  15. Read: https://wiki.multitheftauto.com/wiki/BindKey "The values passed to this function are: key: The key that was pressed keyState: The state of the key that was pressed, down if it was pressed, up if it was released. arguments The optional arguments you specified when calling bindKey (see below)." You cant use getIntoMacineGun ( veh ) when bindKey gives you key (here "h", not vehicle!), keystate and other arguments. Then you can use getIntoMacineGun ( key, keystate ) but there is no vehicle. If you wanna get the vehicle there you can use getPedOccupiedVehicle. Or you can use bindKey only when someone enters vehicle: function getIntoMacineGun ( _, _, veh ) -- I use _ instead of key or state to show, that I don't use these arguments ... end addEventHandler ( "onClientPlayerVehicleEnter", localPlayer, function ( veh, seat ) if seat == 0 then bindKey ( "h", "down", getIntoMacineGun, veh ) -- here veh is this "other arguments" end end ) addEventHandler ( "onClientPlayerVehicleExit", localPlayer, function ( veh, seat ) if seat == 0 then unbindKey ( "h", "down", getIntoMacineGun ) end end )
  16. I don't really understand what you want. If you want the countdown to start after opening the GUI, why do you put countdownMS there and don't put the setTimer in the function, which opens the GUI? If you want to reset the countdown just use countdownMS = getTickCount() + 350000 again
  17. Where is "veh" defined in client? Look in MTA wiki, whats "theElement" and what is "source" here? What to use instead of veh.
  18. And know you are doing other things again. 1. Why use source? Use client again! 2. Why use getRootElement() as source in triggerClientEvent? Use client again, its better. 3. When you trigger result instead of result[1] the array is in this form: result = { [1] = { [coulmn] = value, [column] = value ... }, [2] = ... ... [amountRowsInDatabase] = {...} } That means: To get the ID of the first vehicle you have to use result[1]["ID"] for index, row in pairs ( result ) do outputChatBox ( row["ID"]..": "..row["Name"] ) ... end And for your info: 0.3 + 0.3 + 0.3 = 0.9, not 1.0 Oh and next time WAIT ffs. It was fkin 6 AM here when you wrote this, maybe I am sleeping?
  19. Server is much better now, but client won't open that way. Serversided you should use triggerClientEvent to trigger the result, the best would be if you trigger result[1]. Clientsided you again need addEvent and addEventHandler. Here you use local gridlist = guiCreateGridList ( ... ) local columncolumn = guiGridListAddColumn ( gridlist, "Column", 0.2 ) local valuecolumn = guiGridListAddColumn ( gridlist, "Value", 0.8 ) for column, value in pairs ( triggeredresult ) do local row = guiGridListAddRow ( gridlist ) guiGridListSetItemText ( gridlist, row, columncolumn, column, false, false ) guiGridListSetItemText ( gridlist, row, valuecolumn, value, false, false ) end Wrote on phone
  20. 1. if guiSetVisible ( wndPVList, false ) then Wtf? 2. Read the info! "Note: Connecting and disconnecting many times can have a performance impact on the server. For optimal performance it is recommended that you use dbConnect only once when the resource starts, and share the connection element with the whole script." 3. Don't like local? You should like it, use it! It's safer and faster. 4. Again, read the infos! dbExec: "This function executes a database query using the supplied connection. No result is returned." Don't use dbExec with select! 5. Use client instead of source. Else they can fake events and get the data of other players First of all fix these ones ...
  21. Bonus

    marker

    https://forum.multitheftauto.com/viewtopic.php?f=91&t=96571
  22. -- Client -- addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) local txd = engineLoadTXD ( pathoftxd ) engineImportTXD ( txd, 1337 ) local dff = engineLoadDFF ( pathofdff ) engineReplaceModel ( dff, 1337 ) end ) -- Server -- function createCustomMarker ( x, y, z, theType, size, r, g, b, a, visibleTo ) local x = tonumber ( x ) or false if x then local y = tonumber ( y ) or false if y then local z = tonumber ( z ) or false if z then local theType = theType or "checkpoint" local size = tonumber ( size ) or 4.0 local a = tonumber ( a ) or 255 local visibleTo = visibleTo or root local marker = createMarker ( x, y, z, theType, size, 0, 0, 0, 0, visibleTo ) if marker then local object = createObject ( 1337, x, y, z ) setObjectScale ( object, size ) -- I bet you have to try a calculation for the perfect size setElementCollisionsEnabled ( object, false ) setElementFrozen ( object, true ) setElementAlpha ( object, a ) if visibleTo ~= root then setElementVisibleTo ( object, root, false ) setElementVisibleTo ( object, visibleTo, true ) end attachElements ( object, marker ) setElementParent ( object, marker ) return marker end end end end end return false end Try that, should work if I did everything right.
  23. -- Client triggerServerEvent ( "thatthing", localPlayer, arg1, arg2 ) triggerServerEvent ( "thatthing2", localPlayer, arg1, arg2, arg3, arg4 ) triggerServerEvent ( "thatthing3", localPlayer, arg1 ) -- Server -- addEventHandler ( "thatthing", root, function ( arg1, arg2 ) ... addEventHandler ( "thatthing2", root, function ( arg1, arg2, arg3 ) ... addEventHandler ( "thatthing3", root, function ( arg1, arg2 ) ... -- here arg2 is nil Here client is the player, who triggered it. source is the one, who is source of the event. We used localPlayer in triggerServerEvent, so the same player is the source. example: -- Client -- triggerServerEvent ( "dothatthing", localPlayer, "hi", 255, 0, 0 ) -- Server -- addEvent ( "dothatthing", true ) addEventHandler ( "dothatthing", root, function ( arg1, arg2, arg3, arg4 ) outputChatBox ( getPlayerName(client)..": "..arg1, root, arg2, arg3, arg4 ) end ) -- Output: -- "Bonus: hi" in red color
  24. You can use every object, but smaller = better
×
×
  • Create New...