Jump to content

كود بسيط


Recommended Posts

السلام عليكم شباب انا عندى معرض سيارات

عاوز الى يشترى من المعرض الفلوس تنسحب منه و تروح لـ شخص

ده اول طلب ليا يا راب ما تخذلونى

كلينت---

function putDown(wnd) 
    local sx,sy = guiGetScreenSize() 
    local w,h = guiGetSize(wnd,false) 
    local x,y = 0,(sy - h) 
    guiSetPosition(wnd,x,y,false) 
end 
  
function centerWindow(center_window) 
    local screenW,screenH=guiGetScreenSize() 
    local windowW,windowH=guiGetSize(center_window,false) 
    local x,y = (screenW-windowW)/2,(screenH-windowH)/2 
    guiSetPosition(center_window,x,y,false) 
end 
  
GUIEditor_Label = {} 
  
shop_wnd = guiCreateWindow(0.005,0.26,0.5375,0.5017,"معرض ماكس للسيارات",true) 
grid = guiCreateGridList(0.0209,0.0797,0.9558,0.598,true,shop_wnd) 
guiGridListSetSelectionMode(grid,1) 
guiGridListAddColumn(grid,"Cars",0.6) 
guiGridListAddColumn(grid,"Prize",0.3) 
guiSetFont(buy,"default-bold-small") 
take = guiCreateButton(0.2395,0.691,0.2093,0.1196,"استئجار",true,shop_wnd) 
guiSetFont(take,"default-bold-small") 
GUIEditor_Label[1] = guiCreateLabel(0.4512,0.6944,0.5209,0.113,"* الاستئجار لمده 15 دقيقه بـ 200 الف",true,shop_wnd) 
guiLabelSetColor(GUIEditor_Label[1],255,0,0) 
guiLabelSetVerticalAlign(GUIEditor_Label[1],"center") 
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"right",false) 
guiSetFont(GUIEditor_Label[1],"default-bold-small") 
ex = guiCreateButton(0.7698,0.8472,0.2093,0.1196,"خروج",true,shop_wnd) 
guiSetFont(ex,"default-bold-small") 
guiSetVisible(shop_wnd,false) 
putDown(shop_wnd) 
  
cars = { 
    {"Jester== السعر 70 مليون",602,70000000}, 
    {"بي آآم  == السعر 45 مليون",546,45000000}, 
    {"جيب شروكى == السعر 28 مليون",400,28000000}, 
    {"كامرو == السعر 24 مليون",558,24000000}, 
    {"إلنترا == السعر 16 مليون",587,15000000}, 
  
} 
  
for i,car in ipairs(cars) do 
    local row = guiGridListAddRow(grid) 
    guiGridListSetItemText(grid,row,1,car[1],false,false) 
    guiGridListSetItemText(grid,row,2,car[3],false,false) 
    guiGridListSetItemData(grid,row,1,car[2]) 
end 
  
addEvent("putPlayerInShop",true) 
addEventHandler("putPlayerInShop",root, 
    function () 
        guiSetVisible(shop_wnd,true) 
        showCursor(true) 
        setElementFrozen(localPlayer,true) 
        setCameraMatrix(-2432.4516601563,1043.5134277344,53.729694366455,-2432.4516601563,1043.5134277344,53.729694366455) 
        veh = createVehicle(cars[1][2],-2444.2944335938,1035.7518310547,49.979347229004) 
    end 
) 
  
addEventHandler("onClientGUIClick",root, 
    function () 
        if source == ex then 
            guiSetVisible(shop_wnd,false) 
            showCursor(false) 
            destroyElement(veh) 
            setCameraTarget(localPlayer) 
            setElementFrozen(localPlayer,false) 
        end 
    end 
) 
  
addEventHandler("onClientGUIClick",grid, 
    function () 
        local sel = guiGridListGetSelectedItem(source) 
        if sel ~= -1 then 
            local id = tonumber(guiGridListGetItemData(grid,sel,1)) 
            setElementModel(veh,id) 
        end 
    end 
,false) 
  
function BACK() 
    setCameraTarget(localPlayer) 
    destroyElement(veh) 
    guiSetVisible(shop_wnd,false) 
    showCursor(false) 
    setElementFrozen(localPlayer,false) 
end 
  
