Jump to content

خطأ في كود السيارات


Recommended Posts

السلام عليكم

شباب وش الخطأ في ذا الكود ؟

server side

local gate = createObject ( 980, 1286.4000244141 , -1652.8000488281, 15.300000190735, 0, 0, 269.48901367188) 
local gate_no = createObject ( 3749, 1286.4000244141 , -1652.8000488281, 18.5, 0, 0, 269.48901367188) 
local marker = createMarker( 1284.8599853516, -1652.9304199219, 12.546875 , "cylinder", 7, 255, 153, 0, 0) 
local markers = { 
  
} 
local blib = createBlipAttachedTo ( gate, 23) 
local x,y,z = 0,0,0 
  
function open(thePlayer) 
    if isAdmin(thePlayer) == true then 
        moveObject ( gate, 3000, 1286.4000244141 , -1652.8000488281, 25) 
        outputChatBox ("Welcome To Admins Base", thePlayer, 255, 153, 0) 
    else 
        setPlayerWantedLevel(thePlayer,3) 
    end 
end 
addEventHandler( "onMarkerHit", marker, open ) 
  
function close(thePlayer) 
     
    if isAdmin(thePlayer) == true then 
        moveObject ( gate, 3000, 1286.4000244141 , -1652.8000488281, 15) 
    end 
  
end 
addEventHandler( "onMarkerLeave", marker, close ) 
  
function opengui(player) 
    if isPedInVehicle(player) == false then 
        mark = nil 
        for i,v in ipairs(markers) do 
            if markers[i][1] == source then 
                if getElementData(player, "Group") == markers[i][4] or markers[i][4] == "N/A" then 
                    mark = markers[i][2] 
                    splitted = split(markers[i][3],",") 
                    x,y,z = splitted[1],splitted[2],splitted[3] 
                    triggerClientEvent(player,"openGUI",getRootElement(), mark) 
                else 
                    outputChatBox(markers[i][4] .. " هذه الماركر فقط لقروب ",player,255,153,20,true) 
                end              
            end 
        end 
    end 
end 
  
function loadHandlers() 
  
    xml = xmlLoadFile("xml.xml") 
    for i,node in ipairs(xmlNodeGetChildren(xml)) do 
        x = xmlNodeGetAttribute(node, "x") 
        y = xmlNodeGetAttribute(node, "y") 
        z = xmlNodeGetAttribute(node, "z") 
        typee = xmlNodeGetAttribute(node, "type") 
        size = xmlNodeGetAttribute(node, "size") 
        r = xmlNodeGetAttribute(node, "r") 
        g = xmlNodeGetAttribute(node, "g") 
        b = xmlNodeGetAttribute(node, "b") 
        a = xmlNodeGetAttribute(node, "a") 
        ii = xmlNodeGetAttribute(node, "ids") 
        spawn = xmlNodeGetAttribute(node, "spawn") 
        group = xmlNodeGetAttribute(node, "group") 
        table.insert(markers, i , {createMarker(x,y,z,typee,size,r,g,b,a),ii,spawn,group} ) 
    end 
    xmlUnloadFile(xml) 
     
    setTimer( 
        function() 
            for i,v in ipairs(markers)do 
                addEventHandler( "onMarkerHit", v[1], opengui ) 
            end 
        end 
    ,500,1) 
     
end 
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),loadHandlers) 
  
function warp(player,id) 
    vehicle = createVehicle(id,x,y,z) 
    warpPlayerIntoVehicle(player,vehicle) 
end 
addEvent("warp",true) 
addEventHandler("warp",root,warp) 
  
function loging(_, account) 
    if isAdmin(source) then 
        setPlayerSkin(source, 163) 
    end 
end 
addEventHandler("onPlayerLogin",root,loging) 
  
function isAdmin(player) 
    acc = getPlayerAccount(player) 
    accountname = getAccountName(acc) 
    if not accountname then 
        return false 
    else     
        if isObjectInACLGroup("user."..accountname, aclGetGroup('Admin2')) or isObjectInACLGroup("user."..accountname, aclGetGroup('Console')) and not isGuestAccount(acc) then 
            return true 
        else 
            return false 
        end 
    end 
end 
  
