iiv03 Posted May 30, 2019 Share Posted May 30, 2019 (edited) ايش خطأ هنا ؟ ليش مايشتغل تريقر ؟ Client Side bindKey("F4", "down", function() if not getElementData(localPlayer,"login") then return end if isDM() then carfade = (not carfade) if(carfade)then triggerClientEvent(source,'servermessages',source, 'TEST',warning) else triggerClientEvent(source,'servermessages',source, 'TEST',rec) end end end) انا متصله ب سرفر Server Side mensages = {} messagetick = 0 function servermessages(message, type) table.insert(mensages, {message, type or "confirm", getTickCount(), dxGetTextWidth(message, fontScale*0.06, Font_1) + screenH*0.01, 0, 0, 0}) messagetick = getTickCount() end addEvent("servermessages", true) addEventHandler("servermessages", getRootElement(), servermessages) function renderMensages() local msgd = mensages if #msgd ~= 0 then local startY = screenW*0.5 local i = 1 repeat mData = msgd[i] local drawThis = true if i~= 1 then startY = startY + screenW*0.0425 end if mData[5] == 0 and mData[6] == 0 then mData[5] = - mData[4] - screenH*0.015 mData[6] = startY mData[7] = startY end local tick = getTickCount() - mData[3] local posX, posY, alpha if tick < 1000 then local progress = math.min(tick/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, 0, 0, 0, progress, "Linear") elseif tick >= 1000 and tick <= 7000 then mData[5] = 0 elseif tick > 7000 then local progress = math.min((tick - 7000)/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, - mData[4] - mData[4] - screenH*0.015, 0, 0, progress, "Linear") if progress >= 1 then table.remove(msgd, i) drawThis = false messagetick = getTickCount() end end local globalTick = getTickCount() - messagetick if drawThis then mData[7] = startY mData[6] = interpolateBetween(mData[6], 0, 0, mData[7], 0, 0, math.min(globalTick/1000,1), "Linear") posX = mData[5] posY = mData[6] alpha = 255 dxDrawRectangle(posX, posY, mData[4], screenW*0.04, tocolor(0, 0, 0, alpha*0.75), true) local r, g, b = 0, 255, 0 if mData[2] == "warning" then r, g, b = 255, 0, 0 end dxDrawRectangle(posX + mData[4], posY, screenH*0.010, screenW*0.04, tocolor(r, g, b, alpha*0.85), true) dxDrawText(mData[1], posX, posY, posX + mData[4], posY + screenW*0.04, tocolor(255, 255, 255, alpha), fontScale*0.05, Font_1, "center", "center", false, false, true, false, false) end i = i + 1 until i > #msgd mensages = msgd end end addEventHandler("onClientRender", getRootElement(), renderMensages) وش سالفه شباب؟ Edited May 30, 2019 by liwahadri Link to comment
!#NssoR_) Posted May 30, 2019 Share Posted May 30, 2019 1 hour ago, liwahadri said: ايش خطأ هنا ؟ ليش مايشتغل تريقر ؟ Client Side bindKey("F4", "down", function() if not getElementData(localPlayer,"login") then return end if isDM() then carfade = (not carfade) if(carfade)then triggerClientEvent(source,'servermessages',source, 'TEST',warning) else triggerClientEvent(source,'servermessages',source, 'TEST',rec) end end end) انا متصله ب سرفر Server Side mensages = {} messagetick = 0 function servermessages(message, type) table.insert(mensages, {message, type or "confirm", getTickCount(), dxGetTextWidth(message, fontScale*0.06, Font_1) + screenH*0.01, 0, 0, 0}) messagetick = getTickCount() end addEvent("servermessages", true) addEventHandler("servermessages", getRootElement(), servermessages) function renderMensages() local msgd = mensages if #msgd ~= 0 then local startY = screenW*0.5 local i = 1 repeat mData = msgd[i] local drawThis = true if i~= 1 then startY = startY + screenW*0.0425 end if mData[5] == 0 and mData[6] == 0 then mData[5] = - mData[4] - screenH*0.015 mData[6] = startY mData[7] = startY end local tick = getTickCount() - mData[3] local posX, posY, alpha if tick < 1000 then local progress = math.min(tick/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, 0, 0, 0, progress, "Linear") elseif tick >= 1000 and tick <= 7000 then mData[5] = 0 elseif tick > 7000 then local progress = math.min((tick - 7000)/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, - mData[4] - mData[4] - screenH*0.015, 0, 0, progress, "Linear") if progress >= 1 then table.remove(msgd, i) drawThis = false messagetick = getTickCount() end end local globalTick = getTickCount() - messagetick if drawThis then mData[7] = startY mData[6] = interpolateBetween(mData[6], 0, 0, mData[7], 0, 0, math.min(globalTick/1000,1), "Linear") posX = mData[5] posY = mData[6] alpha = 255 dxDrawRectangle(posX, posY, mData[4], screenW*0.04, tocolor(0, 0, 0, alpha*0.75), true) local r, g, b = 0, 255, 0 if mData[2] == "warning" then r, g, b = 255, 0, 0 end dxDrawRectangle(posX + mData[4], posY, screenH*0.010, screenW*0.04, tocolor(r, g, b, alpha*0.85), true) dxDrawText(mData[1], posX, posY, posX + mData[4], posY + screenW*0.04, tocolor(255, 255, 255, alpha), fontScale*0.05, Font_1, "center", "center", false, false, true, false, false) end i = i + 1 until i > #msgd mensages = msgd end end addEventHandler("onClientRender", getRootElement(), renderMensages) وش سالفه شباب؟ الاكواد الاولي الي انت حاطها هاذي المفروض بجهة السيرفر , وانت كاتب انها كلنت ! وثانيا الاكواد الي انت كاتب انها بجهة السيرفر , المفروض تكون بجهة الكلنت وعندك اكثر من خطاء بجهة السيرفر localplayer = ? source = ? اذا استخدمته بجهة السيرفر لازم تعرف اللاعب بالكود نفسه , راجع الويكي وراح تفهم قصدي bindKey و الكود هذا Link to comment
JustP Posted May 30, 2019 Share Posted May 30, 2019 5 hours ago, liwahadri said: ايش خطأ هنا ؟ ليش مايشتغل تريقر ؟ Client Side bindKey("F4", "down", function() if not getElementData(localPlayer,"login") then return end if isDM() then carfade = (not carfade) if(carfade)then triggerClientEvent(source,'servermessages',source, 'TEST',warning) else triggerClientEvent(source,'servermessages',source, 'TEST',rec) end end end) انا متصله ب سرفر Server Side mensages = {} messagetick = 0 function servermessages(message, type) table.insert(mensages, {message, type or "confirm", getTickCount(), dxGetTextWidth(message, fontScale*0.06, Font_1) + screenH*0.01, 0, 0, 0}) messagetick = getTickCount() end addEvent("servermessages", true) addEventHandler("servermessages", getRootElement(), servermessages) function renderMensages() local msgd = mensages if #msgd ~= 0 then local startY = screenW*0.5 local i = 1 repeat mData = msgd[i] local drawThis = true if i~= 1 then startY = startY + screenW*0.0425 end if mData[5] == 0 and mData[6] == 0 then mData[5] = - mData[4] - screenH*0.015 mData[6] = startY mData[7] = startY end local tick = getTickCount() - mData[3] local posX, posY, alpha if tick < 1000 then local progress = math.min(tick/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, 0, 0, 0, progress, "Linear") elseif tick >= 1000 and tick <= 7000 then mData[5] = 0 elseif tick > 7000 then local progress = math.min((tick - 7000)/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, - mData[4] - mData[4] - screenH*0.015, 0, 0, progress, "Linear") if progress >= 1 then table.remove(msgd, i) drawThis = false messagetick = getTickCount() end end local globalTick = getTickCount() - messagetick if drawThis then mData[7] = startY mData[6] = interpolateBetween(mData[6], 0, 0, mData[7], 0, 0, math.min(globalTick/1000,1), "Linear") posX = mData[5] posY = mData[6] alpha = 255 dxDrawRectangle(posX, posY, mData[4], screenW*0.04, tocolor(0, 0, 0, alpha*0.75), true) local r, g, b = 0, 255, 0 if mData[2] == "warning" then r, g, b = 255, 0, 0 end dxDrawRectangle(posX + mData[4], posY, screenH*0.010, screenW*0.04, tocolor(r, g, b, alpha*0.85), true) dxDrawText(mData[1], posX, posY, posX + mData[4], posY + screenW*0.04, tocolor(255, 255, 255, alpha), fontScale*0.05, Font_1, "center", "center", false, false, true, false, false) end i = i + 1 until i > #msgd mensages = msgd end end addEventHandler("onClientRender", getRootElement(), renderMensages) وش سالفه شباب؟ ليش ثلاثة اند ؟ ماعتقد البايند يحتاج اند Link to comment
nxFairlywell Posted May 30, 2019 Share Posted May 30, 2019 39 minutes ago, JustP said: ليش ثلاثة اند ؟ ماعتقد البايند يحتاج اند bindKey ركز ع السطر الثاني توجد دالة داخل الـ Link to comment
iiv03 Posted May 30, 2019 Author Share Posted May 30, 2019 (edited) 8 hours ago, !#NssoR_) said: الاكواد الاولي الي انت حاطها هاذي المفروض بجهة السيرفر , وانت كاتب انها كلنت ! وثانيا الاكواد الي انت كاتب انها بجهة السيرفر , المفروض تكون بجهة الكلنت وعندك اكثر من خطاء بجهة السيرفر localplayer = ? source = ? اذا استخدمته بجهة السيرفر لازم تعرف اللاعب بالكود نفسه , راجع الويكي وراح تفهم قصدي bindKey و الكود هذا سويت آلي قلت لي ياه غير اكواد وسميت فانكشن وحطيت bindKey اسم الفأنكشن مآشتغل وآلكود مب آتوقع مفيه اغلاط عشان مارسلت الكودً كأمل آلي سويته كذا Server Side function bounce() antiBounce = false if not getElementData(localPlayer,"login") then return end antiBounce = not antiBounce if antiBounce then triggerClientEvent(source,'servermessages',source, 'TEST',warning) else triggerClientEvent(source,'servermessages',source, 'TEST',warning) end end bindKey("c","down", bounce) addEventHandler("onClientVehicleCollision",root, function(hitElement) if(not antiBounce) then return end if(hitElement ~= nil) then if(getElementType(hitElement) ~= "object") then return end end if(getElementType(source) ~= "vehicle") then return end if getVehicleOccupant(source) ~= localPlayer then return end local tx, ty, tz = getVehicleTurnVelocity(source) if ((math.abs(ty) > 0.1 and math.abs(tz) > 0.001) or (math.abs(ty) > 0.001 and math.abs(tz) > 0.1)) then local vx,vy,vz = getElementVelocity(source) setVehicleTurnVelocity(source, 0, 0, 0) setElementVelocity(source, vx*1.01, vy*1.01, vz) end end ) Client Side function renderMensages() local msgd = mensages if #msgd ~= 0 then local startY = screenW*0.5 local i = 1 repeat mData = msgd[i] local drawThis = true if i~= 1 then startY = startY + screenW*0.0425 end if mData[5] == 0 and mData[6] == 0 then mData[5] = - mData[4] - screenH*0.015 mData[6] = startY mData[7] = startY end local tick = getTickCount() - mData[3] local posX, posY, alpha if tick < 1000 then local progress = math.min(tick/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, 0, 0, 0, progress, "Linear") elseif tick >= 1000 and tick <= 7000 then mData[5] = 0 elseif tick > 7000 then local progress = math.min((tick - 7000)/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, - mData[4] - mData[4] - screenH*0.015, 0, 0, progress, "Linear") if progress >= 1 then table.remove(msgd, i) drawThis = false messagetick = getTickCount() end end local globalTick = getTickCount() - messagetick if drawThis then mData[7] = startY mData[6] = interpolateBetween(mData[6], 0, 0, mData[7], 0, 0, math.min(globalTick/1000,1), "Linear") posX = mData[5] posY = mData[6] alpha = 255 dxDrawRectangle(posX, posY, mData[4], screenW*0.04, tocolor(0, 0, 0, alpha*0.75), true) local r, g, b = 0, 255, 0 if mData[2] == "warning" then r, g, b = 255, 0, 0 end dxDrawRectangle(posX + mData[4], posY, screenH*0.010, screenW*0.04, tocolor(r, g, b, alpha*0.85), true) dxDrawText(mData[1], posX, posY, posX + mData[4], posY + screenW*0.04, tocolor(255, 255, 255, alpha), fontScale*0.05, Font_1, "center", "center", false, false, true, false, false) end i = i + 1 until i > #msgd mensages = msgd end end addEventHandler("onClientRender", getRootElement(), renderMensages) 4 hours ago, JustP said: ليش ثلاثة اند ؟ ماعتقد البايند يحتاج اند مايحتاج صحيح كلامك عشان كتبت اسم فانكشن في بيند كاي بس ب اخير مزبط 3 hours ago, NX_CI said: bindKey ركز ع السطر الثاني توجد دالة داخل الـ اعتقد اني سويته bindKey("c","down", bounce) بس مايجني ولا تنبيه ب اخير Edited May 30, 2019 by liwahadri Link to comment
JustP Posted May 30, 2019 Share Posted May 30, 2019 (edited) 1 hour ago, liwahadri said: سويت آلي قلت لي ياه غير اكواد وسميت فانكشن وحطيت bindKey اسم الفأنكشن مآشتغل وآلكود مب آتوقع مفيه اغلاط عشان مارسلت الكودً كأمل آلي سويته كذا Server Side function bounce()antiBounce = false if not getElementData(localPlayer,"login") then return end antiBounce = not antiBounce if antiBounce then triggerClientEvent(source,'servermessages',source, 'TEST',warning) else triggerClientEvent(source,'servermessages',source, 'TEST',warning) endendbindKey("c","down", bounce)addEventHandler("onClientVehicleCollision",root, function(hitElement) if(not antiBounce) then return end if(hitElement ~= nil) then if(getElementType(hitElement) ~= "object") then return end end if(getElementType(source) ~= "vehicle") then return end if getVehicleOccupant(source) ~= localPlayer then return end local tx, ty, tz = getVehicleTurnVelocity(source) if ((math.abs(ty) > 0.1 and math.abs(tz) > 0.001) or (math.abs(ty) > 0.001 and math.abs(tz) > 0.1)) then local vx,vy,vz = getElementVelocity(source) setVehicleTurnVelocity(source, 0, 0, 0) setElementVelocity(source, vx*1.01, vy*1.01, vz) end end) Client Side function renderMensages() local msgd = mensages if #msgd ~= 0 then local startY = screenW*0.5 local i = 1 repeat mData = msgd[i] local drawThis = true if i~= 1 then startY = startY + screenW*0.0425 end if mData[5] == 0 and mData[6] == 0 then mData[5] = - mData[4] - screenH*0.015 mData[6] = startY mData[7] = startY end local tick = getTickCount() - mData[3] local posX, posY, alpha if tick < 1000 then local progress = math.min(tick/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, 0, 0, 0, progress, "Linear") elseif tick >= 1000 and tick <= 7000 then mData[5] = 0 elseif tick > 7000 then local progress = math.min((tick - 7000)/1000,1) mData[5] = interpolateBetween(mData[5], 0, 0, - mData[4] - mData[4] - screenH*0.015, 0, 0, progress, "Linear") if progress >= 1 then table.remove(msgd, i) drawThis = false messagetick = getTickCount() end end local globalTick = getTickCount() - messagetick if drawThis then mData[7] = startY mData[6] = interpolateBetween(mData[6], 0, 0, mData[7], 0, 0, math.min(globalTick/1000,1), "Linear") posX = mData[5] posY = mData[6] alpha = 255 dxDrawRectangle(posX, posY, mData[4], screenW*0.04, tocolor(0, 0, 0, alpha*0.75), true) local r, g, b = 0, 255, 0 if mData[2] == "warning" then r, g, b = 255, 0, 0 end dxDrawRectangle(posX + mData[4], posY, screenH*0.010, screenW*0.04, tocolor(r, g, b, alpha*0.85), true) dxDrawText(mData[1], posX, posY, posX + mData[4], posY + screenW*0.04, tocolor(255, 255, 255, alpha), fontScale*0.05, Font_1, "center", "center", false, false, true, false, false) end i = i + 1 until i > #msgd mensages = msgd endendaddEventHandler("onClientRender", getRootElement(), renderMensages) مايحتاج صحيح كلامك عشان كتبت اسم فانكشن في بيند كاي بس ب اخير مزبط اعتقد اني سويته bindKey("c","down", bounce) بس مايجني ولا تنبيه ب اخير جرب هالكود function displayServerMessage(source, message, type) triggerClientEvent(source, "servermessages", getRootElement(), message, type) end وتحت مثال عليه displayServerMessage(source, "test.", "confirm") -- هذا عشان يكون اخضر displayServerMessage(source, "test.", "warning") -- كذا يكون احمر او انك ببساطة تحط التايب كذا "warning" مو كذا warning Edited May 30, 2019 by JustP Link to comment
iiv03 Posted May 30, 2019 Author Share Posted May 30, 2019 2 hours ago, JustP said: جرب هالكود function displayServerMessage(source, message, type) triggerClientEvent(source, "servermessages", getRootElement(), message, type)end وتحت مثال عليه displayServerMessage(source, "test.", "confirm")-- هذا عشان يكون اخضرdisplayServerMessage(source, "test.", "warning")-- كذا يكون احمر او انك ببساطة تحط التايب كذا "warning" مو كذا warning ماضبط كمان function displayServerMessage(source, message, type) triggerClientEvent(source, "servermessages", getRootElement(), message, type) end function bounce() antiBounce = false if not getElementData(localPlayer,"login") then return end antiBounce = not antiBounce if antiBounce then displayServerMessage(source, "test.", "confirm") else displayServerMessage(source, "test.", "warning") end end bindKey("c","down", bounce) addEventHandler("onClientVehicleCollision",root, function(hitElement) if(not antiBounce) then return end if(hitElement ~= nil) then if(getElementType(hitElement) ~= "object") then return end end if(getElementType(source) ~= "vehicle") then return end if getVehicleOccupant(source) ~= localPlayer then return end local tx, ty, tz = getVehicleTurnVelocity(source) if ((math.abs(ty) > 0.1 and math.abs(tz) > 0.001) or (math.abs(ty) > 0.001 and math.abs(tz) > 0.1)) then local vx,vy,vz = getElementVelocity(source) setVehicleTurnVelocity(source, 0, 0, 0) setElementVelocity(source, vx*1.01, vy*1.01, vz) end end ) Link to comment
JustP Posted May 30, 2019 Share Posted May 30, 2019 3 hours ago, liwahadri said: ماضبط كمان function displayServerMessage(source, message, type) triggerClientEvent(source, "servermessages", getRootElement(), message, type)endfunction bounce()antiBounce = false if not getElementData(localPlayer,"login") then return end antiBounce = not antiBounce if antiBounce then displayServerMessage(source, "test.", "confirm") else displayServerMessage(source, "test.", "warning") endendbindKey("c","down", bounce)addEventHandler("onClientVehicleCollision",root, function(hitElement) if(not antiBounce) then return end if(hitElement ~= nil) then if(getElementType(hitElement) ~= "object") then return end end if(getElementType(source) ~= "vehicle") then return end if getVehicleOccupant(source) ~= localPlayer then return end local tx, ty, tz = getVehicleTurnVelocity(source) if ((math.abs(ty) > 0.1 and math.abs(tz) > 0.001) or (math.abs(ty) > 0.001 and math.abs(tz) > 0.1)) then local vx,vy,vz = getElementVelocity(source) setVehicleTurnVelocity(source, 0, 0, 0) setElementVelocity(source, vx*1.01, vy*1.01, vz) end end) اعتقد انك لازم تحط الوظيفة بالاخير.. يعني مو قبل الي تبي تستخدمه انت Link to comment
nxFairlywell Posted May 30, 2019 Share Posted May 30, 2019 (edited) والله يا صاحبي انت عافس ام الكود لكن اذا تقصد ان الكود الاول سيرفر والثاني كلينت عدل كود السيرفر اللي فوق لـ function onStart() local players = getElementsByType("player"); for i, thePlayer in ipairs (players) do bindKey(thePlayer,"F4", "down", function() if not getElementData(thePlayer,"login") then return end if isDM() then carfade = (not carfade) if(carfade)then triggerClientEvent(thePlayer,'servermessages',thePlayer, 'TEST',warning) else triggerClientEvent(thePlayer,'servermessages',thePlayer, 'TEST',rec) end end end ); end end addEventHandler("onResourceStart",resourceRoot, onStart); ولا تنسى تعرف المتغيرات warning rec carfade function isDM() Edited May 30, 2019 by NX_CI 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