Jump to content

SDK

Members
  • Posts

    635
  • Joined

  • Last visited

Everything posted by SDK

  1. SDK

    Please Help Guys

    You do know the marker is set to dimension and interior 3?
  2. SDK

    [HELP]Command....

    Then learn to read or learn to script, this is not a request forum despite all the replies
  3. SDK

    PM system

    Commandhandlers work this way: function testFunction( player, command, word1, word2, word3, word4 ) If you want to get all words, use this: function testFunction(player, command, word1, ... ) allWords = table.concat(arg, " ") -- this will be all words from word2 to the last word in one string
  4. SDK

    WTF?!

    Use debugscript 3 and post the complete code .. And I can already tell you that source is probably wrong and should be getPedOccupiedVehicle(player)
  5. SDK

    WTF?!

    Maybe tell us what this should be? Explain more please
  6. I could be misunderstanding you, but the medic vehicle is the same as the cop car in that script So off course it will not work, change it to the correct vehicle ID's
  7. Post the new script and if you can add some example from your table using this: https://community.multitheftauto.com/index.php?p= ... ils&id=495
  8. I don't think it works that way, it only disables the engine sound afaik and doesn't do anything physical. If you want to make it look like the engine doesn't work you can either freeze it or disable the vehicle controls on entering the vehicle.
  9. SDK

    next map

    The stopResource and startResource are wrong, use the correct pointers. Or if you're running mapmanager, you can use this (it's probably better to not use this tho): local lastmap = nil function startnextmap() local gamemode = exports.mapmanager:getRunningGamemode() -- current gamemode local array = exports.mapmanager:getMapsCompatibleWithGamemode(gamemode) local nextmap = array[math.random(1,#array)] if lastmap ~= nextmap then stopResource(exports.mapmanager:getRunningGamemodeMap()) startResource(nextmap) lastmap = nextmap end end
  10. It means DDAttemps[1] = nil. I guess your SQL select returns an empty table, try checking your select + results.
  11. I did not check your code very well but this is what you should do. After jailing/logging in you put up a timer that runs a function each second. That function will do two things: if the jailtime is higher then 0, you update in sql the time value minus 1 second and the timer continues if the jailtime is lower then 1, you unjail the player and stop the timer
  12. policeVehicle = createVehicle ( 426, 2418.4436035156, 85.328956604004, 26.292650222778, 0, 0, 90 ) policeSkins = { [286]=true,[288]=true } function enterVehicle ( player, seat, jacked ) if (policeVehicle == source) and not policeSkins[getElementModel(player)] then outputChatBox ( "You're not a cop!", player ) cancelEvent() end end addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) This is really basic stuff, stop putting "Don't copy my code" and start learning more lua
  13. SDK

    [HELP]Command....

    Eh, you can't do onPlayerChat and addCommandHandler on the same function .. function pointsCommand (player, message, arg1) local tplayer = getPlayerFromName(arg1) or source local playerPoints = loadPlayerData (tplayer,"points") setTimer(outputChatBox,50,1,getPlayerName (tplayer) .. " #FF0000has " .. tostring(playerPoints) .. " points!",getRootElement(),255,0,0,true) end end addCommandHandler('points', pointsCommand) addEventHandler ("onPlayerChat",getRootElement(), function(message, mtype) message = split(message,32) if mtype == 0 then if message[1] == "!points" then pointsCommand(source, "!points", message[2]) end end end) And yes this needs full name, if you don't want that copy the function from some other script and insert it yourself
  14. SDK

    [HELP]Command....

    Quick edit, not tested: addEventHandler ("onPlayerChat",getRootElement(), function(message,type) message = split(message,32) if (message[1] == "!points") then local player = getPlayerFromName(message[2]) or source local playerPoints = loadPlayerData (player,"points") setTimer(outputChatBox,50,1,getPlayerName (player) .. " #FF0000has " .. tostring(playerPoints) .. " points!",getRootElement(),255,0,0,true)
  15. That method probably only worked for that part I saw, it's probably best to make it again and keep it relative from the start
  16. Where did you edit and where is the event handler for onClientResourceStart ? Please post the complete code again, I don't see anything wrong for what I can see now.
  17. The VehicleInfo with your query's IS available from everywhere, you can try a simple for outputChatBox loop to test it. Your problem is to get for the correct vehicle the matching info from the table. But vehicles don't get ID's when created, so you'll have to link the database info with the vehicle when you spawn it. I hope I explained it good enough
  18. onColShapeHit doesn't exist clientside, it's onClientColShapeHit. But as Scooby suggests, use onClientResourceStart to create the window and setElementVisible when entering the colshape.
  19. 1st, vehicle is defined as a number: if (getElementModel(getPedOccupiedVehicle(player)) == vehicle) then -- If Player is in Carrier Vehicle... 2nd, to search te player I think it would be better using a for loop instead of a repeat: outputChatBox("in heli...") local target for i, tplayer in ipairs(getElementsByType('player')) do local tx, ty, tz = getElementPosition(tplayer) -- Search Through Players, Find One Within 3 Pixels, Check Vehicle... if (tplayer ~= player) and getPedOccupiedVehicle(tplayer) and getDistanceBetweenPoints2D(x,y,tx,ty) < 20 then target = tplayer break end end attachElements(target, player, 0, 0, -2) carrying = target But why clientside? Shouldn't it be serverside?
  20. Try this function drawTripleXLogoImage() GUIEditor_Image = {} local sWidth, sHeight =1920, 1080 GUIEditor_Image[1] = guiCreateStaticImage( (sWidth-1334.976)/sWidth, (sHeight-169.992)/sHeight, (sWidth-1265.088)/sWidth, (sHeight-910.008)/sHeight, "triplexlogo.png",true) guiSetAlpha(GUIEditor_Image[1],1) end addEventHandler("onClientResourceStart",getRootElement(), drawTripleXLogoImage)
  21. I see, try it this way: VehicleInfo = {} ... for idx=1, maxve do ... local vehicleElement = createVehicle(id,x,y,z) setElementData( vehicleElement, "vehicle_id", idx) -- attach your ID VehicleInfo[idx] = {} VehicleInfo[idx].VehID = getElementModel(vehicleElement) ... end and function Test(theVehicle, seat, jacked) local idx = getElementData(theVehicle,"vehicle_id") -- get the attached ID if type(idx) == "number" then -- check if there actually was an ID local data = VehicleInfo[idx] outputChatBox("Vehicle: "..idx.."Information:"..data.VehID,source) end end addEventHandler("onPlayerVehicleEnter", getRootElement(), Test) setElementData allows to attach any variable to your vehicle, so you could use your own ID's
  22. I don't know, I just wasn't sure if it would work, you're nowhere referring to the player. And what is that vehicles table?
  23. for idx=1, maxve do You can not use this to identify all vehicles! The type of idx is a number, vehicles are stored as an element! And you're probably setting elementdata on the number too (which isn't possible since idx is no element). What exactly are you trying to do?
  24. SDK

    /renametime

    This is not a request forum. Make it yourself using executeSQLUpdate, or request it at the original author, since this code is copy pasted.
  25. That many if's do make the code look complicated, since you'll go pretty 'deep' and have many end's. Instead, use elseif and return. About the code, addCommandHandler needs different arguments, but I can't really help you since I don't know how the rest of the script looks like. (The sql part seems weird tho) function togwindows ( player, command ) -- first the checks if the player has everything needed: if not exports.players:isLoggedIn( player ) then return false -- not logged in, stop code elseif not isPedInVehicle ( player ) then outputChatBox( "You are not in a vehicle.", player, 255, 0, 0 ) return false -- no vehicle, stop code end -- then the actual code, which I don't know how to fix, sql seems weird local vehicle = getPedOccupiedVehicle(player) local data = vehicles[ vehicle ] if data and data.vehicleID > 0 and data.windows == 0 then local success, error = exports.sql:query_free( "UPDATE vehicles SET windows = 1 WHERE vehicleID = " .. data.vehicleID ) if success then exports.chat:me( source, "rolls the windows up.") end if error then outputChatBox( "My-SQL Error.", source, 255, 0, 0 ) end elseif data.windows == 1 then local success, error = exports.sql:query_free( "UPDATE vehicles SET windows = 0 WHERE vehicleID = " .. data.vehicleID ) if success then exports.chat:me( source, "rolls the windows down.") end if error then outputChatBox( "My-SQL Error.", source, 255, 0, 0 ) else outputChatBox( "You can't do this with a temporary vehicle. (SQL Error)", source, 255, 0, 0 ) end end end addCommandHandler( "togwindows", togwindows)
×
×
  • Create New...