Jump to content

..:D&G:..

Members
  • Posts

    1,028
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by ..:D&G:..

  1. Nope, it still says that an element is expected at argument 2 for the event onPickupHit. I tried creating a separate pickup on top of that function (outside any functions) and it works. For some reasons it doesn't get the pickup from the first function I even tried this: function pickupShowGarageGUI(thePlayer) for i, v in ipairs (getElementsByType("object")) do if (getElementModel(v) == 17950) then pickup = getElementData(v, "pickup") outputChatBox("Working fine",thePlayer) triggerClientEvent ( thePlayer, "showGarageUI", thePlayer ) end end end addEventHandler ( "onPickupHit", pickup, pickupShowGarageGUI ) The pickup is attached to a garage, but it still says that there is no element at argument 2
  2. function spawnGaragesOnStart( res ) local result = mysqli:query("SELECT x, y, z, interior, dimension FROM garages") while true do local row = mysqli:fetch_assoc(result) if not (row) then break end local x = row['x'] local y = row['y'] local z = row['z'] local int = row['interior'] local dim = row['dimension'] pickup = createPickup ( x+4.40, y+4, z-1, 3, 1277, 0, 0 ) setElementData(garage, "pickup", pickup) setElementInterior(pickup, tonumber(int)) setElementDimension(pickup, tonumber(dim)) end mysqli:free_result(result) end addEventHandler("onResourceStart", resourceRoot, spawnGaragesOnStart) function pickupShowGarageGUI(thePlayer) if ( source ~= pickup ) then return end triggerClientEvent ( thePlayer, "showGarageUI", thePlayer ) end addEventHandler ( "onPickupHit", resourceRoot, pickupShowGarageGUI )
  3. Um.. this section is for scripting only Also, the guy can sell them for what he wants, if people buy them, good for him (I guess), most of those scripts have been leaked anyway
  4. That doesn't work at all. It is like the event is not even there
  5. I can't really put the line on top of the code, cuz it's getting the coordinates from a MySQL table: pickup = createPickup ( x+4.40, y+4, z-1, 3, 1277, 0, 0 ) Is there other way of doing it?
  6. It is, as I said, the function that creates the pickup is ON TOP of that function with onPickupHit. Also I have not local'ed it. The function that creates the pickup has the onResourceStart event, maybe that interferes with the other function/event?
  7. Yes it is. The pickup's function is on top of the onPickupHit function.
  8. Um... ok.. <meta> <script src="garage_server.lua" type="server" /> <script src="garage_client.lua" type="client" /> <file src="pickup.txd"/> <file src="pickup.dff"/> <file src="icon.png"/> <export function="openGarageGate" type="server" /> </meta>
  9. Hi, I am trying to make a function that opens a client side window when the player hits a pickup function pickupShowGarageGUI(thePlayer) showGarageGUI() end addEventHandler ( "onPickupHit", pickup, pickupShowGarageGUI ) There is the function, and the pickup is in another function but same file (server side): pickup = createPickup ( x+4.40, y+4, z-1, 3, 1277, 0, 0 ) I keep getting that error, which says that an element is expected at argument 2 ("pickup") and got nil, but the pickup exists...
  10. I am not really good with SQLite, my code should work if you have a roleplay mysql resource...
  11. Well first check what's the name of the collumn of your MySQL database where the name of the business goes and change "name" to the name of the collumn. Also, getBusName is just a name for the function arguments, so it doesn't matter how you name it in the function and trigger if they are in the same order. EG: If in server side you have "function testFunction (thePlayer, argument1, argument2)" and in client you trigger something like this "triggerServerEvent ( "testFunction", thePlayer, arg1, arg2 )" then what you have for arg1 and arg2 will output in argument1 and argument2... I'm not really good at explaining
  12. mysql = exports.mysql function createBusiness(name) local insert = mysql:query_free("INSERT INTO business SET name=".. mysql:escape_string(name) .."") if (insert) then outputChatBox("Congratulations, you have created your business", source, 255, 194, 14) else outputDebugString("Mysql Error: Unable to create business!") mysql:free_result(insert) end end addEvent("onBusinessCreate", true) addEventHandler("onBusinessCreate", getRootElement(), createBusiness)
  13. It works now, dunno what I did wrong though Thanks for help
  14. It just spams "you are too far away from the garage" function openGarageGate(thePlayer, garageID) local garageID = tonumber(garageID) local found = false for i, v in ipairs (getElementsByType("object")) do if (getElementModel(v) == 17950) then local gate = getElementData(v, "poarta") local dbid = tonumber(getElementData(v, "dbid")) if (dbid == garageID) then found = true break end local px,py,pz = getElementPosition(thePlayer) local ox,oy,oz = getElementPosition(v) if getDistanceBetweenPoints3D(ox,oy,oz,px,py,pz) <= distance then local gateX, gateY, gateZ, rotX, roxY, rotZ = getElementAttachedOffsets(gate) if (state == 0) then setElementAttachedOffsets(gate, gateX, gateY-1, gateZ+1.65, rotX, -90, rotZ) outputChatBox("You opened the garage!", thePlayer, 0, 255, 0) state = 1 elseif (state == 1) then setElementAttachedOffsets(gate, gateX, gateY+1, gateZ-1.65, rotX, 0, rotZ) outputChatBox("You closed the garage!", thePlayer, 0, 255, 0) state = 0 end end else outputChatBox("You are too far away from the garage!", thePlayer, 255, 0, 0) end end if found == false then outputChatBox("There's no garage with this ID!", thePlayer, 255, 0, 0) end end
  15. It workes but I get this: There's no garage with this ID! There's no garage with this ID! There's no garage with this ID! There's no garage with this ID! There's no garage with this ID! There's no garage with this ID! There's no garage with this ID! There's no garage with this ID! There's no garage with this ID! There's no garage with this ID! You closed the garage! And when I am far away from the garage, it keeps saying "there's no garage with this ID" like about 10 times and then it says that I am too far away... local state = 0 local distance = 50 function openGarageGate(thePlayer, garageID) local garageID = tonumber(garageID) local found = false for i, v in ipairs (getElementsByType("object")) do if (getElementModel(v) == 17950) then local gate = getElementData(v, "poarta") local dbid = tonumber(getElementData(v, "dbid")) if (dbid == garageID) then local px,py,pz = getElementPosition(thePlayer) local ox,oy,oz = getElementPosition(v) if getDistanceBetweenPoints3D(ox,oy,oz,px,py,pz) <= distance then if (state == 0) then local gateX, gateY, gateZ, rotX, roxY, rotZ = getElementAttachedOffsets(gate) setElementAttachedOffsets(gate, gateX, gateY-1, gateZ+1.65, rotX, -90, rotZ) outputChatBox("You opened the garage!", thePlayer, 0, 255, 0) state = 1 elseif (state == 1) then local gateX, gateY, gateZ, rotX, roxY, rotZ = getElementAttachedOffsets(gate) setElementAttachedOffsets(gate, gateX, gateY+1, gateZ-1.65, rotX, 0, rotZ) outputChatBox("You closed the garage!", thePlayer, 0, 255, 0) state = 0 end else outputChatBox("You are too far away from the garage!", thePlayer, 255, 0, 0) end else outputChatBox("There's no garage with this ID!", thePlayer, 255, 0, 0) end end end end
  16. Um.. I got another problem If I type in the command 3 times, it workes the first 2 times (it says I open the garage and then close it) but the other times it keeps saying I close the garage and this like is executed: setElementAttachedOffsets(gate, gateX, gateY+1, gateZ-1.65, rotX, 0, rotZ) Any ideas why?
  17. It says that I am too far away from the garage
  18. Hey, I tried to make something like a state, which means that if the state == 1 then move the gate to possition A, and if the state == 0 then move the gate to possition B. local state = 0 local distance = 50 function openGarageGate(thePlayer, cmd, garageID, state) if not garageID then outputChatBox("SYNTAXA: /"..cmd.." [iD Garage]", thePlayer, 255, 255, 0) else local garageID = tonumber(garageID) local found = false for i, v in ipairs (getElementsByType("object")) do if (getElementModel(v) == 17950) then local gate = getElementData(v, "poarta") local dbid = tonumber(getElementData(v, "dbid")) if (dbid == garageID) then local px,py,pz = getElementPosition(thePlayer) local ox,oy,oz = getElementPosition(v) if getDistanceBetweenPoints3D(ox,oy,oz,px,py,pz) <= distance then if (state == 0) then local gateX, gateY, gateZ, rotX, roxY, rotZ = getElementAttachedOffsets(gate) setElementAttachedOffsets(gate, gateX, gateY-1, gateZ+1.65, rotX, -90, rotZ) state = true outputChatBox("You opened the garage!", thePlayer, 0, 255, 0) found = true break elseif (state == 1) then local gateX, gateY, gateZ, rotX, roxY, rotZ = getElementAttachedOffsets(gate) setElementAttachedOffsets(gate, gateX, gateY+1, gateZ-1.65, rotX, 0, rotZ) outputChatBox("You closed the garage!", thePlayer, 0, 255, 0) end end else outputChatBox("You are too far away from the garage!", thePlayer, 255, 0, 0) end end end end if found == false then outputChatBox("There's no garage with this ID!", thePlayer, 255, 0, 0) end end end addCommandHandler("opengarage", openGarageGate) For some reason it says that there was no garage found with that ID...
  19. So, instead of moveObject I decided to go with setElementAttachedOffsets but the gate just disappears... if getDistanceBetweenPoints3D(ox,oy,oz,px,py,pz) <= distance then local gateX, gateY, gateZ = getElementPosition(gate) local rotX, roxY, rotZ = getElementRotation(gate) setElementAttachedOffsets(gate, gateX, gateY+2, gateZ+2, rotX, -90, rotZ) --moveObject(gate, 2000, gateX+4.9, gateY+9.6, gateZ, 0, 0, 0) -- moveObject(gate1, 17951, gateX, gateY, gateZ+3, -90, 0, 0) outputChatBox("You have opened your garage!", thePlayer, 0, 255, 0) found = true break else outputChatBox("You are too far away from the garage!", thePlayer, 255, 0, 0) end Any ideas?
  20. Yes, I am sure.. local gateX, gateY, gateZ = getElementPosition(gate) moveObject(gate, 17951, gateX, gateY, gateZ+3, -90, 0, 0) -------------EDIT--------------- When I made a separate gate, it moves and everything works. Also, the script is getting the possition of the gate. Is it maybe because the gate is attached to the garage using attachElement and I somehow need to update the possition from attachElement?
  21. Now it kinda works, but the gate doesn't move. There is also no error in debugscript
×
×
  • Create New...