function newMarker(pos,color,size,ids,pos2,group) 
    pos = split(pos, ",") 
    r,g,b,a = getColorFromString(color) 
    --table.insert(markers, #markers + 1 , { createMarker(pos[1], pos[2], pos[3]-1, "cylinder", size, r,g,b,a) , ids , pos2, group} ) 
    xml = xmlLoadFile("xml.xml") 
    if xml then  
        child = xmlCreateChild(xml,"marker") 
        xmlNodeSetAttribute(child, "x", pos[1]) 
        xmlNodeSetAttribute(child, "y", pos[2]) 
        xmlNodeSetAttribute(child, "z", pos[3]) 
        xmlNodeSetAttribute(child, "type", "cylinder") 
        xmlNodeSetAttribute(child, "size", size) 
        xmlNodeSetAttribute(child, "r", r) 
        xmlNodeSetAttribute(child, "g", g) 
        xmlNodeSetAttribute(child, "b", b) 
        xmlNodeSetAttribute(child, "a", a) 
        xmlNodeSetAttribute(child, "ids", ids) 
        xmlNodeSetAttribute(child, "spawn", pos2) 
        xmlNodeSetAttribute(child, "group", group) 
        xmlSaveFile(xml) 
    end 
    xmlUnloadFile(xml) 
    loadHandlers() 
end 
addEvent("newMarker" ,true) 
addEventHandler("newMarker", root,newMarker) 
  
function newmarkerrequest(playerSource) 
    if isAdmin(playerSource) then 
        triggerClientEvent(playerSource, "onMarkerRequest" , getRootElement()) 
    end 
end 
addCommandHandler("newcarmarkergtatime", newmarkerrequest) 
addEvent("newcarrquest",true) 
addEventHandler("newcarrquest",getRootElement(),newmarkerrequest) 
  
-- MANAGER 
  
addCommandHandler("m8rat", 
    function(player) 
        if isAdmin(player) then 
            triggerClientEvent(player, "showManagerWindow", player) 
        end 
    end 
) 
  
function saveall(markers_data) 
    for ii,vv in ipairs(markers)do 
        destroyElement(vv[1]) 
    end 
    markers = {} 
    xml = xmlLoadFile("xml.xml") 
    if xml then 
        for i,v in ipairs(xmlNodeGetChildren(xml))do 
            xmlDestroyNode(v) 
        end 
        for i,v in ipairs(markers_data)do 
            table.insert(markers,i,{createMarker(v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]),v[10],v[11]..","..v[12]..","..v[13],v[14]} ) 
            child = xmlCreateChild(xml, "marker") 
            xmlNodeSetAttribute(child, "x", v[1]) 
            xmlNodeSetAttribute(child, "y", v[2]) 
            xmlNodeSetAttribute(child, "z", v[3]) 
            xmlNodeSetAttribute(child, "type", v[4]) 
            xmlNodeSetAttribute(child, "size", v[5]) 
            xmlNodeSetAttribute(child, "r", v[6]) 
            xmlNodeSetAttribute(child, "g", v[7]) 
            xmlNodeSetAttribute(child, "b", v[8]) 
            xmlNodeSetAttribute(child, "a", v[9]) 
            xmlNodeSetAttribute(child, "ids", v[10]) 
            xmlNodeSetAttribute(child, "spawn", v[11]..","..v[12]..","..v[13]) 
            xmlNodeSetAttribute(child, "group", v[14]) 
         
        end 
        xmlSaveFile(xml) 
    end 
    xmlUnloadFile(xml) 
     
     
    setTimer( 
    function() 
        for i,v in ipairs(markers)do 
            addEventHandler( "onMarkerHit", v[1], opengui ) 
        end 
    end 
    ,500,1) 
end 
addEvent("saveMarkersFromManager",true) 
addEventHandler("saveMarkersFromManager",getRootElement() , saveall) 
  
  
  

اذا شغلت المود يطلع في الكونسل

server.lua:70: Bad argument @ 'addEventHandler'

واذا رحت للماركر يجيني كذا

server.lua:30:Bad'ped' pointer @ 'isPedInVehicle'

+ كيف اخليه الشخص الي يروح للماركر ياخذ سياره وحده بس

اذا اخذ سياره ثانيه تنسحب الاولى

وثانكيو :$

Link to comment
السلام عليكم

شباب وش الخطأ في ذا الكود ؟

server side

local gate = createObject ( 980, 1286.4000244141 , -1652.8000488281, 15.300000190735, 0, 0, 269.48901367188) 
local gate_no = createObject ( 3749, 1286.4000244141 , -1652.8000488281, 18.5, 0, 0, 269.48901367188) 
local marker = createMarker( 1284.8599853516, -1652.9304199219, 12.546875 , "cylinder", 7, 255, 153, 0, 0) 
local markers = { 
  
} 
local blib = createBlipAttachedTo ( gate, 23) 
local x,y,z = 0,0,0 
  
function open(thePlayer) 
    if isAdmin(thePlayer) == true then 
        moveObject ( gate, 3000, 1286.4000244141 , -1652.8000488281, 25) 
        outputChatBox ("Welcome To Admins Base", thePlayer, 255, 153, 0) 
    else 
        setPlayerWantedLevel(thePlayer,3) 
    end 
