Jump to content

Functions


Recommended Posts

السلام عليكم

شباب انا سويت لوحة تسجيل

ابي انه الواحد يسوي بس حسابين

وكيف احفظ الحسابين بملف ميتا عشان اقدر اغيرهن متى ما ابي ويا ريت مثال لانه مرة جربت وما ضبط

والسلام خير ختام

Link to comment

هذا مثال بسيط وانت طبقه ع كودكـ .. لو في اي شي ما فهمته تفضل اسال :

addEventHandler ( "onResourceStart", resourceRoot, function (  ) 
    executeSQLQuery ( "CREATE TABLE IF NOT EXISTS moneySystem ( pSerial, AccountsCount )" ) 
end ) 
  
  
addEventHandler ( "onPlayerLogin", root, function (  )  
    local lCheck = executeSQLQuery ( "SELECT AccountsCount FROM moneySystem WHERE pSerial=?", getPlayerSerial ( source ) ) 
    if ( #lCheck <= 0 ) then 
      executeSQLQuery ( "INSERT INTO moneySystem ( pSerial, AccountsCount ) VALUES(?,?)", getPlayerSerial ( source ), 0 ) 
  end 
end ) 
  
addCommandHandler ( "giveMeMoney", function ( player ) 
   local sCheck = executeSQLQuery ( "SELECT AccountsCount FROM moneySystem WHERE pSerial=?", getPlayerSerial ( player ) ) 
    if ( #sCheck > 0 ) then 
     if ( tonumber ( sCheck[1].AccountsCount ) == 2 ) then 
          outputChatBox ( "You already took money for 2 times" ) 
     else 
          givePlayerMoney ( player, 2000 ) 
          executeSQLQuery ( "UPDATE moneySystem SET AccountsCount=? WHERE pSerial=?", tonumber ( sCheck[1].AccountsCount ) + 1, getPlayerSerial ( player ) )   
    end 
  end 
end ) 
Link to comment
addEventHandler ( "onResourceStart", resourceRoot, function (  ) 
    executeSQLQuery ( "CREATE TABLE IF NOT EXISTS Accounts ( playerSerial, playerAccounts )" ) 
end ) 
  
  
function registerPlayer () 
 local lCheck = executeSQLQuery ( "SELECT AccountsCount FROM Accounts WHERE playerSerial=?", getPlayerSerial ( source ) ) 
    if ( #lCheck <= 2 ) then 
      executeSQLQuery ( "INSERT INTO Accounts ( playerSerial, playerAccounts ) VALUES(?,?)", getPlayerSerial ( source ), +1 ) 
      addEvent ( "CanRegister", true ) 
      else 
            outputChatBox ("You Can Make Just 2 Accounts",source,255,255,255,true) 
  end 
  
  
  
  
addEvent("onRequestRegister",true) 
addEventHandler("onRequestRegister",getRootElement(),registerPlayer) 

كذا ؟؟؟

Link to comment

عندك اند ناقص

مدري لو في غلط اخر لكن ذا يلي شفته

هنا

function registerPlayer () -<<<<<<<<<<<<<<<<<<<<<<< 
 local lCheck = executeSQLQuery ( "SELECT AccountsCount FROM Accounts WHERE playerSerial=?", getPlayerSerial ( source ) ) 
    if ( #lCheck <= 2 ) then   ---<<<<<<<<<<<< 
      executeSQLQuery ( "INSERT INTO Accounts ( playerSerial, playerAccounts ) VALUES(?,?)", getPlayerSerial ( source ), +1 ) 
      addEvent ( "CanRegister", true ) 
      else 
            outputChatBox ("You Can Make Just 2 Accounts",source,255,255,255,true) 
  end 

Link to comment

addEventHandler ( "onResourceStart", resourceRoot, function (  ) 
    executeSQLQuery ( "CREATE TABLE IF NOT EXISTS AccountsMax ( playerSerial, playerAccounts )" ) 
end ) 
  
  
function registerPlayer (  ) 
  local lCheck = executeSQLQuery ( "SELECT playerAccounts FROM AccountsMax WHERE playerSerial=?", getPlayerSerial ( source ) ) 
  if ( #lCheck == 0 ) then 
       executeSQLQuery ( "INSERT INTO AccountsMax ( playerSerial, playerAccounts ) VALUES(?,?)", getPlayerSerial ( source ), 1 ) 
       addEvent ( "CanRegister", true ) 
  else 
       if ( tonumber ( lCheck[1].playerAccounts ) == 2 ) then 
          outputChatBox ( "You Can Make Just 2 Accounts", source, 255, 255,255,true) 
    else   
          addEvent ( "CanRegister", true ) 
          executeSQLQuery ( "UPDATE AccountsMax SET playerAccounts=? WHERE playerSerial=?", tonumber ( lCheck[1].playerAccounts ) + 1, getPlayerSerial ( source ) )   
    end  
  end 
end   
addEvent ( "onRequestRegister", true ) 
addEventHandler ( "onRequestRegister", root, registerPlayer ) 
Link to comment
addEventHandler ( "onResourceStart", resourceRoot, function (  ) 
    executeSQLQuery ( "CREATE TABLE IF NOT EXISTS AccountsMax ( playerSerial, playerAccounts )" ) 
end ) 
  
  
function regg ( username,password ) 
registerPlayer (username,password)  
  local lCheck = executeSQLQuery ( "SELECT playerAccounts FROM AccountsMax WHERE playerSerial=?", getPlayerSerial ( source ) ) 
  if ( #lCheck == 0 ) then 
setElementData ( source, "CanRegister", "Yes") 
  else 
       if ( tonumber ( lCheck[1].playerAccounts ) == 2 ) then 
          setElementData ( source, "CanRegister", "No") 
    else   
setElementData ( source, "CanRegister", "Yes") 
    end  
  end 
end   
addEvent("reg",true) 
addEventHandler("reg",getRootElement(),regg) 
  
  
function registerPlayer (username,password)  
local get = getElementData ( source, "CanRegister" ) 
        if ( get ) == "Yes" then 
    if not (username == "") then 
        if not (password == "") then 
                    local account = getAccount (username,password) 
                    if (account == false) then 
                        local accountAdded = addAccount(tostring(username),tostring(password)) 
                        if (accountAdded) then 
                            outputChatBox ("#FF0000* #FFFFFFYou have sucessfuly registered! [username: #ABCDEF" .. username .. " #FF0000| #FFFFFFPassword: #ABCDEF" .. password .. "#FFFFFF]",source,255,255,255,true ) 
                            setTimer(outputChatBox,800,1,"#FF0000* #FFFFFFYou can now login with your new account.",source,255,255,255,true ) 
                        else 
                            outputChatBox ("#FF0000* #FFFFFFAn unknown error has occured! Please choose a different username/password and try again.",source,255,255,255,true ) 
                        end 
                    else 
                        outputChatBox ("#FF0000* #FFFFFFError! An account with this username already exists!",source,255,255,255,true ) 
                    end 
        else 
            outputChatBox ("#FF0000* #FFFFFFError! Please enter a password!",source,255,255,255,true) 
        end 
    else 
        outputChatBox ("#FF0000* #FFFFFFError! Please enter a username you would like to register with!",source,255,255,255,true) 
    end 
     
end 
end 
  

صح اني غلبتكم بس وش مشكلة ذا

Link to comment

addEventHandler ( "onResourceStart", resourceRoot, function (  ) 
    executeSQLQuery ( "CREATE TABLE IF NOT EXISTS AccountsMax ( playerSerial, playerAccounts )" ) 
end ) 
  
  
function registerPlayer ( username, password ) 
  local lCheck = executeSQLQuery ( "SELECT playerAccounts FROM AccountsMax WHERE playerSerial=?", getPlayerSerial ( source ) ) 
  if ( #lCheck == 0 ) then 
       executeSQLQuery ( "INSERT INTO AccountsMax ( playerSerial, playerAccounts ) VALUES(?,?)", getPlayerSerial ( source ), 1 ) 
       registerPlayer ( source, username, password ) 
  else 
       if ( tonumber ( lCheck[1].playerAccounts ) == 2 ) then 
          outputChatBox ( "You Can Make Just 2 Accounts", source, 255, 255,255,true) 
    else   
          registerPlayer ( source, username, password ) 
          executeSQLQuery ( "UPDATE AccountsMax SET playerAccounts=? WHERE playerSerial=?", tonumber ( lCheck[1].playerAccounts ) + 1, getPlayerSerial ( source ) )   
    end  
  end 
end   
addEvent ( "onRequestRegister", true ) 
addEventHandler ( "onRequestRegister", root, registerPlayer ) 
  
function registerPlayer ( element, username, password ) 
    if not ( username == "" ) then 
        if not ( password == "" ) then 
           local account = getAccount (username,password) 
            if ( account == false ) then 
                local accountAdded = addAccount(tostring(username),tostring(password)) 
              if ( accountAdded ) then 
                      outputChatBox ("#FF0000* #FFFFFFYou have sucessfuly registered! [username: #ABCDEF" .. username .. " #FF0000| #FFFFFFPassword: #ABCDEF" .. password .. "#FFFFFF]",element,255,255,255,true ) 
                      setTimer(outputChatBox,800,1,"#FF0000* #FFFFFFYou can now login with your new account.",element,255,255,255,true ) 
                else 
                       outputChatBox ("#FF0000* #FFFFFFAn unknown error has occured! Please choose a different username/password and try again.",element,255,255,255,true ) 
                   end 
              else 
               outputChatBox ("#FF0000* #FFFFFFError! An account with this username already exists!",element,255,255,255,true ) 
           end 
        else 
            outputChatBox ("#FF0000* #FFFFFFError! Please enter a password!",element,255,255,255,true) 
        end 
    else 
        outputChatBox ("#FF0000* #FFFFFFError! Please enter a username you would like to register with!",element,255,255,255,true) 
    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...