addEventHandler("onClientGUIClick",root, 
    function () 
        local sel = guiGridListGetSelectedItem(grid) 
        if source == buy then 
            if sel ~= -1 then 
                triggerServerEvent("onBuyCar",localPlayer,guiGridListGetItemText(grid,sel,1),guiGridListGetItemText(grid,sel,2),guiGridListGetItemData(grid,sel,1)) 
            else 
                outputChatBox("* Choose A Car To Buy It",255,0,0) 
            end 
        elseif source == take then 
            if sel ~= -1 then 
                if getPlayerMoney(localPlayer) >= 100000 then 
                    triggerServerEvent("onTakeCar",localPlayer,guiGridListGetItemData(grid,sel,1)) 
                    BACK() 
                else 
                    outputChatBox("* You Don't Have Enough Money",255,0,0) 
                end 
            else 
                outputChatBox("* Choose A Car To Take It",255,0,0) 
            end 
        end 
    end 
) 
  
addEvent("back",true) 
addEventHandler("back",root, 
    function () 
        BACK() 
    end 
) 
  
  
tw = guiCreateWindow(0.3212,0.2683,0.3187,0.19,"هل تريد تجديد الايجار ؟",true) 
yes = guiCreateButton(0.0353,0.2105,0.9294,0.3246,"نعم",true,tw) 
guiSetFont(yes,"default-bold-small") 
no = guiCreateButton(0.0353,0.5702,0.9294,0.3246,"لا",true,tw) 
guiSetFont(no,"default-bold-small") 
guiSetVisible(tw,false) 
centerWindow(tw) 
  
addEvent("onCheckCar",true) 
addEventHandler("onCheckCar",root, 
    function () 
        guiSetVisible(tw,true) 
        showCursor(true) 
        guiSetInputEnabled(true) 
    end 
) 
  
addEventHandler("onClientGUIClick",root, 
    function () 
        if source == yes then 
            triggerServerEvent("onYes",localPlayer) 
            guiSetVisible(tw,false) 
            showCursor(false) 
            guiSetInputEnabled(false) 
        elseif source == no then 
            triggerServerEvent("onNo",localPlayer) 
            guiSetVisible(tw,false) 
            showCursor(false) 
            guiSetInputEnabled(false) 
        end 
    end 
) 
  

سيرفر--

Marker = createMarker(-2429.1154785156,1037.6608886719,50.390625,"cylinder",1.5,255,0,0) 
createBlipAttachedTo(Marker,55) 
tc = {} 
tt = {} 
  
addEventHandler("onMarkerHit",Marker, 
    function (player) 
        if getElementType(player) == "player" and not isPedInVehicle(player) then 
            triggerClientEvent(player,"putPlayerInShop",player) 
        end 
    end 
) 
  
if sendPlayerMoney (mido) (localPlayer) 
  
addEvent("onBuyCar",true) 
addEventHandler("onBuyCar",root, 
    function (name,money,id) 
        if not isGuestAccount(getPlayerAccount(source)) then 
            if getPlayerMoney(source) >= tonumber(money) then    
                takePlayerMoney(source,money) 
                givePlayerCar(source,name,id,money) 
                outputChatBox("* You Have Bought " .. name .. " For " .. money,source,0,255,0) 
                triggerClientEvent(source,"back",source) 
            else 
                outputChatBox("* You Don't Have Enough Money",source,255,0,0) 
            end 
        else 
            outputChatBox("* You Are Not Logged In",source,255,0,0) 
        end 
    end 
) 
  
addEvent("onTakeCar",true) 
addEventHandler("onTakeCar",root, 
    function (id) 
        if isElement(tc[source]) then destroyElement(tc[source]) end 
        if isTimer(tt[source]) then killTimer(tt[source]) end 
        takePlayerMoney(source,100000) 
        tc[source] = createVehicle(tonumber(id),-2444.2944335938,1035.7518310547,49.979347229004) 
        warpPedIntoVehicle(source,tc[source]) 
        tt[source] = setTimer(TJDED,15 * 60000,1,source) 
        outputChatBox("* You Have 15 Min",source,0,255,0) 
    end 
) 
  
function TJDED(player) 
    if isElement(player) and isElement(tc[player]) then 
        triggerClientEvent(player,"onCheckCar",player) 
    end 
end 
  