end 
addEventHandler( "onMarkerHit", marker, open ) 
  
function close(thePlayer) 
     
    if isAdmin(thePlayer) == true then 
        moveObject ( gate, 3000, 1286.4000244141 , -1652.8000488281, 15) 
    end 
  
end 
addEventHandler( "onMarkerLeave", marker, close ) 
  
function opengui(player) 
    if isPedInVehicle(player) == false then 
        mark = nil 
        for i,v in ipairs(markers) do 
            if markers[i][1] == source then 
                if getElementData(player, "Group") == markers[i][4] or markers[i][4] == "N/A" then 
                    mark = markers[i][2] 
                    splitted = split(markers[i][3],",") 
                    x,y,z = splitted[1],splitted[2],splitted[3] 
                    triggerClientEvent(player,"openGUI",getRootElement(), mark) 
                else 
                    outputChatBox(markers[i][4] .. " هذه الماركر فقط لقروب ",player,255,153,20,true) 
                end              
            end 
        end 
    end 
end 
  
function loadHandlers() 
  
    xml = xmlLoadFile("xml.xml") 
    for i,node in ipairs(xmlNodeGetChildren(xml)) do 
        x = xmlNodeGetAttribute(node, "x") 
        y = xmlNodeGetAttribute(node, "y") 
        z = xmlNodeGetAttribute(node, "z") 
        typee = xmlNodeGetAttribute(node, "type") 
        size = xmlNodeGetAttribute(node, "size") 
        r = xmlNodeGetAttribute(node, "r") 
        g = xmlNodeGetAttribute(node, "g") 
        b = xmlNodeGetAttribute(node, "b") 
        a = xmlNodeGetAttribute(node, "a") 
        ii = xmlNodeGetAttribute(node, "ids") 
        spawn = xmlNodeGetAttribute(node, "spawn") 
        group = xmlNodeGetAttribute(node, "group") 
        table.insert(markers, i , {createMarker(x,y,z,typee,size,r,g,b,a),ii,spawn,group} ) 
    end 
    xmlUnloadFile(xml) 
     
    setTimer( 
        function() 
            for i,v in ipairs(markers)do 
                addEventHandler( "onMarkerHit", v[1], opengui ) 
            end 
        end 
    ,500,1) 
     
end 
addEventHandler("onResourceStart",getResourceRootElement(getThisResource()),loadHandlers) 
  
function warp(player,id) 
    vehicle = createVehicle(id,x,y,z) 
    warpPlayerIntoVehicle(player,vehicle) 
end 
addEvent("warp",true) 
addEventHandler("warp",root,warp) 
  
function loging(_, account) 
    if isAdmin(source) then 
        setPlayerSkin(source, 163) 
    end 
end 
addEventHandler("onPlayerLogin",root,loging) 
  
function isAdmin(player) 
    acc = getPlayerAccount(player) 
    accountname = getAccountName(acc) 
    if not accountname then 
        return false 
    else     
        if isObjectInACLGroup("user."..accountname, aclGetGroup('Admin2')) or isObjectInACLGroup("user."..accountname, aclGetGroup('Console')) and not isGuestAccount(acc) then 
            return true 
        else 
            return false 
        end 
    end 
end 
  
