Jump to content

IIYAMA

Moderators
  • Posts

    6,063
  • Joined

  • Last visited

  • Days Won

    209

Everything posted by IIYAMA

  1. 1: How many times does this function gets called? 2: What is the position after the reset? 3: And what is the position before you affect any of the components? 4: Does the function getVehicleComponentPosition moves the component down? Or the result is, moved down? Debug the results. After what you told me, I would say resetVehicleComponentPosition doesn't reset everything well. But if that is the case, make sure you backup the original position. (or save it) local modelComponentPosition = {} local model = getElementModel(source) local bufferModelComponentData = modelComponentPosition[model] if not bufferModelComponentData then modelComponentPosition[model]= {} end for k in pairs ( getVehicleComponents ( source ) ) do if ( k ~= "exhaust_ok" ) then local x, y, z = bufferModelComponentData and table.unpack(bufferModelComponentData[k]) or getVehicleComponentPosition ( source, k ) setVehicleComponentPosition ( source, k, x, y, z) if not bufferModelComponentData then modelComponentPosition[model][k] = {x, y, z} end end end But maybe you can better generate a xml document with original positions, then you won't have trouble with bugs.
  2. Well, combine the code from a both and you have it. But make sure you have a table with valid players you can loop through, so the variable "player" can be defined.
  3. local x,y,z = getElementPosition(chair) local sx,sy,sz,_,_,_ = getCameraMatrix(player) if not sx then sx,sy,sz = getElementPosition(player) end setCameraMatrix(player,sx,sy,sz,x,y,z) I don't know what you want, explain better with less nonsense. local lastPosition = {} setTimer(function () if not lastPosition then local x,y,z = getElementPosition(chair) if getDistanceBetweenPoints3D(x,y,z,lastPosition[1],lastPosition[2],lastPosition[3]) > 0.1 then outputChatBox("chair moved!") lastPosition = {x,y,z} end else lastPosition = {getElementPosition(chair)} end end,100,0)
  4. Another way of requesting images from other resources: (not tested but should be working) <export function="requestImage" type="client"/> local requestDatabase = {} function requestImage (filePath,buffer) if requestDatabase[filePath] then return requestDatabase[filePath]["texture"] elseif fileExists (filePath) then local texture = dxCreateTexture(filePath) if texture then if buffer then requestDatabase[filePath] = {["texture"]= texture,["creationTime"]=getRealTime().timestamp} end return texture end end return false end local image = call ( getResourceFromName ( "**********" ), "requestImage",filePath,true)
  5. This is not a place for requests. You know what and how to fix your code, now do it! Move that lazy ass of yours.
  6. That will dissable all damage, if he wants it that way then yes. But what I am trying to tell you is that you never know when the damage is caused by the fire.
  7. Damage from fire is most of the time not bounded to an attacker or the attacker weapon is unknown. Cancel using cancelEvent() would be hard under those conditions. The result will be in the end the same, it doesn't matter who owns the fire you simply die... So setTeamFriendlyFire would give the most performance. If you don't want fire in your server: addEventHandler("onClientPreRender",root, function () if isPedOnFire(localPlayer) then setPedOnFire(localPlayer,false) end end)
  8. Ey horse guy, are you even listening to me?
  9. @Derpy why are you changing your tabs while scrolling? Afaik your scroll is vertical(for the items) and not horizontal(for the tabs). local tabTextSize = 0 for i=1,#tab do local tabTitle = tab[i] dxDrawText(tabTitle,x,y+tabTextSize-5,sw,sh,tocolor(255,255,255),scaleX,font) -- THERE IS NO ,scaleY !!!!!! tabTextSize = tabTextSize+dxGetTextWidth(tabTitle,scaleX,font)+10 --tab tab tab tab ...
  10. It is: getElementType getElementModel outputChatBox and not: getElemntType isElementModel OutPutChatBox And don't tell me you don't see any warnings of that, because that would a lie. Unless your meta is incorrect...
  11. I recommend this: function delayedKill (player,command) -- player = you, command = "test1" setTimer (function () if isElement(player) then -- Players can leave during the timer, which will give you warning if this happens. killPed(player) end end,1500, 1) end addCommandHandler ("test1", delayedKill) As scripter you don't want warnings during execute your code. Warnings = lagg and fill up your server logs.
  12. Well it would be nice to keep the camera static. Like this: local playerCameraTarget = {0,0,0} local extendLine2D = function ( x,y,x2,y2,length ) local vx = x2 - x local vy = y2 - y local ratio = length/(getDistanceBetweenPoints2D ( x,y,x2,y2 )) vx = vx*ratio vy = vy*ratio return (x + vx),(y + vy) end addEventHandler("onClientPreRender",root, function () local playerX,playerY,playerZ = getElementPosition(localPlayer) local cameraTargetX,cameraTargetY,cameraTargetZ = playerCameraTarget[1],playerCameraTarget[2],playerCameraTarget[3] local distance2DFromCameraTarget = getDistanceBetweenPoints2D(cameraTargetX,cameraTargetY,playerX,playerY) local cameraStartX,cameraStartY = extendLine2D(cameraTargetX,cameraTargetY,playerX,playerY,distance2DFromCameraTarget+6) local cameraEndX,cameraEndY = extendLine2D(cameraTargetX,cameraTargetY,playerX,playerY,distance2DFromCameraTarget-10) setCameraMatrix ( cameraStartX,cameraStartY,playerZ+1, cameraEndX,cameraEndY,playerZ, 0, 0, 70 ) end)
  13. IIYAMA

    Basic's SQL

    thank you very much!
  14. IIYAMA

    Basic's SQL

    Also thank you Novo and Anubhav for other explanations, examples and websites! Storing and loading, it is all working now!
  15. IIYAMA

    Basic's SQL

    ah yea, mist that one. Yet not critical, since false can never be 0. thx
  16. IIYAMA

    Basic's SQL

    Huh? Why would you define a table under the name query? And at line 7 you check if: it isn't a table or the variable query isn't empty or variable query. Should be: if type(result) == "table" and #result~= 0 then Yet I didn't notice any real mistakes in it, just extra checks. Thx for that.
  17. IIYAMA

    Basic's SQL

    Aha. I am planning to update it slowly, using a table which contains the same data as the database. So I don't have to call the database to receive data from the players. Just only storage and only loading data when they join. Just wondering, why do I have to index the result 1 time more before I can access the main data? function loadData (player) local account = getPlayerAccount (player) if not isGuestAccount(account) then local accountName = getAccountName(account) if accountName then local query = dbQuery(connection, "SELECT * FROM `accounts` WHERE `username` = ?", accountName) if query and rows ~= 0 then local result, rows = dbPoll(query, -1) if result then for index,data in pairs(result[1]) do outputDebugString(tostring(index) .. " " .. tostring(data)) end end end end end end addCommandHandler("loadData",loadData) This part solved: and this doesn't seems to work: (no errors/warnings) and returns true -- the total string looks like this: -- "UPDATE `accounts` SET `location` = ?, `status` = ?, `weaponSkills` = ?, `serial` = ? WHERE `username` = ?" dbExec(connection, "UPDATE `accounts` SET " .. dbString .. " WHERE `username` = ?", unpack(dbArguments))
  18. It depends if you use custom table Keys. When you use them in combination with the pairs loop. (not ipairs) It is possible and manage able.
  19. It doesn't show up, because I created an error/warning or you didn't use the piss command. Yet your previous code is kinda strange and has a lot of features you don't need. (like having the possibility to create multiply bars, which you aren't using in your code.) The reason why you can't update it, is because your data can't be edited easily. When you use the piss command multiply times, it will fill up the table with the same data. The data will never be delete, it will only increase. And at the end the players with not very good pc's will have very low fps. Pls stick with the latest code I posted and debug is correctly.
  20. IIYAMA

    Basic's SQL

    Aha, great! Another question, now I get the data based on the column username. "UPDATE `accounts` SET `serial`= ?, `playerName` = ? WHERE `username` = ?" But can I also use the playerName or serial to find the account right? "UPDATE `accounts` SET `serial`= ?, `username` = ? WHERE `playerName` = ?" Or am I limited to the key I first used to insert? Which is in this case the key username. dbExec(connect, "INSERT INTO `accounts` SET `username` = ?", accountName)
  21. IIYAMA

    Basic's SQL

    Will predefined columns give more performance? (while edit that column the next time) The ones you can create with "CREATE TABLE IF NOT EXISTS".
  22. IIYAMA

    Basic's SQL

    aha I understand that part now. (I am a fast learner) Another question: dbExec( connection, "INSERT INTO table_name VALUES (?,?,?)", "aaa", "bbb", 10 ) --(From wiki) Will I be able to add more than 3 values later?
  23. IIYAMA

    Basic's SQL

    "UPDATE `accounts` SET `serial`= ?, `playerName` = ? WHERE `username` = ?" The "WHERE" must be the last thing in the string?
  24. IIYAMA

    Basic's SQL

    Is this how I can make accounts like with accountdata? Or I do get problems with special characters in the players their names? local connect = dbConnect ( "sqlite", "file.db" ) local possibleData = { "serial TEXT", "playerName TEXT" } addCommandHandler("test", function (player) local account getPlayerAccount(player) if not isGuestAccount (account) then local accountName = getAccountName(account) local serial = getPlayerSerial(player) local playerName = getPlayerName(player) dbExec ( connect, "CREATE TABLE IF NOT EXISTS `" .. accountName .. "` ( " .. table.concat(possibleData,", ") .. ")" ) dbExec ( connect, "INSERT INTO `" .. accountName .. "` SET `serial`=?, `playerName`=?", serial, playerName ) end end)
  25. IIYAMA

    Basic's SQL

    Can you continuous my addCommandHandler example, so I know how I can use the account name as key for the sql table?
×
×
  • Create New...