Protagonist95
Members-
Posts
53 -
Joined
-
Last visited
Everything posted by Protagonist95
-
How to insert multiple values from select into table?
Protagonist95 replied to Protagonist95's topic in Scripting
Thakns m8 -
Can you give me a hint how do i insert values into table? Heres the code i wrote mytable = {} function insertGangTable() local connection = dbConnect( "sqlite", "data.db" ) local gang_list = dbQuery( connection, "SELECT id,name FROM gang_list" ) local gang_list_result = dbPoll(gang_list, -1) if gang_list_result then for _,row in ipairs( gang_list_result ) do for _,value in pairs( row ) do table.insert(mytable,...) --- { [id] = "name" } end end end end
-
How can i pass serverside table to client? --Serverside function selectMembersList ( playerSource ) local connection = dbConnect( "sqlite", "data.db" ) local qh = dbQuery( connection, "SELECT member_login FROM gang_members WHERE gang_id = ?",selectGangIDBySerial(getPlayerSerial(playerSource))) local result = dbPoll ( qh, -1 ) local group_members = {} for _, row in ipairs ( result ) do local player = getPlayerFromSerial(row["member_login"]) table.insert(group_members,getPlayerSerial(player)) end return group_members --table is ok at this point end addEvent( "selectMembersListEvent", true ) addEventHandler( "selectMembersListEvent", resourceRoot, selectMembersList ) --Clientside function addGroupMembers() group_members = triggerServerEvent("selectMembersListEvent",resourceRoot,getLocalPlayer()) for _,value in ipairs(group_members) do -- table expected,got boolean outputChatBox(value) end end addEventHandler( "onClientResourceStart",resourceRoot,addGroupMembers)
-
function hoursToDays(commandName, hour) local conv_hour = tonumber(hour) local day = math.floor(hour / 24) outputChatBox("Days: " .. tostring(day) .. " Hours: " .. tostring(conv_hour - (day * 24))) end addCommandHandler ( "tm", hoursToDays )
-
Try using modulo operator,then round the output to int type number
-
Hello.Does anybody know how to make doublesided marker (talking about checkpoint one,not cylinder) or just recommend the way to create a really large one(size > 300 units) that will not fade away after walking some distance?
-
Figured out after taking a cup of cofee ))
-
Markers are round,not straight line
-
Does anyone have an idea how to create really large wall,that would spread across the whole map(screenshot below) image
-
Ok il try
-
I was just thinking about it,and yes.I spawn objects on server side and try to delete them on client side.
-
Okay,the detach part is successful,but the destroy isn't.Still dont know why... Any ideas?
-
Okay,but in my situation i would like to remove both.Btw not working.
-
At 22 line:tmpColshape is nil value.
-
Not working.Error in getLocalPlayer lines -- attempt to call global
-
Why do you need to detach elements?
-
Is it possible to make this code simplyer? function onClientColHit(theElement, matchingDimension) local col = source if ( theElement == getLocalPlayer()) then -- if player hit colshape addEventHandler( "onClientKey", getRootElement(), function(button,press) if (button == "mouse3") then setElementData(getLocalPlayer(),"item",getElementData(getElementAttachedTo(col),"item")) -- set elementData of and object in colshape end end) end end addEventHandler("onClientColShapeHit",getRootElement(),onClientColHit)
-
didn't help
-
cache = false cache = false?
-
What may be the problem? function destroyObject( theElement, matchingDimension ) local object = getElementAttachedTo(source) -- object attached to colshape if (theElement == getLocalPlayer()) then -- if player hits colshape destroyElement(object) -- destroy object within colshape end end addEventHandler("onClientColShapeHit",getRootElement(),destroyObject)
-
Thank you for the love of god!!! I'm gona figure out how it works and what was the problem after I get some sleep And yes,I was planning to read about Event system,because I'm new in LUA scripting
-
I see your point,but thing is not in the numbers or strings.Lets assume that i would deal with large table which includes {1337,"something",true} or something like that.That wont solve the problem.
-
wtf?Debugscript is silent,idk what may cause the problem.
-
Not working
-
Not working.Heres whole script if it somehow helps you objects = { {1337,23.15625,-5.677734375,3}, {1338,19.15625,-5.677734375,3}, {1339,15.15625,-5.677734375,3} } Parameters = { {1337,"data","data"}, {1338,"data1","data1"}, {1339,"data2",100} } function spawnLoot() for i,k in ipairs(objects) do local obj local col local id = k[1] obj = createObject(k[1],k[2],k[3],k[4]) col = createColCuboid(k[2],k[3],k[4],1.6,1.6,1.6) if(obj) then -- if it exists then setElementData(col,"col",true) setElementData(obj,"loot",true) attachElements(col,obj,-0.7,-0.7,-0.5) setElementCollisionsEnabled(obj,false) end for index,key in ipairs(Parameters) do if id == key[1] then setElementData(obj,key[2],key[3]) outputChatBox("ID added") break end end end end addEventHandler ( "onResourceStart", getResourceRootElement(), spawnLoot) function onColEnter ( thePlayer ) local item = getElementsWithinColShape (source, "object") if isElementWithinColShape (thePlayer,source) and getElementData(source,"col") ~= false then setElementData(thePlayer,"inLoot",true) for i,k in ipairs(item) do for index,key in ipairs(Parameters) do if getElementData(k,key[3]) ~= false then outputChatBox(tostring(getElementData(k,key[3]))) end end end end end addEventHandler ("onColShapeHit",getResourceRootElement(), onColEnter) function onColLeave ( thePlayer ) if getElementsWithinColShape ( source, "player" ) then setElementData(thePlayer,"inLoot",false) end end addEventHandler ("onColShapeLeave", getRootElement(), onColLeave)