function newMarker(pos,color,size,ids,pos2,group) 
    pos = split(pos, ",") 
    r,g,b,a = getColorFromString(color) 
    --table.insert(markers, #markers + 1 , { createMarker(pos[1], pos[2], pos[3]-1, "cylinder", size, r,g,b,a) , ids , pos2, group} ) 
    xml = xmlLoadFile("xml.xml") 
    if xml then  
        child = xmlCreateChild(xml,"marker") 
        xmlNodeSetAttribute(child, "x", pos[1]) 
        xmlNodeSetAttribute(child, "y", pos[2]) 
        xmlNodeSetAttribute(child, "z", pos[3]) 
        xmlNodeSetAttribute(child, "type", "cylinder") 
        xmlNodeSetAttribute(child, "size", size) 
        xmlNodeSetAttribute(child, "r", r) 
        xmlNodeSetAttribute(child, "g", g) 
        xmlNodeSetAttribute(child, "b", b) 
        xmlNodeSetAttribute(child, "a", a) 
        xmlNodeSetAttribute(child, "ids", ids) 
        xmlNodeSetAttribute(child, "spawn", pos2) 
        xmlNodeSetAttribute(child, "group", group) 
        xmlSaveFile(xml) 
    end 
    xmlUnloadFile(xml) 
    loadHandlers() 
end 
addEvent("newMarker" ,true) 
addEventHandler("newMarker", root,newMarker) 
  
function newmarkerrequest(playerSource) 
    if isAdmin(playerSource) then 
        triggerClientEvent(playerSource, "onMarkerRequest" , getRootElement()) 
    end 
end 
addCommandHandler("newcarmarkergtatime", newmarkerrequest) 
addEvent("newcarrquest",true) 
addEventHandler("newcarrquest",getRootElement(),newmarkerrequest) 
  
-- MANAGER 
  
addCommandHandler("m8rat", 
    function(player) 
        if isAdmin(player) then 
            triggerClientEvent(player, "showManagerWindow", player) 
        end 
    end 
) 
  
function saveall(markers_data) 
    for ii,vv in ipairs(markers)do 
        destroyElement(vv[1]) 
    end 
    markers = {} 
    xml = xmlLoadFile("xml.xml") 
    if xml then 
        for i,v in ipairs(xmlNodeGetChildren(xml))do 
            xmlDestroyNode(v) 
        end 
        for i,v in ipairs(markers_data)do 
            table.insert(markers,i,{createMarker(v[1],v[2],v[3],v[4],v[5],v[6],v[7],v[8],v[9]),v[10],v[11]..","..v[12]..","..v[13],v[14]} ) 
            child = xmlCreateChild(xml, "marker") 
            xmlNodeSetAttribute(child, "x", v[1]) 
            xmlNodeSetAttribute(child, "y", v[2]) 
            xmlNodeSetAttribute(child, "z", v[3]) 
            xmlNodeSetAttribute(child, "type", v[4]) 
            xmlNodeSetAttribute(child, "size", v[5]) 
            xmlNodeSetAttribute(child, "r", v[6]) 
            xmlNodeSetAttribute(child, "g", v[7]) 
            xmlNodeSetAttribute(child, "b", v[8]) 
            xmlNodeSetAttribute(child, "a", v[9]) 
            xmlNodeSetAttribute(child, "ids", v[10]) 
            xmlNodeSetAttribute(child, "spawn", v[11]..","..v[12]..","..v[13]) 
            xmlNodeSetAttribute(child, "group", v[14]) 
         
        end 
        xmlSaveFile(xml) 
    end 
    xmlUnloadFile(xml) 
     
     
    setTimer( 
    function() 
        for i,v in ipairs(markers)do 
            addEventHandler( "onMarkerHit", v[1], opengui ) 
        end 
    end 
    ,500,1) 
end 
addEvent("saveMarkersFromManager",true) 
addEventHandler("saveMarkersFromManager",getRootElement() , saveall) 
  
  
  

اذا شغلت المود يطلع في الكونسل

server.lua:70: Bad argument @ 'addEventHandler'

واذا رحت للماركر يجيني كذا

server.lua:30:Bad'ped' pointer @ 'isPedInVehicle'

+ كيف اخليه الشخص الي يروح للماركر ياخذ سياره وحده بس

اذا اخذ سياره ثانيه تنسحب الاولى

وثانكيو :$

ي عيال ساعدوني >< :cry::cry:

Link to comment

  
function opengui(player) 
  
 if getElementType( player ) == "player" then 
  
       if not isPedInVehicle(player) then return end 
  
  
  
        mark = nil 
  
  
  
        for i,v in ipairs(markers) do 
  
  
  
            if markers[i][1] == source then 
  
  
  
                if getElementData(player, "Group") == markers[i][4] or markers[i][4] == "N/A" then 
  
  
  
                    mark = markers[i][2] 
  
  
  
                    splitted = split(markers[i][3],",") 
  
  
  
                    x,y,z = splitted[1],splitted[2],splitted[3] 
  
  
  
                    triggerClientEvent(player,"openGUI",getRootElement(), mark) 
  
  
  
                else 
  
  
  
                    outputChatBox(markers[i][4] .. " هذه الماركر فقط لقروب ",player,255,153,20,true) 
  
  
  
                end              
  
  
  
            end 
  
  
  
        end 
  
  
  
    end 
  
end 
  

+

لين تبي يااخد سيارة وحده و بعدين اخد ثانية تنسحب الاولى

Event : "onMarkerHit" 
destroyElement 
getPedOccupiedVehicle  
createVehicle 
warpPedIntoVehicle 
  
Edited by Guest
Link to comment
  
        if ( player == localPlayer ) then 
-- + 
        triggerClientEvent(player,"openGUI",getRootElement(), mark) 

localPlayer --Client only 

شلون تسوي تريقر من كلاينت لكلاينت

ههههه مانتبهت ذذ

لاني كنت مستعجل

المهم تم التعديل :wink: ~

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