Mahmoud123 Posted December 15, 2014 Share Posted December 15, 2014 السلام عليكم , شباب ابي اعرف كيف اسوي المود او الgui ما يشتغلو لما السكريبت يشتغل او لما حد يدخل السيرفر ابي الكود الله يخليكم ++ انا حملت مود الثلج , يشتغل لما السكريبت يشتغل او لما الشخص يدخل ممكن تساعدوني الله يخليكم ؟ انا موب مبرمج محترف ,, انا اقدر اسوي لوحه و الأشياء البسيطه هاد فقط شكرا Link to comment
nxFairlywell Posted December 15, 2014 Share Posted December 15, 2014 وضح وش تبي تسوي بالضبط ؟ Link to comment
Mahmoud123 Posted December 15, 2014 Author Share Posted December 15, 2014 اقصد , يعني انا جبت سكريبت الثلج [ snow ] من الcommunity هو يشتغل لما حد يدخل السيرفر و لما السكريبت يشتغل [ تسوي /snow عشان الثلج يقف / يشتغل ] انا ابي اسويه لما السكريبت يشتغل الثلج ما يشتغل لازم اللاعب يسوي /snow عشان يشتغل , ما فيه كود او شئ ؟ Link to comment
nxFairlywell Posted December 15, 2014 Share Posted December 15, 2014 addCommandHandler("snow", اسم الوظيفة الي تشغل الثلج) Link to comment
Ahmed Abo-elezz Posted December 15, 2014 Share Posted December 15, 2014 addCommandHandler("snow", اسم الوظيفة الي تشغل الثلج) اضافه "snow" اللى راح تكتبها فى f8 Link to comment
# L 7 N Posted December 15, 2014 Share Posted December 15, 2014 آطرح الكود هنآ وبسآعدك فيه ~ Link to comment
</Mr.Tn6eL> Posted December 15, 2014 Share Posted December 15, 2014 نسوي لك تعويذة عشان نصلحه بدون ماتعطينا اكوادك Link to comment
Ahmed Abo-elezz Posted December 16, 2014 Share Posted December 16, 2014 نسوي لك تعويذة عشان نصلحه بدون ماتعطينا اكوادك هو يريد الكومند فقط Link to comment
Mahmoud123 Posted December 16, 2014 Author Share Posted December 16, 2014 لا لا ,, السكريبت شغال و كل شئ تمام ,, ابي اخلي السكريبت ما يشتغل لما افتتح الريسورس , يعني لازم اكتب /snow عشان يشتغل : الكود # : local snowflakes = {} local snowing = false local box_width, box_depth, box_height, box_width_doubled, box_depth_doubled = 4,4,4,8,8 local position = {0,0,0} local flake_removal = nil local snow_fadein = 10 local snow_id = 1 sx,sy = guiGetScreenSize() sx2,sy2 = sx/2,sy/2 localPlayer = getLocalPlayer() settings = {type = "real", density = 700, wind_direction = {0.01,0.01}, wind_speed = 1, snowflake_min_size = 1, snowflake_max_size = 4, fall_speed_min = 1, fall_speed_max = 4, jitter = true} guiEnabled = false snowToggle = false --local random = math.random function random(lower,upper) return lower+(math.random()*(upper-lower)) end function startSnow() if not snowing then snowflakes = {} local lx,ly,lz = getWorldFromScreenPosition(0,0,1) local rx,ry,rz = getWorldFromScreenPosition(sx,0,1) box_width = getDistanceBetweenPoints3D(lx,ly,lz,rx,ry,rz)+3 -- +1.5 each side of the screen box_depth = box_width box_width_doubled = box_width*2 box_depth_doubled = box_depth*2 lx,ly,lz = getWorldFromScreenPosition(sx2,sy2,box_depth) position = {lx,ly,lz} -- let it snow for i=1, settings.density do local x,y,z = random(0,box_width*2),random(0,box_depth*2),random(0,box_height*2) createFlake(x-box_width,y-box_depth,z-box_height,0) end addEventHandler("onClientRender",root,drawSnow) snowing = true return true else return false end return false end function stopSnow() if snowing then removeEventHandler("onClientRender",root,drawSnow) for i,flake in pairs(snowflakes) do snowflakes[i] = nil end snowflakes = nil flake_removal = nil snowing = false -- outputChatBox("Snow stopped") return true end return false end addEventHandler("onClientResourceStop",resourceRoot,stopSnow) function createFlake(x,y,z,alpha,i) if flake_removal then if (flake_removal[2] % flake_removal[3]) == 0 then flake_removal[1] = flake_removal[1] - 1 if flake_removal[1] == 0 then flake_removal = nil end table.remove(snowflakes,i) return else flake_removal[2] = flake_removal[2] + 1 end end snow_id = (snow_id % 4) + 1 if i then local randy = math.random(0,180) snowflakes[i] = {x = x, y = y, z = z, speed = math.random(settings.fall_speed_min,settings.fall_speed_max)/100, size = 2^math.random(settings.snowflake_min_size,settings.snowflake_max_size), section = {(snow_id % 2 == 1) and 0 or 32, (snow_id < 3) and 0 or 32}, rot = randy, alpha = alpha, jitter_direction = {math.cos(math.rad(randy*2)), -math.sin(math.rad(math.random(0,360)))}, jitter_cycle = randy*2, jitter_speed = 8 } else local randy = math.random(0,180) table.insert(snowflakes,{x = x, y = y, z = z, speed = math.random(settings.fall_speed_min,settings.fall_speed_max)/100, size = 2^math.random(settings.snowflake_min_size,settings.snowflake_max_size), section = {(snow_id % 2 == 1) and 0 or 32, (snow_id < 3) and 0 or 32}, rot = randy, alpha = alpha, jitter_direction = {math.cos(math.rad(randy*2)), -math.sin(math.rad(math.random(0,360)))}, jitter_cycle = randy*2, jitter_speed = 8 } ) end end function drawSnow() local tick = getTickCount() local cx,cy,cz = getCameraMatrix() local lx,ly,lz = getWorldFromScreenPosition(sx2,sy2,box_depth) --local hit,hx,hy,hz = processLineOfSight(lx,ly,lz,lx,ly,lz+20,true,true,false,true,false,true,false,false,localPlayer) if (isLineOfSightClear(cx,cy,cz,cx,cy,cz+20,true,false,false,true,false,true,false,localPlayer) or isLineOfSightClear(lx,ly,lz,lx,ly,lz+20,true,false,false,true,false,true,false,localPlayer)) then -- if we are underwater, substitute the water level for the ground level local check = getGroundPosition if testLineAgainstWater(cx,cy,cz,cx,cy,cz+20) then check = getWaterLevel end -- local gz = getGroundPosition(lx,ly,lz) -- split the box into a 3x3 grid, each section of the grid takes its own ground level reading to apply for every flake within it local gpx,gpy,gpz = lx+(-box_width),ly+(-box_depth),lz+15 local ground = {} for i=1, 3 do local it = box_width_doubled*(i*0.25) ground[i] = { check(gpx+(it), gpy+(box_depth_doubled*0.25), gpz), check(gpx+(it), gpy+(box_depth_doubled*0.5), gpz), check(gpx+(it), gpy+(box_depth_doubled*0.75), gpz) } end -- outputDebugString(string.format("Gn: %.1f %.1f %.1f",ground[i][1],ground[i][2],ground[i][3])) -- outputDebugString(string.format("Gy: %.1f %.1f %.1f",groundy[i][1],groundy[i][2],groundy[i][3])) -- outputDebugString(string.format("%.1f %.1f %.1f, %.1f %.1f %.1f, %.1f %.1f %.1f",ground[1][1],ground[1][2],ground[1][3],ground[2][1],ground[2][2],ground[2][3],ground[3][1],ground[3][2],ground[3][3])) -- outputDebugString(string.format("%.1f %.1f %.1f, %.1f %.1f %.1f",(-box_width)+grid[1],(-box_width)+grid[1]*3,(-box_width)+grid[1]*5,(-box_depth)+grid[2],(-box_depth)+grid[2]*3,(-box_depth)+grid[2]*5)) local dx,dy,dz = position[1]-lx,position[2]-ly,position[3]-lz --local alpha = (math.abs(dx) + math.abs(dy) + math.abs(dz))*15 -- outputDebugString(tostring(alpha)) for i,flake in pairs(snowflakes) do if flake then -- check the flake hasnt moved beyond the box or below the ground -- actually, to preserve a constant density allow the flakes to fall past ground level (just dont show them) and remove once at the bottom of the box -- if (flake.z+lz) < ground[gx][gy] or flake.z < (-box_height) then if flake.z < (-box_height) then -- outputDebugString(string.format("Flake removed. %.1f %.1f %.1f",flake.x,flake.y,flake.z)) -- createFlake(x, y, z, alpha, index) createFlake(random(0,box_width*2) - box_width, random(0,box_depth*2) - box_depth, box_height, 0, i) else -- find the grid section the flake is in local gx,gy = 2,2 if flake.x <= (box_width_doubled*0.33)-box_width then gx = 1 elseif flake.x >= (box_width_doubled*0.66)-box_width then gx = 3 end if flake.y <= (box_depth_doubled*0.33)-box_depth then gy = 1 elseif flake.y >= (box_depth_doubled*0.66)-box_depth then gy = 3 end -- check it hasnt moved past the ground if ground[gx][gy] and (flake.z+lz) > ground[gx][gy] then local draw_x, draw_y, jitter_x, jitter_y = nil,nil,0,0 -- draw all onscreen flakes if settings.jitter then local jitter_cycle = math.cos(flake.jitter_cycle) / flake.jitter_speed jitter_x = (flake.jitter_direction[1] * jitter_cycle ) jitter_y = (flake.jitter_direction[2] * jitter_cycle ) end draw_x,draw_y = getScreenFromWorldPosition(flake.x + lx + jitter_x, flake.y + ly + jitter_y ,flake.z + lz, 15, false) if draw_x and draw_y then -- outputDebugString(string.format("Drawing flake %.1f %.1f",draw_x,draw_y)) -- only draw flakes that are infront of the player -- peds seem to have very vague collisions, resulting in a dome-like space around the player where no snow is drawn, so leave this out due to it looking rediculous -- if isLineOfSightClear(cx,cy,cz,flake.x+lx,flake.y+ly,flake.z+lz,true,true,true,true,false,false,false,true) then --dxDrawImage(draw_x,draw_y,flake.size,flake.size,"flakes/snowflake"..tostring(flake.image).."_".. settings.type ..".png",flake.rot,0,0,tocolor(222,235,255,flake.alpha)) dxDrawImageSection(draw_x, draw_y, flake.size, flake.size, flake.section[1], flake.section[2], 32, 32, "flakes/".. settings.type .. "_tile.png", flake.rot, 0, 0, tocolor(222,235,255,flake.alpha)) -- end -- rotation and alpha (do not need to be done if the flake isnt being drawn) flake.rot = flake.rot + settings.wind_speed if flake.alpha < 255 then flake.alpha = flake.alpha + snow_fadein --[[+ alpha]] if flake.alpha > 255 then flake.alpha = 255 end end else -- outputDebugString(string.format("Cannot find screen pos. %.1f %.1f %.1f",flake.x+lx,flake.y+ly,flake.z+lz)) end end if settings.jitter then flake.jitter_cycle = (flake.jitter_cycle % 360) + 0.1 end -- horizontal movement flake.x = flake.x + (settings.wind_direction[1] * settings.wind_speed) flake.y = flake.y + (settings.wind_direction[2] * settings.wind_speed) -- vertical movement flake.z = flake.z - flake.speed -- update flake position based on movement of the camera flake.x = flake.x + dx flake.y = flake.y + dy flake.z = flake.z + dz -- outputDebugString(string.format("Diff: %.1f, %.1f, %.1f",position[1]-lx,position[2]-ly,position[3]-lz)) if flake.x < -box_width or flake.x > box_width or flake.y < -box_depth or flake.y > box_depth or flake.z > box_height then -- outputDebugString(string.format("Flake removed (move). %.1f %.1f %.1f",flake.x,flake.y,flake.z)) -- mirror flakes that were removed due to camera movement onto the opposite side of the box (and hope nobody notices) flake.x = flake.x - dx flake.y = flake.y - dy Link to comment
Rm-Dj Posted December 16, 2014 Share Posted December 16, 2014 تقصد زي الي بسيرفر وناسة تايم ؟ يمديك تطفي وتشغل من اف 1 Link to comment
Mahmoud123 Posted December 16, 2014 Author Share Posted December 16, 2014 مدري عن وناسه تايم,, شوف اخي , انا ابي المود لما حد يدخل السيرفر ما ينزل ثلج لو حد يبي ينزل ثلج يكتب الcommand الي موجود ,, بالتالي موجوود! بس السيكريبت يسوي اول ما حد يدخل السيرفر , الثلج يشتغل انا ابيييييه ما يشتغل لازم لما يكتب الكوماند Link to comment
nxFairlywell Posted December 16, 2014 Share Posted December 16, 2014 جرب كذا local snowflakes = {} local snowing = false local box_width, box_depth, box_height, box_width_doubled, box_depth_doubled = 4,4,4,8,8 local position = {0,0,0} local flake_removal = nil local snow_fadein = 10 local snow_id = 1 sx,sy = guiGetScreenSize() sx2,sy2 = sx/2,sy/2 localPlayer = getLocalPlayer() settings = {type = "real", density = 700, wind_direction = {0.01,0.01}, wind_speed = 1, snowflake_min_size = 1, snowflake_max_size = 4, fall_speed_min = 1, fall_speed_max = 4, jitter = true} guiEnabled = false snowToggle = false --local random = math.random function random(lower,upper) return lower+(math.random()*(upper-lower)) end function startSnow() if not snowing == true then snowing=true snowflakes = {} local lx,ly,lz = getWorldFromScreenPosition(0,0,1) local rx,ry,rz = getWorldFromScreenPosition(sx,0,1) box_width = getDistanceBetweenPoints3D(lx,ly,lz,rx,ry,rz)+3 -- +1.5 each side of the screen box_depth = box_width box_width_doubled = box_width*2 box_depth_doubled = box_depth*2 lx,ly,lz = getWorldFromScreenPosition(sx2,sy2,box_depth) position = {lx,ly,lz} -- let it snow for i=1, settings.density do local x,y,z = random(0,box_width*2),random(0,box_depth*2),random(0,box_height*2) createFlake(x-box_width,y-box_depth,z-box_height,0) end addEventHandler("onClientRender",root,drawSnow) snowing = true return true else return false end return false end function stopSnow() if snowing==true then snowing=false removeEventHandler("onClientRender",root,drawSnow) for i,flake in pairs(snowflakes) do snowflakes[i] = nil end snowflakes = nil flake_removal = nil snowing = false -- outputChatBox("Snow stopped") return true end return false end addEventHandler("onClientResourceStop",resourceRoot,stopSnow) function createFlake(x,y,z,alpha,i) if flake_removal then if (flake_removal[2] % flake_removal[3]) == 0 then flake_removal[1] = flake_removal[1] - 1 if flake_removal[1] == 0 then flake_removal = nil end table.remove(snowflakes,i) return else flake_removal[2] = flake_removal[2] + 1 end end snow_id = (snow_id % 4) + 1 if i then local randy = math.random(0,180) snowflakes[i] = {x = x, y = y, z = z, speed = math.random(settings.fall_speed_min,settings.fall_speed_max)/100, size = 2^math.random(settings.snowflake_min_size,settings.snowflake_max_size), section = {(snow_id % 2 == 1) and 0 or 32, (snow_id < 3) and 0 or 32}, rot = randy, alpha = alpha, jitter_direction = {math.cos(math.rad(randy*2)), -math.sin(math.rad(math.random(0,360)))}, jitter_cycle = randy*2, jitter_speed = 8 } else local randy = math.random(0,180) table.insert(snowflakes,{x = x, y = y, z = z, speed = math.random(settings.fall_speed_min,settings.fall_speed_max)/100, size = 2^math.random(settings.snowflake_min_size,settings.snowflake_max_size), section = {(snow_id % 2 == 1) and 0 or 32, (snow_id < 3) and 0 or 32}, rot = randy, alpha = alpha, jitter_direction = {math.cos(math.rad(randy*2)), -math.sin(math.rad(math.random(0,360)))}, jitter_cycle = randy*2, jitter_speed = 8 } ) end end function drawSnow() local tick = getTickCount() local cx,cy,cz = getCameraMatrix() local lx,ly,lz = getWorldFromScreenPosition(sx2,sy2,box_depth) --local hit,hx,hy,hz = processLineOfSight(lx,ly,lz,lx,ly,lz+20,true,true,false,true,false,true,false,false,localPlayer) if (isLineOfSightClear(cx,cy,cz,cx,cy,cz+20,true,false,false,true,false,true,false,localPlayer) or isLineOfSightClear(lx,ly,lz,lx,ly,lz+20,true,false,false,true,false,true,false,localPlayer)) then -- if we are underwater, substitute the water level for the ground level local check = getGroundPosition if testLineAgainstWater(cx,cy,cz,cx,cy,cz+20) then check = getWaterLevel end -- local gz = getGroundPosition(lx,ly,lz) -- split the box into a 3x3 grid, each section of the grid takes its own ground level reading to apply for every flake within it local gpx,gpy,gpz = lx+(-box_width),ly+(-box_depth),lz+15 local ground = {} for i=1, 3 do local it = box_width_doubled*(i*0.25) ground[i] = { check(gpx+(it), gpy+(box_depth_doubled*0.25), gpz), check(gpx+(it), gpy+(box_depth_doubled*0.5), gpz), check(gpx+(it), gpy+(box_depth_doubled*0.75), gpz) } end -- outputDebugString(string.format("Gn: %.1f %.1f %.1f",ground[i][1],ground[i][2],ground[i][3])) -- outputDebugString(string.format("Gy: %.1f %.1f %.1f",groundy[i][1],groundy[i][2],groundy[i][3])) -- outputDebugString(string.format("%.1f %.1f %.1f, %.1f %.1f %.1f, %.1f %.1f %.1f",ground[1][1],ground[1][2],ground[1][3],ground[2][1],ground[2][2],ground[2][3],ground[3][1],ground[3][2],ground[3][3])) -- outputDebugString(string.format("%.1f %.1f %.1f, %.1f %.1f %.1f",(-box_width)+grid[1],(-box_width)+grid[1]*3,(-box_width)+grid[1]*5,(-box_depth)+grid[2],(-box_depth)+grid[2]*3,(-box_depth)+grid[2]*5)) local dx,dy,dz = position[1]-lx,position[2]-ly,position[3]-lz --local alpha = (math.abs(dx) + math.abs(dy) + math.abs(dz))*15 -- outputDebugString(tostring(alpha)) for i,flake in pairs(snowflakes) do if flake then -- check the flake hasnt moved beyond the box or below the ground -- actually, to preserve a constant density allow the flakes to fall past ground level (just dont show them) and remove once at the bottom of the box -- if (flake.z+lz) < ground[gx][gy] or flake.z < (-box_height) then if flake.z < (-box_height) then -- outputDebugString(string.format("Flake removed. %.1f %.1f %.1f",flake.x,flake.y,flake.z)) -- createFlake(x, y, z, alpha, index) createFlake(random(0,box_width*2) - box_width, random(0,box_depth*2) - box_depth, box_height, 0, i) else -- find the grid section the flake is in local gx,gy = 2,2 if flake.x <= (box_width_doubled*0.33)-box_width then gx = 1 elseif flake.x >= (box_width_doubled*0.66)-box_width then gx = 3 end if flake.y <= (box_depth_doubled*0.33)-box_depth then gy = 1 elseif flake.y >= (box_depth_doubled*0.66)-box_depth then gy = 3 end -- check it hasnt moved past the ground if ground[gx][gy] and (flake.z+lz) > ground[gx][gy] then local draw_x, draw_y, jitter_x, jitter_y = nil,nil,0,0 -- draw all onscreen flakes if settings.jitter then local jitter_cycle = math.cos(flake.jitter_cycle) / flake.jitter_speed jitter_x = (flake.jitter_direction[1] * jitter_cycle ) jitter_y = (flake.jitter_direction[2] * jitter_cycle ) end draw_x,draw_y = getScreenFromWorldPosition(flake.x + lx + jitter_x, flake.y + ly + jitter_y ,flake.z + lz, 15, false) if draw_x and draw_y then -- outputDebugString(string.format("Drawing flake %.1f %.1f",draw_x,draw_y)) -- only draw flakes that are infront of the player -- peds seem to have very vague collisions, resulting in a dome-like space around the player where no snow is drawn, so leave this out due to it looking rediculous -- if isLineOfSightClear(cx,cy,cz,flake.x+lx,flake.y+ly,flake.z+lz,true,true,true,true,false,false,false,true) then --dxDrawImage(draw_x,draw_y,flake.size,flake.size,"flakes/snowflake"..tostring(flake.image).."_".. settings.type ..".png",flake.rot,0,0,tocolor(222,235,255,flake.alpha)) dxDrawImageSection(draw_x, draw_y, flake.size, flake.size, flake.section[1], flake.section[2], 32, 32, "flakes/".. settings.type .. "_tile.png", flake.rot, 0, 0, tocolor(222,235,255,flake.alpha)) -- end -- rotation and alpha (do not need to be done if the flake isnt being drawn) flake.rot = flake.rot + settings.wind_speed if flake.alpha < 255 then flake.alpha = flake.alpha + snow_fadein --[[+ alpha]] if flake.alpha > 255 then flake.alpha = 255 end end else -- outputDebugString(string.format("Cannot find screen pos. %.1f %.1f %.1f",flake.x+lx,flake.y+ly,flake.z+lz)) end end if settings.jitter then flake.jitter_cycle = (flake.jitter_cycle % 360) + 0.1 end -- horizontal movement flake.x = flake.x + (settings.wind_direction[1] * settings.wind_speed) flake.y = flake.y + (settings.wind_direction[2] * settings.wind_speed) -- vertical movement flake.z = flake.z - flake.speed -- update flake position based on movement of the camera flake.x = flake.x + dx flake.y = flake.y + dy flake.z = flake.z + dz -- outputDebugString(string.format("Diff: %.1f, %.1f, %.1f",position[1]-lx,position[2]-ly,position[3]-lz)) if flake.x < -box_width or flake.x > box_width or flake.y < -box_depth or flake.y > box_depth or flake.z > box_height then -- outputDebugString(string.format("Flake removed (move). %.1f %.1f %.1f",flake.x,flake.y,flake.z)) -- mirror flakes that were removed due to camera movement onto the opposite side of the box (and hope nobody notices) flake.x = flake.x - dx flake.y = flake.y - dy Link to comment
Mahmoud123 Posted December 16, 2014 Author Share Posted December 16, 2014 مشكور Ge[N]eraL. الله يخليك Link to comment
nxFairlywell Posted December 16, 2014 Share Posted December 16, 2014 مشكور Ge[N]eraL. الله يخليك العفو ، حياك الله Link to comment
Mahmoud123 Posted December 16, 2014 Author Share Posted December 16, 2014 ,, اسف اخر سؤال ,, ضض اسألتي كثيره | اسف وش سويت عشان تسويه كذا ؟ عشان ابي اتعلم ,, لو عندك وقت فهمني , الله يعطيك اجر الي تسويه Link to comment
</Mr.Tn6eL> Posted December 16, 2014 Share Posted December 16, 2014 هو بس عدل الكلمة الي كانت قبل Toggle snow وخلاها snow Ge[N]eraL,10 احذف سطر 276 Link to comment
nxFairlywell Posted December 16, 2014 Share Posted December 16, 2014 حذفت سطر وبدلت لك المتغيرات if ( snowing ) then خليتها if ( snowing == true ) then وكذا if ( snowing == false ) then Link to comment
Mahmoud123 Posted December 17, 2014 Author Share Posted December 17, 2014 شكرا شباب , /lock 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