Jump to content

Rockyz

Members
  • Posts

    1,862
  • Joined

  • Days Won

    8

Everything posted by Rockyz

  1. وعليكم السلام table.insert هذا الفنكشن يضيف قيمة جديدة في الجدول الساينتكس : table.insert (table, [pos,] value) table = التيبل الي تبي تضيف اليه القيمة pos = طبعا هذا الأرقمنت اختياري وألي هو رقم القيمة اذا ماحطيته بيكون تلقائي اخر قيمة value = القيمة الي تبي تضيفها بعض الأمثلة : local myTable = { 'HI', 'OK', '!' }; print ( myTable [ #myTable ] ) table.insert ( myTable, 'Hello' ) print ( myTable [ #myTable ] ) --[[ ! Hello ]] هنا ما أستخدمنا الأرقمنت الثاني ف ضاف قيمة 'Hello' للجدول (القيمة الأخيرة) local myTable = { 'HI', 'OK', '!' }; print ( myTable [ 2 ] ) table.insert ( myTable, 2, 'Hello' ) print ( myTable [ 2 ] ) --[[ OK Hello ]] هنا استخدمنا الأرقمنت الثاني والي هو رقم القيمة string.find يستخدم للبحث عن كلمة في السترنق string.find (s, pattern [, init [, plain]]) الأرقمنتات المطلوبة s = السترنق الي تبي تبحث فيه pattern = الكلمة الي تبي عنها من السترنق الأرقمنتات الأختيارية init = يحدد من وين تبدأ البحث عن الكلمة (1)ء plain = يطفي البحث عن الأنماط (false) بعض الأمثلة : print ( string.find ( ' Hello', '%s%sHello' ) and 'true' or 'false' ) -- true print ( string.find ( ' Hello', '%s%sHello', 1, true ) and 'true' or 'false' ) -- false if ( string.find ( 'thisString..', '%p%p' ) ) then print ( ( { string.gsub ( 'thisString..', 'S', string.lower ) } ) [ 1 ] ) end -- thisstring.. string.format unpack بأختصار يفك الجدول مثلا عندي جدول كذا myTable = { 'a', b', 'c' } اذا سوينا كذا myTable = { 'a', 'b', 'c' ) a, b, c = unpack ( myTable ) -- 'a', 'b', 'c' اذا تبي تجرب الأمثلة من هنا
  2. -- #Client Side local showToSelf = true -- if you want to show the text to your self put it to 'true' and if you dont put it to 'false' or remove it function dxDrawTextOnElement(TheElement,text,height,distance,R,G,B,alpha,size,font,checkBuildings,checkVehicles,checkPeds,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement) local x, y, z = getElementPosition(TheElement) local x2, y2, z2 = getElementPosition(localPlayer) local distance = distance or 20 local height = height or 1 local checkBuildings = checkBuildings or true local checkVehicles = checkVehicles or false local checkPeds = checkPeds or false local checkObjects = checkObjects or true local checkDummies = checkDummies or true local seeThroughStuff = seeThroughStuff or false local ignoreSomeObjectsForCamera = ignoreSomeObjectsForCamera or false local ignoredElement = ignoredElement or nil if (isLineOfSightClear(x, y, z, x2, y2, z2, checkBuildings, checkVehicles, checkPeds , checkObjects,checkDummies,seeThroughStuff,ignoreSomeObjectsForCamera,ignoredElement)) then local sx, sy = getScreenFromWorldPosition(x, y, z+height) if(sx) and (sy) then local distanceBetweenPoints = getDistanceBetweenPoints3D(x, y, z, x2, y2, z2) if(distanceBetweenPoints < distance) then dxDrawText(text, sx+2, sy+2, sx, sy, tocolor(R or 255, G or 255, B or 255, alpha or 255), (size or 1)-(distanceBetweenPoints / distance), font or "arial", "center", "center") end end end end addEventHandler ( 'onClientRender', root, function ( ) for _, players in pairs ( getElementsByType 'player' ) do if not ( showToSelf ) then if ( players ~= localPlayer ) then if ( getElementData ( players, 'playerOnDuty' ) ) then dxDrawTextOnElement ( players, 'Admin On Duty [NO DM]' ) end end else if ( getElementData ( players, 'playerOnDuty' ) ) then dxDrawTextOnElement ( players, 'Admin On Duty [NO DM]' ) end end end end ) -- #Server Side addCommandHandler('duty',function(player,cmd) local accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup('user.'..accName,aclGetGroup('Admin')) then setElementData(player,'playerOnDuty',not getElementData(player,'playerOnDuty')) outputChatBox('#F10404[ADMINISTRATOR] #FF8B00 '..getPlayerName(player)..' #04F42Cis now '..(getElementData(player, 'playerOnDuty') and 'on' or 'off')..' duty!', getRootElement(), 255, 255, 255, true) setElementAlpha(player,getElementData(player,'playerOnDuty') and 0 or 255) end end ) local theTable = { [ 'brokenbone' ] = { false }, [ 'bleeding' ] = { false }, [ 'pain' ] = { false }, [ 'cold' ] = { false }, [ 'temperature' ] = { 36.5 }, [ 'blood' ] = { 12000 }, [ 'food' ] = { 100 }, [ 'thirst' ] = { 75 } }; addDebugHook ( 'preFunction', function ( sourceResource, functionName, isAllowedByACL, luaFilename, luaLineNumber, ... ) local args = { ... }; if ( #args >= 3 and getElementData ( args [ 1 ], 'playerOnDuty' ) and theTable [ args [ 2 ] ] and getElementData ( args [ 1 ], args [ 2 ] ) ~= args [ 3 ] ) then return setElementData ( args [ 1 ], args [ 2 ], theTable [ args [ 2 ] ] [ 1 ] ) end end, { 'setElementData' } ) addDebugHook ( 'preFunction', function ( sourceResource, functionName, isAllowedByACL, luaFilename, luaLineNumber, ... ) local args = { ... }; if ( #args >= 2 and getElementData ( args [ 1 ], 'playerOnDuty' ) ) then return setElementAlpha ( args [ 1 ], 0 ) end end, { 'setElementAlpha' } )
  3. Rockyz

    [Help] With text

    remove 'local' at line 9
  4. مثال : function convertTimeToSeconds(y,d,h,m,s) local y,d,h,m,s,newTime=y or 0,d or 0,h or 0,m or 0,s or 0,0 local newTime=newTime+(31556926*y)+(86400*d)+(3600*h)+((3600/60)*m)+(((3600/60)/60)*s) return math.floor(newTime) end print ( convertTimeToSeconds ( 0, 1, 2 ) ) -- 1 day, 2 hour --[[ output : 93600 ]]
  5. addCommandHandler ( 'kk', function ( player ) local acc = getPlayerAccount ( player ) if not ( isGuestAccount ( acc ) ) then setAccountData ( acc, 'account-Timer.Test', toJSON ( { getRealTime ( ).timestamp, 60 } ) ) -- 60 = 1 minute outputChatBox ( 'تم تفعيل إشتراكك', player, 255, 255, 0, true ) end end ) setTimer ( function ( ) for _, acc in pairs ( getAccounts ( ) ) do if not ( isGuestAccount ( acc ) ) then local data = getAccountData ( acc, 'account-Timer.Test' ) if ( data and type ( data ) == 'string' ) then local data = fromJSON ( data ) if ( getRealTime ( ).timestamp - data [ 1 ] >= data [ 2 ] ) then setAccountData ( acc, 'account-Timer.Test', false ) if ( getAccountPlayer ( acc ) ) then outputChatBox ( 'تم إلغاء اشتراكك', getAccountPlayer ( acc ), 255, 0, 0, true ) end end end end end end, 60000 / 2, 0 ) addEventHandler ( 'onResourceStart', resourceRoot, function ( ) for _, players in pairs ( getElementsByType 'player' ) do local acc = getPlayerAccount ( players ) if not ( isGuestAccount ( acc ) ) then local data = getAccountData ( acc, 'account-Timer.Test' ) if ( data and type ( data ) == 'string' ) then local data = fromJSON ( data ) if ( getRealTime ( ).timestamp - data [ 1 ] >= data [ 2 ] ) then setAccountData ( acc, 'account-Timer.Test', false ) outputChatBox ( 'تم إلغاء اشتراكك', players, 255, 0, 0, true ) end end end end end ) addEventHandler ( 'onPlayerLogin', root, function ( _, acc ) local data = getAccountData ( acc, 'account-Timer.Test' ) if ( data and type ( data ) == 'string' ) then local data = fromJSON ( data ) if ( getRealTime ( ).timestamp - data [ 1 ] >= data [ 2 ] ) then setAccountData ( acc, 'account-Timer.Test', false ) outputChatBox ( 'تم إلغاء اشتراكك', source, 255, 0, 0, true ) end end end )
  6. MTASA/server/mods/deathmatch/internal.db
  7. استبدل جهة السيرفر : addEvent ( 'setElementModel_SERVER', true ) addEvent ( 'pedClothes_SERVER', true ) addEventHandler ( 'setElementModel_SERVER', root, function ( model ) return setElementModel ( client, model ) end ) addEventHandler ( 'pedClothes_SERVER', root, function ( theBool, ... ) return _G [ theBool and 'addPedClothes' or 'removePedClothes' ] ( client, unpack ( { ... } ) ) end )
  8. استبدل جهة الكلينت بهذا : _setElementModel = setElementModel function setElementModel ( e, m ) return triggerServerEvent ( 'setElementModel_SERVER', e, m ) end addEventHandler ("onClientGUIClick",getRootElement(), function(button,state,absoluteX,absoluteY) if (button == "left") then if (source == clothesshopStartWindowCJbutton) then cjTempTable = nil cjTempTable = {} for i=0,17 do local tstr,mstr = getPedClothes local tempTab = {i,tstr,mstr} table.insert (cjTempTable,tempTab) end guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopCJwindow,true) elseif (source == clothesshopStartWindowSkinButton) then guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopCJwindow,false) guiSetVisible (clothesshopSkinWindow,true) elseif (source == clothesshopStartWindowCloseButton) then guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopCJwindow,false) showCursor (false,false) guiSetInputEnabled (false) elseif (source == clothesshopSkinWindowButtonOK) then guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopSkinWindow,false) guiSetVisible (clothesshopCJwindow,false) showCursor (false,false) guiSetInputEnabled (false) elseif (source == clothesshopSkinWindowButtonCancel) then guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopSkinWindow,false) guiSetVisible (clothesshopCJwindow,false) showCursor (false,false) guiSetInputEnabled (false) triggerServerEvent ("clothesShopClose",getLocalPlayer(),"skin-cancel") elseif (source == clothesshopCJwindowButtonOK) then local clothes = {} for i=0,17 do local t,m = getPedClothes (getLocalPlayer(),i) if t and m then table.insert (clothes,i .. "," .. t .. "," .. m) end end guiSetVisible (clothesshopStartWindow,false) guiSetVisible (clothesshopSkinWindow,false) guiSetVisible (clothesshopCJwindow,false) showCursor (false,false) guiSetInputEnabled (false) triggerServerEvent ("clothesShopClose",getLocalPlayer(),"save-cj",clothes) elseif (source == EmploymentAgencyWindowCloseButton) then guiSetVisible (EmploymentAgencyWindow,false) showCursor (false,false) guiSetInputEnabled (false) elseif (source == clothesshopSkinWindowLeft) then local skin = getElementModel (getLocalPlayer()) if (skin == 0) then setElementModel (getLocalPlayer(),312) elseif (skin == 7) then setElementModel (getLocalPlayer(),2) elseif (skin == 9) then setElementModel (getLocalPlayer(),7) elseif (skin == 43) then setElementModel (getLocalPlayer(),41) elseif (skin == 66) then setElementModel (getLocalPlayer(),64) elseif (skin == 75) then setElementModel (getLocalPlayer(),73) elseif (skin == 87) then setElementModel (getLocalPlayer(),85) elseif (skin == 148) then setElementModel (getLocalPlayer(),118) elseif (skin == 150) then setElementModel (getLocalPlayer(),148) elseif (skin == 209) then setElementModel (getLocalPlayer(),207) elseif (skin == 290) then setElementModel (getLocalPlayer(),288) elseif (skin == 274) then setElementModel (getLocalPlayer(),272) else setElementModel (getLocalPlayer(),skin -1) end elseif (source == clothesshopSkinWindowRight) then local skin = getElementModel (getLocalPlayer()) if (skin == 312) then setElementModel (getLocalPlayer(),0) elseif (skin == 2) then setElementModel (getLocalPlayer(),7) elseif (skin == 7) then setElementModel (getLocalPlayer(),9) elseif (skin == 41) then setElementModel (getLocalPlayer(),43) elseif (skin == 64) then setElementModel (getLocalPlayer(),66) elseif (skin == 73) then setElementModel (getLocalPlayer(),75) elseif (skin == 85) then setElementModel (getLocalPlayer(),87) elseif (skin == 118) then setElementModel (getLocalPlayer(),148) elseif (skin == 148) then setElementModel (getLocalPlayer(),150) elseif (skin == 207) then setElementModel (getLocalPlayer(),209) elseif (skin == 288) then setElementModel (getLocalPlayer(),290) elseif (skin == 272) then setElementModel (getLocalPlayer(),274) else setElementModel (getLocalPlayer(),skin +1) end elseif (source == clothesshopCJwindowButtonLeft) then if (getElementModel (getLocalPlayer()) == 0) then local r,c = guiGridListGetSelectedItem (clothesshopCJwindowClothesGridlist) if (r) then local type = tonumber(guiGridListGetItemText (clothesshopCJwindowClothesGridlist,r,1)) if (type) then local type,id = getPedIndexClothes (getLocalPlayer(),type) setPedIndexClothes (getLocalPlayer(),type,id-1) end else exports.js_infowindow:showInfoWindow ("Select the clothes you want to change!") end else exports.js_infowindow:showInfoWindow ("You haven't got the CJ skin!\nGet that first before you go to get clothes!") end elseif (source == clothesshopCJwindowButtonRight) then if (getElementModel (getLocalPlayer()) == 0) then local r,c = guiGridListGetSelectedItem (clothesshopCJwindowClothesGridlist) if (r) then local type = tonumber(guiGridListGetItemText (clothesshopCJwindowClothesGridlist,r,1)) if (type) then local type,id = getPedIndexClothes (getLocalPlayer(),type) setPedIndexClothes (getLocalPlayer(),type,id+1) end else exports.js_infowindow:showInfoWindow ("Select the clothes you want to change!") end else exports.js_infowindow:showInfoWindow ("You haven't got the CJ skin!\nGet that first before you go to get clothes!") end end end end) addEvent ("openClothesShop",true) addEventHandler ("openClothesShop",getRootElement(), function() guiSetVisible (clothesshopStartWindow,true) showCursor (true,true) end) function getPedIndexClothes (player,type) local tstr,mstr = getPedClothes (player,type) if (tstr) then local type,index = getTypeIndexFromClothes (tstr,mstr) return type,index else return type,0 end end function setPedIndexClothes (player,type,index) if (index > 0) then local tstr,mstr = getClothesByTypeIndex (type,index) if tstr and mstr then triggerServerEvent ( 'pedClothes_SERVER', player, true, tstr, mstr, type ) end else triggerServerEvent ( 'pedClothes_SERVER', player, false, tstr, mstr, type ) end end جهة السيرفر : addEvent ( 'setElementModel_SERVER', true ) addEvent ( 'pedClothes_SERVER', true ) addEventHandler ( 'setElementModel_SERVER', root, function ( elm, model ) setElementModel ( elm, model ) end ) addEventHandler ( 'pedClothes_SERVER', root, function ( theBool, ... ) return _G [ theBool and 'addPedClothes' or 'removePedClothes' ] ( unpack ( { ... } ) ) end )
  9. الويكي اصلا مكتوب فيه Note: The client side version of getPlayerSerial has been deprecated as it can return the wrong value for some players, and is potentially insecure. The following article assumes that the function is serverside only. يعني ممكن يعطي قيمة غلط
  10. قلت لك ماله داعي لأنه في return مايصير return break
  11. فنكشن break ماله داعي
  12. هذا اختصار صغير للفنكشن ورتبته شوي : function getQAnswerFromTable(table,Q,changed,answer) local changed = changed or false local answer = answer or false if not ( changed ) then for k, v in ipairs ( table ) do if ( v [ 1 ] == Q ) then return v [ 2 ] end if ( answer and v [ 2 ] == Q ) then return v [ 1 ] end end else if ( table [ Q ] ) then return table [ Q ] end if ( answer ) then for k, v in pairs ( table )do if ( v == Q ) then return k end end end end return false end
  13. الفرق انك كنت حاطط text بين سترنق
  14. انت لحد الان فاهم غلط جرب هالمثال : QA = { [ 'Nothing' ] = 'Error', [ 'a' ] = 'b', [ 'c' ] = 'd', [ 'haha' ] = '?', [ 'Hi !' ] = 'Hello !' }; function answerMyQuestion ( a ) print ( QA [ a ] or QA [ 'Nothing' ] ) end answerMyQuestion ( 'a' ) answerMyQuestion ( 'No Answer For This !!!!' ) b Error
  15. function saiyansDoor ( saiyan ) if ( saiyan and getElementType ( saiyan ) == 'player' and source == Door ) then local super = getPlayerTeam ( saiyan ) local saiyanType = getTeamFromName ( 'Police' ) if ( super == saiyanType ) then local isSaiyan = isKeyBound ( saiyan, 'tab', 'down', OpenDoor ) if ( eventName == 'onMarkerHit' ) then if not ( isSaiyan ) then bindKey ( saiyan, 'tab', 'down', OpenDoor, 1 ) end elseif ( eventName == 'onMarkerLeave' ) then if ( isSaiyan ) then unbindKey ( saiyan, 'tab', 'down', OpenDoor ) end end end end end addEventHandler ( 'onMarkerHit', root, saiyansDoor ) addEventHandler ( 'onMarkerLeave', root, saiyansDoor )
  16. لا مو كذا طريقتي انا طريقتي هي اذا كان السؤال موجود في الجدول يطلع الجواب اذا مو موجود السؤال يطبع 'b' مثلا لو سويت كذا : answerMyQuestion ( ' ----- ' ) بيطبع 'b' لأنه مافي قيمة ' ----- ' في الجدول _______ انا مابي اسوي اذا كان كاتب السؤال يطلع الجواب والعكس انت فاهم غلط
  17. يفضل انك تستعمل 'break' او تقدر تسويها بطريقة ثانية : مثال : QA = { [ 'a' ] = 'b', [ 'c' ] = 'd', [ 'haha' ] = '?', [ 'Hi !' ] = 'Hello !' }; function answerMyQuestion ( a ) print ( QA [ a ] or QA [ 'a' ] ) end answerMyQuestion ( 'Hi !' ) answerMyQuestion ( 'haha' )
  18. table 'onClientGUIClick' guiGetText string.find string.gsub guiSetText
  19. هو قصده الديبق ..
  20. Rockyz

    isTimer bug ?

    show me your codes because i tried it and its working
×
×
  • Create New...