..:D&G:.. Posted October 28, 2014 Share Posted October 28, 2014 Hello guys, I am using mta paradise so I can learn more scripting, and I've come across something I never knew how to do. addEvent( "items:drop", true ) addEventHandler( "items:drop", root, function( slot ) if source == client then if exports.players:isLoggedIn( source ) then local item = get( source )[ slot ] if item then local id = item.item local value = item.value local name = item.name or getName( id ) local x,y,z = getElementPosition(source) local ang = getPedRotation(source) local dim = getElementDimension ( source ) local int = getElementInterior ( source ) local obj = 1271 if(id == 1) then obj = 1581 elseif(id == 3) then if(value == 10) then obj = 2663 elseif(value == 30) then obj = 2663 end elseif(id == 4) then if(value == 20) then obj = 2647 else end elseif(id == 9) then if(value == 12) then obj = 1578 elseif(value == 13) then obj = 1575 else end else obj = 1271 end local drop = createObject ( obj, x+math.sin(math.rad(-ang)), y+math.cos(math.rad(-ang)), z - 0.85, 90, 0, math.random (0, 360) ) if drop then setElementData ( drop, "id", id ) setElementData ( drop, "value", value ) setElementData ( drop, "name", name ) setElementInterior ( drop, int ) setElementDimension ( drop, dim ) take( source, slot ) local posx, posy, posz = getElementPosition ( drop ) exports.sql:query_insertid( "INSERT INTO dropitems (id, value, name, posx, posy, posz, int, dim) VALUES (" .. id .. ", " .. value .. ", " .. name .. ", " .. posx .. ", " .. posy .. ", " .. posz .. ", " .. int .. ", " .. dim .. ")") exports.chat:me( source, "drops a " .. name .. "." ) end outputChatBox( "This " ..name.. " has ID " .. slot .. ".", source, 0, 255, 0 ) end end end end ) This was supposed to save the items droped (the items do drop and there are no errors). I cannot say it looks good to me, because I don't know anything about saving into a mysql database. Even tho I drop the item, and it is droped, it doesn't save in the database, any ideas why? Link to comment
..:D&G:.. Posted October 29, 2014 Author Share Posted October 29, 2014 It's a bit weird how no one replys to my posts Link to comment
Saml1er Posted October 29, 2014 Share Posted October 29, 2014 Because this part doesn't explain well. You must also post the part where the script is loading saved object. Link to comment
..:D&G:.. Posted October 29, 2014 Author Share Posted October 29, 2014 If I had that part, I wouldn't post this -.- But for now, the objects are not inserted in the database Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now