Jump to content

تصحيح كود


Recommended Posts

Posted

تصحيح كود يجيب عدد الاعبين يلي معهم داتا عن طريق الجدول, الديبق ما فيه اخطاء....

playersTable = {} 
function onRStart() 
outputChatBox("Start", getRootElement(), 255, 255, 255, true) 
timer1 = setTimer(function() 
for i,v in ipairs(getElementsByType("player")) do 
if getElementData(v, "playersInMission") then 
table.insert(playersTable, v) 
if #playersTable < 3 then 
outputChatBox("No Players In The Mission", getRootElement(), 255, 255, 255, true) 
else 
outputChatBox("Have Players In The Mission", getRootElement(), 255, 255, 255, true) 
end 
end 
end 
end, 5000, 1) 
end 
addEventHandler("onResourceStart", resourceRoot, onRStart) 

Posted
playersTable = {} 
function onRStart() 
outputChatBox("Start", getRootElement(), 255, 255, 255, true) 
timer1 = setTimer(function() 
for i,v in ipairs(getElementsByType("player")) do 
if getElementData(v, "playersInMission") == true then 
table.insert(playersTable, v) 
if #playersTable < 3 then 
outputChatBox("No Players In The Mission", getRootElement(), 255, 255, 255, true) 
else 
outputChatBox("Have Players In The Mission", getRootElement(), 255, 255, 255, true) 
end 
end 
end 
end, 5000, 1) 
end 
addEventHandler("onResourceStart", resourceRoot, onRStart) 

مانك متحقق من الداتا

true or false

Skype :- mezo.prince1

FaceBook :- https://www.facebook.com/medolua

YouTube :- http://www.youtube.com/c/MeZoOPriNse 

76561198820126897.png

Posted
playersTable = {} 
function onRStart() 
outputChatBox("Start", getRootElement(), 255, 255, 255, true) 
timer1 = setTimer(function() 
for i,v in ipairs(getElementsByType("player")) do 
if getElementData(v, "playersInMission") == true then 
table.insert(playersTable, v) 
if #playersTable < 3 then 
outputChatBox("No Players In The Mission", getRootElement(), 255, 255, 255, true) 
else 
outputChatBox("Have Players In The Mission", getRootElement(), 255, 255, 255, true) 
end 
end 
end 
end, 5000, 1) 
end 
addEventHandler("onResourceStart", resourceRoot, onRStart) 

مانك متحقق من الداتا

true or false

مش لازم .

 

 

Posted
تصحيح كود يجيب عدد الاعبين يلي معهم داتا عن طريق الجدول, الديبق ما فيه اخطاء....

Posted

عدلت لك الكود كامل ، جرب

  
function onRStart() 
outputChatBox("Start", getRootElement(), 255, 255, 255, true) 
timer1 = setTimer(function() 
    if getHowManyPlayersInMission() < 3 then 
    outputChatBox("No Players In The Mission",      getRootElement(), 255, 255, 255, true) 
    else 
    outputChatBox("Have Players In The Mission", getRootElement(), 255, 255, 255, true) 
    end 
    end, 5000, 1) 
end 
addEventHandler("onResourceStart", resourceRoot, onRStart) 
  
  
function getHowManyPlayersInMission() 
     plrs = 0 
     for _, player in ipairs(getElementsByType("player")) do 
          if getElementData(player,"playersInMission") then 
               plrs = plrs + 1 
          end 
     end 
     return plrs 
end 
  

أعتذر اذا فيه اخطاء ، جالس اكتب من الجوال

* There is No God but Allah

discord: HassoN#2709

Visit my wiki profile: https://wiki.multitheftauto.com/wiki/User:Hassan_saad

13319665721.gif

Posted

إستخدم هذا الكود عشان تجيب اللاعبين اللي بالداتا المحدده

أسهل لك و أفضل وإذا مافهمت الوظيفة علمني

setElementData( player, "DataName", true ) -- لما يدخل اللاعب للمهمة 
setElementData( player, "DataName", false ) -- لما يطلع اللاعب من المهمة 
  
  
-- Syntax : getPlayersFromData( string data ) 
  
function getPlayersFromData( data ) 
      if type(data) == "string" then 
            local t = {    } 
            local players = getElementsByType("player") 
            for _, i in ipairs( players ) do 
                  if ( getElementData(i,data) == true ) then 
                         table.insert( t, i ) 
                  end 
            end 
            return t 
       else return outputDebugString("Bad Argument @ data , got "..tostring(type(data)), 2) end 
end 
  
-- مثال على إستخدام الوظيفة 
  
setTimer( function() 
     for k, v in ipairs( getPlayersFromData("DataName") ) do 
           outputChatBox(getPlayerName(v)) 
     end 
end, 2000, 0) 
  

Discord ID : nxFairlywell#6895

 

Posted

متأخرين كثير صراحه... زمان سويته خليت انه يحط الاعب بالجدول جبت عدد الاعبين يلي بالجدول

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...