Jump to content

تصحيح الكود


Recommended Posts

السلام عليكم ورحمة الله وبركاته

انا سويت مود لكن هناك اخطاء الكود

addCommandHandler("CreateMedic", function() 
    if getElementData(player,"oil",25) then 
        setElementData(player,"medic2",1) 
        outputChatBox("You Was Create medic2",source,200,0,150) 
        removeElmentData(player,"oil",25) 
         
elseif getElementData(player,"oil",0) then 
    outputChatBox("You Dont Have oil",source,255,0,0) 
     
    end 
end) 
  
  
  
addCommandHandler("Use Medice2", function() 
    if getElementData(player,"medic2",1) then 
        setElementHealth(player,200) 
        removeElmentData(player,"medic2",1) 
    end 
end) 

Link to comment

جرب

addCommandHandler("CreateMedic", function ( player ) 
    if getElementData(player,"oil") == 25 then 
        setElementData(player,"medic2",1) 
        outputChatBox("You Was Create medic2",player,200,0,150) 
        removeElementData(player,"oil") 
        
elseif getElementData(player,"oil") == 0 then 
    outputChatBox("You Dont Have oil",player,255,0,0) 
    
    end 
end) 
  
  
  
addCommandHandler("Use Medice2", function ( player ) 
    if getElementData(player,"medic2") == 1 then 
        setElementHealth(player,200) 
        removeElementData(player,"medic2") 
    end 
end) 
  
Link to comment
جرب

addCommandHandler("CreateMedic", function ( player ) 
    if getElementData(player,"oil") == 25 then 
        setElementData(player,"medic2",1) 
        outputChatBox("You Was Create medic2",player,200,0,150) 
        removeElementData(player,"oil") 
        
elseif getElementData(player,"oil") == 0 then 
    outputChatBox("You Dont Have oil",player,255,0,0) 
    
    end 
end) 
  
  
  
addCommandHandler("Use Medice2", function ( player ) 
    if getElementData(player,"medic2") == 1 then 
        setElementHealth(player,200) 
        removeElementData(player,"medic2") 
    end 
end) 
  

شكراً لك لكن الكود خطأ

دي الاكواد كاملة

local oil = getElementData(player,"oil") 
local medic2 = getElementData(player,"medic2") 
  
-------------------------------------------------------------------------------------- 
-------------------------------------------------------------------------------------- 
  