addEvent("onYes",true) 
addEventHandler("onYes",root, 
    function () 
        fixVehicle(tc[source]) 
        tt[source] = setTimer(TJDED,15 * 60000,1,source) 
        outputChatBox("* You Have Been Renewed Your Rent",source,0,255,0) 
    end 
) 
  
addEvent("onNo",true) 
addEventHandler("onNo",root, 
    function () 
        destroyElement(tc[source]) 
    end 
) 
Link to comment

    Marker = createMarker(-2429.1154785156,1037.6608886719,50.390625,"cylinder",1.5,255,0,0) 
    createBlipAttachedTo(Marker,55) 
    tc = {} 
    tt = {} 
      
    addEventHandler("onMarkerHit",Marker, 
        function (player) 
            if getElementType(player) == "player" and not isPedInVehicle(player) then 
                triggerClientEvent(player,"putPlayerInShop",player) 
            end 
        end 
    ) 
      
    addEvent("onBuyCar",true) 
    addEventHandler("onBuyCar",root, 
        function (name,money,id) 
            if not isGuestAccount(getPlayerAccount(source)) then 
                if getPlayerMoney(source) >= tonumber(money) then    
                    takePlayerMoney(source,money) 
                    for _,v in ipairs (getElementsByType ("player")) do 
                    if getPlayerSerial (v) == "Your serial" then 
                    givePlayerMoney (v, money) 
                    break 
                    end 
                    end 
                    givePlayerCar(source,name,id,money) 
                    outputChatBox("* You Have Bought " .. name .. " For " .. money,source,0,255,0) 
                    triggerClientEvent(source,"back",source) 
                else 
                    outputChatBox("* You Don't Have Enough Money",source,255,0,0) 
                end 
            else 
                outputChatBox("* You Are Not Logged In",source,255,0,0) 
            end 
        end 
    ) 
      
    addEvent("onTakeCar",true) 
    addEventHandler("onTakeCar",root, 
        function (id) 
            if isElement(tc[source]) then destroyElement(tc[source]) end 
            if isTimer(tt[source]) then killTimer(tt[source]) end 
            takePlayerMoney(source,100000) 
            tc[source] = createVehicle(tonumber(id),-2444.2944335938,1035.7518310547,49.979347229004) 
            warpPedIntoVehicle(source,tc[source]) 
            tt[source] = setTimer(TJDED,15 * 60000,1,source) 
            outputChatBox("* You Have 15 Min",source,0,255,0) 
        end 
    ) 
      
    function TJDED(player) 
        if isElement(player) and isElement(tc[player]) then 
            triggerClientEvent(player,"onCheckCar",player) 
        end 
    end 
      
    addEvent("onYes",true) 
    addEventHandler("onYes",root, 
        function () 
            fixVehicle(tc[source]) 
            tt[source] = setTimer(TJDED,15 * 60000,1,source) 
            outputChatBox("* You Have Been Renewed Your Rent",source,0,255,0) 
        end 
    ) 
      
    addEvent("onNo",true) 
    addEventHandler("onNo",root, 
        function () 
            destroyElement(tc[source]) 
        end 
    ) 

اول شي السطر 14 ؟؟

وش ذا ؟؟

ما له داعي في الكود

ثاني شي

التعديل يكون في السطر 21

تحط فيه السريال

وأي واحد يشتري سياره

الفلوس راح تروح على سريال الاعب

الي انت حطيت سرياله

Link to comment

البريك يا زاحف يوقف اللوب

لأني مسوي

يجيب كل الاعبين ويتحقق منهم ع حسب السريال

واذا لقا السريال يعطيه فلوس

ويوقف اللوب

لاكن لو ما حطينا بريك

راح يكرر اول شي عدد الفلوس على عدد الاعبين

عشان كذا حطيت بريك

يعني لو كان الاعبين 5 مثلا

راح يعطي الاعب فلوس 5 مرات

Link to comment
البريك يا زاحف يوقف اللوب

لأني مسوي

يجيب كل الاعبين ويتحقق منهم ع حسب السريال

واذا لقا السريال يعطيه فلوس

ويوقف اللوب

لاكن لو ما حطينا بريك

راح يكرر اول شي عدد الفلوس على عدد الاعبين

عشان كذا حطيت بريك

يعني لو كان الاعبين 5 مثلا

راح يعطي الاعب فلوس 5 مرات

اها .. ما انتبهت للتحقق من السريال !

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