Jump to content

استفسار برمجة مود login penal


m7shsh07

Recommended Posts

السلام عليكم ورحمة الله وبركاته كيفكم شباب طيبين

طبعا انا مبتداء في البرمجة

وحبيت استفسر من الخبراء ونستفيد ونفيد المبتدائين الي مثلي

طبعا اخواني انا سويت لوحة تسجيل دخول يعني login penal

و سويت ملفين ملف سيرفر وملف كلينت طبعا الكلينت معروف

طيب سويت كل شي تقولون لي طيب وش فيه اقولكم كل ما اجي اشغل المود يشتغل معي اجي اسجل دخول ما يسجل دخول

الان بحط لكم اكواد السيرفر والكلينت طبعا مثل ما قلت لك مبتداء وابي اتعلم منكم

طبعا في السيرفر فيه اكواد جايبها من امثلة الويكي يعني لحد يضحك علي :(

ذا السيرفر

function logI ( player, account , Password ) 
local account = getAccount ( username, password ) 
if ( account ~= false ) then 
logIn ( player, account, password ) 
else 
outputChatBox ( "Wrong username or password! | خطاء في الاسم او الباسورد", thePlayer, 255, 255, 0 ) 
end 
end 
  
  
addEventHandler( "logIn", rootElement ,loginPlayer ) 
function reg ( adduser , addpass ) 
if ( password ~= "" and password ~= nil ) then 
local accountAdded = addAccount( getPlayerName(source), password ) 
if ( accountAdded ) then 
outputChatBox ( "Thank you|شكرا لك  " .. getPlayerName(source) .. ", you're now registed, you can login with /login | الان لقد اتممت التسجيل فضضلا اذهب لتسجيل الدخول", source ) 
        else 
        outputChatBox ( "Error creating account, contact the server admin | خطاء في صنع الحساب اذا لما تستطع صنع الحساب فل تتواصل مع الادمين ", source ) 
        end 
    else 
            outputChatBox ( "Error creating account", source ) 
    end 
end 
  
addEventHandler ( "register", roeotElemnt ,registerPlayer ) 

الكلينت

  
GUIEditor = { 
    label = {}, 
    button = {}, 
    window = {}, 
    scrollbar = {}, 
    memo = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(375, 163, 604, 407, "x~>|login penal by m7shsh07|<~x", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
  
        GUIEditor.label[1] = guiCreateLabel(255, 107, 240, 27, "user", false, GUIEditor.window[1]) 
        GUIEditor.memo[1] = guiCreateMemo(212, 144, 153, 34, "", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(255, 188, 255, 21, "pass", false, GUIEditor.window[1]) 
        GUIEditor.memo[2] = guiCreateMemo(208, 219, 160, 33, "", false, GUIEditor.window[1]) 
  
        GUIEditor.scrollbar[1] = guiCreateScrollBar(109, 34, 15, 15, false, false, GUIEditor.memo[2]) 
  
        GUIEditor.button[1] = guiCreateButton(168, 286, 87, 43, "login", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFB10000") 
        GUIEditor.button[2] = guiCreateButton(296, 288, 86, 41, "register", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF00B110") 
        GUIEditor.label[3] = guiCreateLabel(9, 380, 246, 23, "by m7shsh07 v1.0 fix", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[3], "default-bold-small") 
        guiLabelSetColor(GUIEditor.label[3], 55, 55, 55)     
    end 
) 
  
addEventHandler ("onClientGUIClick", getRootElement(), 
function () 
if source == GUIEditor.button[1] then 
logIn ( "logIn", true ) 
if source == GUIEditor.button[2] then 
registerPlayer ( "registerPlayer",true ) 
end  
end  
end 
) 
  
  
function show() 
guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) 
showCursor(guiGetVisible(GUIEditor.window[1])) 
end 
bindKey ("f1", "down", show) 
  

طبعا شباب اذا فيه خطاء في برط الازرار او في ملف السيرفر علموني لني مبتداء

واكيد من الموضوع هذا ظني ما راح يخيب فيكم

Link to comment

كودك صراحه هريسه

انت مسوي ميمو حق مود تسجيل و تسجيل دخول

المفروض تسوي ايدت

+

addEventHandler ("onClientGUIClick", getRootElement(), 
function () 
if source == GUIEditor.button[1] then 
logIn ( "logIn", true ) 
if source == GUIEditor.button[2] then 
registerPlayer ( "registerPlayer",true ) 
end 
end 
end 
) 

من وين جايبهم سطر 4 و 6

قصدي يعني ليه كتبتهم زي كذا ايش كان مصدر معلوماتك

+

كيف تجيب الأسم و الباس؟

ما اشوف الفنكشن هذا في كودك

guiGetText 

ينقل الى قسم البرمجة

Link to comment
كودك صراحه هريسه

انت مسوي ميمو حق مود تسجيل و تسجيل دخول

المفروض تسوي ايدت

+

addEventHandler ("onClientGUIClick", getRootElement(), 
function () 
if source == GUIEditor.button[1] then 
logIn ( "logIn", true ) 
if source == GUIEditor.button[2] then 
registerPlayer ( "registerPlayer",true ) 
end 
end 
end 
) 

من وين جايبهم سطر 4 و 6

قصدي يعني ليه كتبتهم زي كذا ايش كان مصدر معلوماتك

+

كيف تجيب الأسم و الباس؟

ما اشوف الفنكشن هذا في كودك

guiGetText 

ينقل الى قسم البرمجة

الحقيقه اخوي تابل انا سويت ميمو عشان يحط الالعب اسمه والباس لن اول شفت شرح من واحد اجنبي يسوي كذا

والسطر 6+4 فيه شرح في المنتدى ربط الزر وشفت امر حق الطيران بالسيارة الي موجود في الشرح فهمت من شرحه لازم كود وانا تعبت ولفيت كل الويكي عشان القاه

ما لقيت ف سويت الاكواد ذي اما كيف تجيب الاسم والباس وما اشوف الفنكشن هذا في كودك

guiGetText 

هذا الحقيقه ما اعرف وش فايدته واذا ماعليك امر ممكن تشرحلي وش فايدته

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

Link to comment
GUI هذا الفنكشن يجيب الكلام من الـ

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

guiGetText 

ماشاء الله تبارك الله الله عليك ي تابل والله مبدع كاعدتك ماشاء الله

بروح اجيب الكود وازبطه من جديد واجربه

( اخوي تابل وين اضعه الفنكشن في ملف السيرفر او في الكلينت )

Link to comment

أنا سويت لك الكود كامل

قارن الكود مع كودك و شوف الأخطاء

Client Side:

  
GUIEditor = { 
    label = {}, 
    button = {}, 
    window = {}, 
    edit = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(375, 163, 604, 407, "x~>|login penal by m7shsh07|<~x", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        showCursor(true) 
        GUIEditor.label[1] = guiCreateLabel(255, 107, 240, 27, "user", false, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(212, 144, 153, 34, "", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(255, 188, 255, 21, "pass", false, GUIEditor.window[1]) 
        GUIEditor.edit[2] = guiCreateEdit(208, 219, 160, 33, "", false, GUIEditor.window[1]) 
        GUIEditor.button[1] = guiCreateButton(168, 286, 87, 43, "login", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFB10000") 
        GUIEditor.button[2] = guiCreateButton(296, 288, 86, 41, "register", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF00B110") 
        GUIEditor.label[3] = guiCreateLabel(9, 380, 246, 23, "by m7shsh07 v1.0 fix", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[3], "default-bold-small") 
        guiLabelSetColor(GUIEditor.label[3], 55, 55, 55)     
    end 
) 
  
addEventHandler ("onClientGUIClick", getRootElement(), 
function() 
    local userName = guiGetText(GUIEditor.edit[1]) 
    local passWord = guiGetText(GUIEditor.edit[2]) 
    if userName ~= "" and passWord ~= "" then 
        if source == GUIEditor.button[1] then 
            triggerServerEvent("Login-Register", localPlayer, "Login", userName, passWord) 
        elseif source == GUIEditor.button[2] then 
            triggerServerEvent("Login-Register", localPlayer, "Register", userName, passWord) 
        end 
    end 
end) 
  
function show() 
    guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) 
    showCursor(guiGetVisible(GUIEditor.window[1])) 
end 
bindKey("f1", "down", show) 

Server Side:

addEvent("Login-Register", true) 
addEventHandler("Login-Register", root, 
function(action, userName, passWord) 
    if (action == "Login") then 
        local account = getAccount(userName, passWord) 
        if account then 
            logIn(source, account, passWord) 
        else 
            outputChatBox ("Wrong username or password! | خطاء في الاسم او الباسورد", source, 255, 255, 0) 
        end 
    elseif (action == "Register") then 
        if not getAccount(userName) then 
            local accountAdded = addAccount(userName, passWord) 
            if accountAdded then 
                outputChatBox("Thank you|شكرا لك "..getPlayerName(source)..", you're now registred, you can login with /login | الان لقد اتممت التسجيل فضضلا اذهب لتسجيل الدخول", source, 0, 255, 0) 
            else 
                outputChatBox("Error creating account, contact the server admin | خطاء في صنع الحساب اذا لما تستطع صنع الحساب فل تتواصل مع الادمين ", source, 255, 0, 0) 
            end 
        else 
            outputChatBox("اسم الحساب هذا مسجل من قبل", source, 255, 0, 0) 
        end 
    end 
end) 

ولا تنسى تضيفه في قروب ادمن

لان التسجيل يحتاج صلاحيات

Link to comment
أنا سويت لك الكود كامل

قارن الكود مع كودك و شوف الأخطاء

Client Side:

  
GUIEditor = { 
    label = {}, 
    button = {}, 
    window = {}, 
    edit = {} 
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        GUIEditor.window[1] = guiCreateWindow(375, 163, 604, 407, "x~>|login penal by m7shsh07|<~x", false) 
        guiWindowSetSizable(GUIEditor.window[1], false) 
        guiSetAlpha(GUIEditor.window[1], 1.00) 
        showCursor(true) 
        GUIEditor.label[1] = guiCreateLabel(255, 107, 240, 27, "user", false, GUIEditor.window[1]) 
        GUIEditor.edit[1] = guiCreateEdit(212, 144, 153, 34, "", false, GUIEditor.window[1]) 
        GUIEditor.label[2] = guiCreateLabel(255, 188, 255, 21, "pass", false, GUIEditor.window[1]) 
        GUIEditor.edit[2] = guiCreateEdit(208, 219, 160, 33, "", false, GUIEditor.window[1]) 
        GUIEditor.button[1] = guiCreateButton(168, 286, 87, 43, "login", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[1], "default-bold-small") 
        guiSetProperty(GUIEditor.button[1], "NormalTextColour", "FFB10000") 
        GUIEditor.button[2] = guiCreateButton(296, 288, 86, 41, "register", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.button[2], "default-bold-small") 
        guiSetProperty(GUIEditor.button[2], "NormalTextColour", "FF00B110") 
        GUIEditor.label[3] = guiCreateLabel(9, 380, 246, 23, "by m7shsh07 v1.0 fix", false, GUIEditor.window[1]) 
        guiSetFont(GUIEditor.label[3], "default-bold-small") 
        guiLabelSetColor(GUIEditor.label[3], 55, 55, 55)     
    end 
) 
  
addEventHandler ("onClientGUIClick", getRootElement(), 
function() 
    local userName = guiGetText(GUIEditor.edit[1]) 
    local passWord = guiGetText(GUIEditor.edit[2]) 
    if userName ~= "" and passWord ~= "" then 
        if source == GUIEditor.button[1] then 
            triggerServerEvent("Login-Register", localPlayer, "Login", userName, passWord) 
        elseif source == GUIEditor.button[2] then 
            triggerServerEvent("Login-Register", localPlayer, "Register", userName, passWord) 
        end 
    end 
end) 
  
function show() 
    guiSetVisible(GUIEditor.window[1], not guiGetVisible(GUIEditor.window[1])) 
    showCursor(guiGetVisible(GUIEditor.window[1])) 
end 
bindKey("f1", "down", show) 

Server Side:

addEvent("Login-Register", true) 
addEventHandler("Login-Register", root, 
function(action, userName, passWord) 
    if (action == "Login") then 
        local account = getAccount(userName, passWord) 
        if account then 
            logIn(source, account, passWord) 
        else 
            outputChatBox ("Wrong username or password! | خطاء في الاسم او الباسورد", source, 255, 255, 0) 
        end 
    elseif (action == "Register") then 
        if not getAccount(userName) then 
            local accountAdded = addAccount(userName, passWord) 
            if accountAdded then 
                outputChatBox("Thank you|شكرا لك "..getPlayerName(source)..", you're now registred, you can login with /login | الان لقد اتممت التسجيل فضضلا اذهب لتسجيل الدخول", source, 0, 255, 0) 
            else 
                outputChatBox("Error creating account, contact the server admin | خطاء في صنع الحساب اذا لما تستطع صنع الحساب فل تتواصل مع الادمين ", source, 255, 0, 0) 
            end 
        else 
            outputChatBox("اسم الحساب هذا مسجل من قبل", source, 255, 0, 0) 
        end 
    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...