Marker = { 
    {566.56647,1315.54443,11.26877}, --1 
    {491.00558,1309.01355,10.06564}, 
    {424.12436,1406.04602,8.56564}, 
    {441.42508,1427.25085,9.21222}, 
    {408.71820,1475.86646,7.92261}, 
    {431.18521,1554.82129,12.78439}, 
    {488.37692,1528.40222,1.45327}, 
    {524.05084,1474.45740,3.93139}, 
    {514.05585,1380.75891,5.32974}, 
    {417.82724,1378.07129,8.89550}, 
    {401.20309,1415.23743,8.02845}, 
} 
  
  
function onStart() 
local number = math.random(#Marker) 
local x, y, z = Marker [number][1], Marker [number][2], Marker [number][3] 
marker = createMarker(x, y, z-1, "cylinder", 2.0, 255, 0, 0, 0) 
arrow = createMarker(x, y, z+2, "arrow", 1.0, 255, 0, 0, 255) 
addEventHandler("onMarkerHit", marker, onHit) 
obj = createObject(2062, x, y, z) 
if oil then 
outputChatBox ( "#ffff00 created new oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
addEventHandler("onResourceStart",resourceRoot, onStart) 
  
function onHit(player) 
destroyElement(marker) 
destroyElement(arrow) 
destroyElement(obj) 
local give2 = math.random( 2 , 10 ) 
setElementData(player,"oil",give2) 
function mainFunction() 
setTimer ( function() 
onStart () 
end, 50000, 1 ) 
end 
mainFunction() 
if oil then 
outputChatBox("#0000ff"..getPlayerName(player).." taked: "..give2.." Oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
  
local hillArea = createColRectangle ( 339.55478, 1282.31128, 250, 300 ) 
local hillRadar = createRadarArea ( 339.55478, 1282.31128, 250, 300, 0, 0, 0, 150 ) 
  
function hill_Enter ( thePlayer, matchingDimension ) 
if (getElementType(thePlayer) == "player") then 
oil = true 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 
  
function hill_Exit ( thePlayer, matchingDimension ) 
        if (getElementType(thePlayer) == "player") then 
oil = nil 
    end 
end 
addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
  
  
  
addCommandHandler("CreateMedic", function ( player ) 
    if getElementData(player,"oil") == 25 then 
        setElementData(player,"medic2",1) 
        outputChatBox("You Was Create medic2",player,200,0,150) 
        removeElementData(player,"oil") 
        
elseif  ( getElementData(player,"oil") < 25 ) then 
    outputChatBox("You Dont Have oil",player,255,0,0) 
    
    end 
end) 
  
  
  
addCommandHandler("Use Medice2", function ( player ) 
    if getElementData(player,"medic2") == 1 then 
        setElementHealth(player,200) 
        removeElementData(player,"medic2") 
    end 
end) 
  
  
addCommandHandler("howhave", function() 
outputChatBox("You Have"..tonumber(oil).." Oil And"..tonumber(medic2).." medic2") 
end) 

Link to comment
طيب حط الأخطاء الي تجيك في الديبق عشان نقدر نساعدك

WARNING: Oil_System/server.lua:1: Bad argument @'getElementData' [Expected Element at argument 1,got nil]

WARNING: Oil_System/server.lua:2: Bad argument @'getElementData' [Expected Element at argument 1,got nil]

ERROR: Oil_Ststem/server.lua:94: attempt to concatenate a nil value

Link to comment
Marker = { 
    {566.56647,1315.54443,11.26877}, --1 
    {491.00558,1309.01355,10.06564}, 
    {424.12436,1406.04602,8.56564}, 
    {441.42508,1427.25085,9.21222}, 
    {408.71820,1475.86646,7.92261}, 
    {431.18521,1554.82129,12.78439}, 
    {488.37692,1528.40222,1.45327}, 
    {524.05084,1474.45740,3.93139}, 
    {514.05585,1380.75891,5.32974}, 
    {417.82724,1378.07129,8.89550}, 
    {401.20309,1415.23743,8.02845}, 
} 
  
  
function onStart() 
local number = math.random(#Marker) 
local x, y, z = Marker [number][1], Marker [number][2], Marker [number][3] 
marker = createMarker(x, y, z-1, "cylinder", 2.0, 255, 0, 0, 0) 
arrow = createMarker(x, y, z+2, "arrow", 1.0, 255, 0, 0, 255) 
addEventHandler("onMarkerHit", marker, onHit) 
obj = createObject(2062, x, y, z) 
if oil then 
outputChatBox ( "#ffff00 created new oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
addEventHandler("onResourceStart",resourceRoot, onStart) 
  
function onHit(player) 
destroyElement(marker) 
destroyElement(arrow) 
destroyElement(obj) 
local give2 = math.random( 2 , 10 ) 
setElementData(player,"oil",give2) 
function mainFunction() 
setTimer ( function() 
onStart () 
end, 50000, 1 ) 
end 
mainFunction() 
if oil then 
outputChatBox("#0000ff"..getPlayerName(player).." taked: "..give2.." Oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
  
local hillArea = createColRectangle ( 339.55478, 1282.31128, 250, 300 ) 
local hillRadar = createRadarArea ( 339.55478, 1282.31128, 250, 300, 0, 0, 0, 150 ) 
  
function hill_Enter ( thePlayer, matchingDimension ) 
if (getElementType(thePlayer) == "player") then 
oil = true 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 
  
function hill_Exit ( thePlayer, matchingDimension ) 
        if (getElementType(thePlayer) == "player") then 
oil = nil 
    end 
end 
addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
  
  
  
addCommandHandler("CreateMedic", function ( player ) 
    if getElementData(player,"oil") >= 25 then 
        setElementData(player,"medic2",getElementData (player,"medic2") + 1) 
        outputChatBox("You Was Create medic2",player,200,0,150) 
         --       removeElementData(player,"medic2")  
      --------  setElementData (player,"oil",getElementData (player,"oil") - 25) لو عايز تنقص الداتا بدل ماتمسحها 
        
elseif  ( getElementData(player,"oil") < 25 ) then 
    outputChatBox("You Dont Have oil",player,255,0,0) 
    
    end 
end) 
  
  
  
addCommandHandler("Use Medice2", function ( player ) 
    if getElementData(player,"medic2") >= 1 then 
        setElementHealth(player,200) 
      --  removeElementData(player,"medic2") 
      --  setElementData (player,"medic2",getElementData (player,"medic2") - 1)  لو عايز تنقص الداتا بدل ماتمسحها 
    end 
end) 
  
  
addCommandHandler("howhave",  
function(plr) 
local oil = getElementData(plr,"oil") 
local medic2 = getElementData(plr,"medic2") 
outputChatBox("You Have"..tonumber(oil).." Oil And"..tonumber(medic2).." medic2") 
end 
) 

oil , medic2 و اتأكد ان الداتا

موجودين و متعرفين في مود تاني

Link to comment
Marker = { 
    {566.56647,1315.54443,11.26877}, --1 
    {491.00558,1309.01355,10.06564}, 
    {424.12436,1406.04602,8.56564}, 
    {441.42508,1427.25085,9.21222}, 
    {408.71820,1475.86646,7.92261}, 
    {431.18521,1554.82129,12.78439}, 
    {488.37692,1528.40222,1.45327}, 
    {524.05084,1474.45740,3.93139}, 
    {514.05585,1380.75891,5.32974}, 
    {417.82724,1378.07129,8.89550}, 
    {401.20309,1415.23743,8.02845}, 
} 
  
  
function onStart() 
local number = math.random(#Marker) 
local x, y, z = Marker [number][1], Marker [number][2], Marker [number][3] 
marker = createMarker(x, y, z-1, "cylinder", 2.0, 255, 0, 0, 0) 
arrow = createMarker(x, y, z+2, "arrow", 1.0, 255, 0, 0, 255) 
addEventHandler("onMarkerHit", marker, onHit) 
obj = createObject(2062, x, y, z) 
if oil then 
outputChatBox ( "#ffff00 created new oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
addEventHandler("onResourceStart",resourceRoot, onStart) 
  
function onHit(player) 
destroyElement(marker) 
destroyElement(arrow) 
destroyElement(obj) 
local give2 = math.random( 2 , 10 ) 
setElementData(player,"oil",give2) 
function mainFunction() 
setTimer ( function() 
onStart () 
end, 50000, 1 ) 
end 
mainFunction() 
if oil then 
outputChatBox("#0000ff"..getPlayerName(player).." taked: "..give2.." Oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
  
local hillArea = createColRectangle ( 339.55478, 1282.31128, 250, 300 ) 
local hillRadar = createRadarArea ( 339.55478, 1282.31128, 250, 300, 0, 0, 0, 150 ) 
  
function hill_Enter ( thePlayer, matchingDimension ) 
if (getElementType(thePlayer) == "player") then 
oil = true 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 
  
function hill_Exit ( thePlayer, matchingDimension ) 
        if (getElementType(thePlayer) == "player") then 
oil = nil 
    end 
end 
addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
  
  
  
addCommandHandler("CreateMedic", function ( player ) 
    if getElementData(player,"oil") >= 25 then 
        setElementData(player,"medic2",getElementData (player,"medic2") + 1) 
        outputChatBox("You Was Create medic2",player,200,0,150) 
         --       removeElementData(player,"medic2")  
      --------  setElementData (player,"oil",getElementData (player,"oil") - 25) لو عايز تنقص الداتا بدل ماتمسحها 
        
elseif  ( getElementData(player,"oil") < 25 ) then 
    outputChatBox("You Dont Have oil",player,255,0,0) 
    
    end 
end) 
  
  
  
addCommandHandler("Use Medice2", function ( player ) 
    if getElementData(player,"medic2") >= 1 then 
        setElementHealth(player,200) 
      --  removeElementData(player,"medic2") 
      --  setElementData (player,"medic2",getElementData (player,"medic2") - 1)  لو عايز تنقص الداتا بدل ماتمسحها 
    end 
end) 
  
  
addCommandHandler("howhave",  
function(plr) 
local oil = getElementData(plr,"oil") 
local medic2 = getElementData(plr,"medic2") 
outputChatBox("You Have"..tonumber(oil).." Oil And"..tonumber(medic2).." medic2") 
end 
) 

oil , medic2 و اتأكد ان الداتا

موجودين و متعرفين في مود تاني

شكراً لك عند كتابة howhave

يجيني دي بق ERROR: Oil_Ststem/server.lua:93: attempt to concatenate a nil value

Link to comment

الكلام يجي للكل

outputChatBox("You Have " ..tonumber(oil).." Oil And " ..tonumber(medic2).." medic2",player,255,255,0) 

ومشكلة اخرى

مثال اخدت 7 داتا

وكتبت hovehave يجيني 7

بعدها جمعت 2 داتا

وكتبت الكلمة اجاني العدد 2

ابي يجيني 9 ما تروح الداتا السابقة :|

Link to comment

طيب

لو الداتا بتاعتك مش متعرفة

جرب حط دة في كلينت

function RefreshData() 
triggerServerEvent ("ref", getLocalPlayer()) 
end 
addEventHandler("onClientRender",getRootElement(),RefreshData) 

و دة باقي الكود بتاعك

Marker = { 
    {566.56647,1315.54443,11.26877}, --1 
    {491.00558,1309.01355,10.06564}, 
    {424.12436,1406.04602,8.56564}, 
    {441.42508,1427.25085,9.21222}, 
    {408.71820,1475.86646,7.92261}, 
    {431.18521,1554.82129,12.78439}, 
    {488.37692,1528.40222,1.45327}, 
    {524.05084,1474.45740,3.93139}, 
    {514.05585,1380.75891,5.32974}, 
    {417.82724,1378.07129,8.89550}, 
    {401.20309,1415.23743,8.02845}, 
} 
  
addEvent( "ref", true) 
function refresh() 
if not getElementData (source, "oil") and not getElementData (source,"medic2")  then 
tonumber ( setElementData (source, "oil", 0) ) 
tonumber ( setElementData (source, "medic2", 0) ) 
elseif not tonumber ( getElementData (source, "oil") ) then  
tonumber ( setElementData (source, "oil", 0) ) 
elseif not tonumber ( getElementData (source, "medic2") ) then  
tonumber ( setElementData (source, "medic2", 0) ) 
end 
if getElementData (source,"oil") < 0 then 
tonumber ( setElementData (acc, "oil", 0) ) 
end 
if getElementData (source,"medic2") < 0 then 
tonumber ( setElementData (source, "medic2", 0) ) 
end 
end 
addEventHandler( "ref", getRootElement(),refresh) 
  
  
  
function onStart() 
local number = math.random(#Marker) 
local x, y, z = Marker [number][1], Marker [number][2], Marker [number][3] 
marker = createMarker(x, y, z-1, "cylinder", 2.0, 255, 0, 0, 0) 
arrow = createMarker(x, y, z+2, "arrow", 1.0, 255, 0, 0, 255) 
addEventHandler("onMarkerHit", marker, onHit) 
obj = createObject(2062, x, y, z) 
if oil then 
outputChatBox ( "#ffff00 created new oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
addEventHandler("onResourceStart",resourceRoot, onStart) 
  
function onHit(player) 
destroyElement(marker) 
destroyElement(arrow) 
destroyElement(obj) 
local give2 = math.random( 2 , 10 ) 
setElementData(player,"oil",give2) 
function mainFunction() 
setTimer ( function() 
onStart () 
end, 50000, 1 ) 
end 
mainFunction() 
if oil then 
outputChatBox("#0000ff"..getPlayerName(player).." taked: "..give2.." Oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
  
local hillArea = createColRectangle ( 339.55478, 1282.31128, 250, 300 ) 
local hillRadar = createRadarArea ( 339.55478, 1282.31128, 250, 300, 0, 0, 0, 150 ) 
  
function hill_Enter ( thePlayer, matchingDimension ) 
if (getElementType(thePlayer) == "player") then 
oil = true 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 
  
function hill_Exit ( thePlayer, matchingDimension ) 
        if (getElementType(thePlayer) == "player") then 
oil = nil 
    end 
end 
addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
  
  
  
addCommandHandler("CreateMedic", function ( player ) 
    if getElementData(player,"oil") >= 25 then 
        setElementData(player,"medic2",getElementData (player,"medic2") + 1) 
        outputChatBox("You Was Create medic2",player,200,0,150) 
       setElementData (player,"oil",getElementData (player,"oil") - 25) 
        
elseif  ( getElementData(player,"oil") < 25 ) then 
    outputChatBox("You Dont Have oil",player,255,0,0) 
    
    end 
end) 
  
  
  
addCommandHandler("Use Medice2", function ( player ) 
    if getElementData(player,"medic2") >= 1 then 
        setElementHealth(player,200) 
       setElementData (player,"medic2",getElementData (player,"medic2") - 1) 
    end 
end) 
  
  
addCommandHandler("howhave", 
function(plr) 
local oil = getElementData(plr,"oil") 
local medic2 = getElementData(plr,"medic2") 
outputChatBox("You Have"..tonumber(oil).." Oil And"..tonumber(medic2).." medic2",plr,255,255,0) 
end 
) 

* ملحوظة

ElementData دي مش بتنحفظ

لما تيجي تخرج من السيرفر بتتشال

الكود عدلته *

AccountData لو عايزها تنحفظ استخدم

Link to comment
طيب

لو الداتا بتاعتك مش متعرفة

جرب حط دة في كلينت

function RefreshData() 
triggerServerEvent ("ref", getLocalPlayer()) 
end 
addEventHandler("onClientRender",getRootElement(),RefreshData) 

و دة باقي الكود بتاعك

Marker = { 
    {566.56647,1315.54443,11.26877}, --1 
    {491.00558,1309.01355,10.06564}, 
    {424.12436,1406.04602,8.56564}, 
    {441.42508,1427.25085,9.21222}, 
    {408.71820,1475.86646,7.92261}, 
    {431.18521,1554.82129,12.78439}, 
    {488.37692,1528.40222,1.45327}, 
    {524.05084,1474.45740,3.93139}, 
    {514.05585,1380.75891,5.32974}, 
    {417.82724,1378.07129,8.89550}, 
    {401.20309,1415.23743,8.02845}, 
} 
  
addEvent( "ref", true) 
function refresh() 
if not getElementData (source, "oil") and not getElementData (source,"medic2")  then 
tonumber ( setElementData (source, "oil", 0) ) 
tonumber ( setElementData (source, "medic2", 0) ) 
elseif not tonumber ( getElementData (source, "oil") ) then  
tonumber ( setElementData (source, "oil", 0) ) 
elseif not tonumber ( getElementData (source, "medic2") ) then  
tonumber ( setElementData (source, "medic2", 0) ) 
end 
if getElementData (source,"oil") < 0 then 
tonumber ( setElementData (acc, "oil", 0) ) 
end 
if getElementData (source,"medic2") < 0 then 
tonumber ( setElementData (source, "medic2", 0) ) 
end 
end 
addEventHandler( "ref", getRootElement(),refresh) 
  
  
  
function onStart() 
local number = math.random(#Marker) 
local x, y, z = Marker [number][1], Marker [number][2], Marker [number][3] 
marker = createMarker(x, y, z-1, "cylinder", 2.0, 255, 0, 0, 0) 
arrow = createMarker(x, y, z+2, "arrow", 1.0, 255, 0, 0, 255) 
addEventHandler("onMarkerHit", marker, onHit) 
obj = createObject(2062, x, y, z) 
if oil then 
outputChatBox ( "#ffff00 created new oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
addEventHandler("onResourceStart",resourceRoot, onStart) 
  
function onHit(player) 
destroyElement(marker) 
destroyElement(arrow) 
destroyElement(obj) 
local give2 = math.random( 2 , 10 ) 
setElementData(player,"oil",give2) 
function mainFunction() 
setTimer ( function() 
onStart () 
end, 50000, 1 ) 
end 
mainFunction() 
if oil then 
outputChatBox("#0000ff"..getPlayerName(player).." taked: "..give2.." Oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
  
local hillArea = createColRectangle ( 339.55478, 1282.31128, 250, 300 ) 
local hillRadar = createRadarArea ( 339.55478, 1282.31128, 250, 300, 0, 0, 0, 150 ) 
  
function hill_Enter ( thePlayer, matchingDimension ) 
if (getElementType(thePlayer) == "player") then 
oil = true 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 
  
function hill_Exit ( thePlayer, matchingDimension ) 
        if (getElementType(thePlayer) == "player") then 
oil = nil 
    end 
end 
addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
  
  
  
addCommandHandler("CreateMedic", function ( player ) 
    if getElementData(player,"oil") >= 25 then 
        setElementData(player,"medic2",getElementData (player,"medic2") + 1) 
        outputChatBox("You Was Create medic2",player,200,0,150) 
       setElementData (player,"oil",getElementData (player,"oil") - 25) 
        
elseif  ( getElementData(player,"oil") < 25 ) then 
    outputChatBox("You Dont Have oil",player,255,0,0) 
    
    end 
end) 
  
  
  
addCommandHandler("Use Medice2", function ( player ) 
    if getElementData(player,"medic2") >= 1 then 
        setElementHealth(player,200) 
       setElementData (player,"medic2",getElementData (player,"medic2") - 1) 
    end 
end) 
  
  
addCommandHandler("howhave", 
function(plr) 
local oil = getElementData(plr,"oil") 
local medic2 = getElementData(plr,"medic2") 
outputChatBox("You Have"..tonumber(oil).." Oil And"..tonumber(medic2).." medic2",plr,255,255,0) 
end 
) 

* ملحوظة

ElementData دي مش بتنحفظ

لما تيجي تخرج من السيرفر بتتشال

الكود عدلته *

AccountData لو عايزها تنحفظ استخدم

ومشكلة اخرى

مثال اخدت 7 داتا

وكتبت hovehave يجيني 7

بعدها جمعت 2 داتا

وكتبت الكلمة اجاني العدد 2

ابي يجيني 9 ما تروح الداتا السابقة

Link to comment

كودي شغال لسا مجربه

الداتا الاتنين كانوا صفر

استخدمت الكود

setElementData (source,"oil",getElementData (source,"oil") + 53) في لوحة الادمن

و نفس الكلام الداتا التانية و مفيش مشاكل بتزيد عن عددها عادي

جرب انسخه من فوق تاني عشان الرد جه متأخر و انا عدلته قبل ماترد

Link to comment
كودي شغال لسا مجربه

الداتا الاتنين كانوا صفر

استخدمت الكود

setElementData (source,"oil",getElementData (source,"oil") + 53) في لوحة الادمن

و نفس الكلام الداتا التانية و مفيش مشاكل بتزيد عن عددها عادي

جرب انسخه من فوق تاني عشان الرد جه متأخر و انا عدلته قبل ماترد

راح تعرف خطأك اذ قريت الموضوع ذا

https://forum.multitheftauto.com/viewtopic.php?f=164&t=95928

Link to comment
كودي شغال لسا مجربه

الداتا الاتنين كانوا صفر

استخدمت الكود

setElementData (source,"oil",getElementData (source,"oil") + 53) في لوحة الادمن

و نفس الكلام الداتا التانية و مفيش مشاكل بتزيد عن عددها عادي

جرب انسخه من فوق تاني عشان الرد جه متأخر و انا عدلته قبل ماترد

راح تعرف خطأك اذ قريت الموضوع ذا

https://forum.multitheftauto.com/viewtopic.php?f=164&t=95928

فين الخطأ :|

Link to comment
كودي شغال لسا مجربه

الداتا الاتنين كانوا صفر

استخدمت الكود

setElementData (source,"oil",getElementData (source,"oil") + 53) في لوحة الادمن

و نفس الكلام الداتا التانية و مفيش مشاكل بتزيد عن عددها عادي

جرب انسخه من فوق تاني عشان الرد جه متأخر و انا عدلته قبل ماترد

راح تعرف خطأك اذ قريت الموضوع ذا

https://forum.multitheftauto.com/viewtopic.php?f=164&t=95928

فين الخطأ :|

اقصد المشكلة من السورس

افهم السورس بعدين عدل كودك بالمطلوب :mrgreen::|

Link to comment

اقصد المشكلة من السورس

افهم السورس بعدين عدل كودك بالمطلوب :mrgreen::|

:?:

شايفني نوب؟ :|

Marker = { 
    {566.56647,1315.54443,11.26877}, --1 
    {491.00558,1309.01355,10.06564}, 
    {424.12436,1406.04602,8.56564}, 
    {441.42508,1427.25085,9.21222}, 
    {408.71820,1475.86646,7.92261}, 
    {431.18521,1554.82129,12.78439}, 
    {488.37692,1528.40222,1.45327}, 
    {524.05084,1474.45740,3.93139}, 
    {514.05585,1380.75891,5.32974}, 
    {417.82724,1378.07129,8.89550}, 
    {401.20309,1415.23743,8.02845}, 
} 
  
addEvent( "ref", true) 
function refresh() 
if not getElementData (source, "oil") and not getElementData (source,"medic2")  then 
tonumber ( setElementData (source, "oil", 0) ) 
tonumber ( setElementData (source, "medic2", 0) ) 
elseif not tonumber ( getElementData (source, "oil") ) then 
tonumber ( setElementData (source, "oil", 0) ) 
elseif not tonumber ( getElementData (source, "medic2") ) then 
tonumber ( setElementData (source, "medic2", 0) ) 
end 
if getElementData (source,"oil") < 0 then 
tonumber ( setElementData (acc, "oil", 0) ) 
end 
if getElementData (source,"medic2") < 0 then 
tonumber ( setElementData (source, "medic2", 0) ) 
end 
end 
addEventHandler( "ref", getRootElement(),refresh) 
  
  
  
function onStart() 
local number = math.random(#Marker) 
local x, y, z = Marker [number][1], Marker [number][2], Marker [number][3] 
marker = createMarker(x, y, z-1, "cylinder", 2.0, 255, 0, 0, 0) 
arrow = createMarker(x, y, z+2, "arrow", 1.0, 255, 0, 0, 255) 
addEventHandler("onMarkerHit", marker, onHit) 
obj = createObject(2062, x, y, z) 
if oil then 
outputChatBox ( "#ffff00 created new oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
addEventHandler("onResourceStart",resourceRoot, onStart) 
  
function onHit(player) 
destroyElement(marker) 
destroyElement(arrow) 
destroyElement(obj) 
local give2 = math.random( 2 , 10 ) 
setElementData(player,"oil",give2) 
function mainFunction() 
setTimer ( function() 
onStart () 
end, 50000, 1 ) 
end 
mainFunction() 
if oil then 
outputChatBox("#0000ff"..getPlayerName(player).." taked: "..give2.." Oil", getRootElement(), 255, 255, 255, true ) 
end 
end 
  
local hillArea = createColRectangle ( 339.55478, 1282.31128, 250, 300 ) 
local hillRadar = createRadarArea ( 339.55478, 1282.31128, 250, 300, 0, 0, 0, 150 ) 
  
function hill_Enter ( thePlayer, matchingDimension ) 
if (getElementType(thePlayer) == "player") then 
oil = true 
        end 
end 
addEventHandler ( "onColShapeHit", hillArea, hill_Enter ) 
  
function hill_Exit ( thePlayer, matchingDimension ) 
        if (getElementType(thePlayer) == "player") then 
oil = nil 
    end 
end 
addEventHandler ( "onColShapeLeave", hillArea, hill_Exit ) 
  
  
  
addCommandHandler("CreateMedic", function ( player ) 
    if getElementData(player,"oil") >= 25 then 
        setElementData(player,"medic2",getElementData (player,"medic2") + 1) 
        outputChatBox("You Was Create medic2",player,200,0,150) 
       setElementData (player,"oil",getElementData (player,"oil") - 25) 
        
elseif  ( getElementData(player,"oil") < 25 ) then 
    outputChatBox("You Dont Have oil",player,255,0,0) 
    
    end 
end) 
  
  
  
addCommandHandler("Use", function ( player ) 
    if getElementData(player,"medic2") >= 1 then 
        setElementHealth(player,200) 
       setElementData (player,"medic2",getElementData (player,"medic2") - 1) 
    end 
end) 
  
addCommandHandler("howhave", 
function(plr) 
local oil = getElementData(plr,"oil") 
local medic2 = getElementData(plr,"medic2") 
outputChatBox("You Have "..tonumber(oil).." Oil And "..tonumber(medic2).." medic2",plr,255,255,0) 
end 
) 

ماله السورس ؟

ايه المشكلة في السورس ؟

لو قصدك في دي setElementData (source,"oil",getElementData (source,"oil") + 53)

بدلها بدي و جرب

addCommandHandler("sett",
function(plr,comm,ammm)
setElementData (plr,"oil",getElementData (plr,"oil") + tonumber(ammm) )
end
)

:mrgreen:

--

اجتني مشكلة بمود اخر وما ابي افتح موضوع جديد

المشكلة هي ركبت مقر لجروب لكن عندما الاعب يموت يرسبن للمقر بعدها يرسبن للمستشفى

ما يرسبن بالمقر

خلينا نشوف الاكواد

Link to comment
addEventHandler("onPlayerWasted",root, function() 
    if ( getElementData(source,"Group") == "D3S" ) and ( getTeamN(source) == "No Team" ) then 
setElementPosition(source, 1935+rnx,1382.3000488281+rny,124.69999694824) 
    end 
end) 

جرب تحط تايمر

عشان لما الاعب يموت ينتقل للمستشفي اول شئ

بعد كدة يكمل الوقت بتاع التايمر و ينتقل للمقر

Link to comment

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...