Jump to content

When Click in Gridlist open window


BigDaddy

Recommended Posts

hi guys ,

i want to make report like this

niriU6.png

if anyone write subject in edit and text in the memo

and click send like then

the subject put in gridlist and when anyone click open and select subject name in the

gridlist he open to him window and put in the edit the subject and text in the memo

that who write it when he send like this :

mcHeQl.png

Edited by Guest
Link to comment

i make it but there is error in insert

when i write in subject edit

Test and then click button send

debugscript say to me :

ERROR: Test\server.lua:15: Database query failed: no such table: 'Test' 

addEventHandler("onClientGUIClick",root, 
function() 
if ( source == Send ) then 
local tSubject = guiGetText(SendSubject) 
local tMeMo = guiGetText(SendMemo) 
local tPlrName = getPlayerName(localPlayer) 
if (tSubject and tSubject ~= "" or tSubject ~= " " and tMeMo ~= "" or tMeMo ~=" ") then 
triggerServerEvent("INSERT",localPlayer,tPlrName,tSubject,tMeMo) 
              end 
          end 
     end 
) 

addEventHandler("onResourceStart",resourceRoot, 
function() 
local AllReports = executeSQLQuery ('CREATE TABLE IF NOT EXISTS  `AllReports` ( PlrName , Subject ) ') 
if ( AllReports ) then 
outputDebugString("Sucsesfully Create SQL Table 'AllReports'") 
end 
end 
) 
addEvent("INSERT",true) 
addEventHandler("INSERT",root, 
    function ( PlrName , tSubject , tMemo ) 
        executeSQLQuery("CREATE TABLE IF NOT EXISTS '".. tSubject .."' (PlayerName,Subject,Memo)") 
        outputDebugString("Sucsesfully Create SQL Table Name : ".. tSubject .."") 
        executeSQLQuery ( "INSERT INTO `AllReports` ( PlrName , Subject ) VALUES(?,?)",PlrName,tSubject) 
        executeSQLQuery ( "INSERT INTO `'".. tSubject .."'` ( PlayerName,Subject,Memo ) VALUES(?,?,?)",PlrName,tSubject,tMemo) 
        outputChatBox("#FFF000Sucsesfully Send Report [ #00FF00".. tSubject .."#FFF000 ] To Servre Owner",source,255,255,255,true) 
end 
) 
Link to comment
addEventHandler("onClientGUIClick", root, 
function() 
    if source == Send then 
        local tSubject = guiGetText(SendSubject) 
        local tMeMo = guiGetText(SendMemo) 
        local tPlrName = getPlayerName(localPlayer) 
        if tSubject ~= "" and tSubject ~= " " and tMeMo ~= "" and tMeMo ~=" " then 
            triggerServerEvent("INSERT", localPlayer, tPlrName, tSubject, tMeMo) 
        end 
    end 
end) 

addEventHandler("onResourceStart", resourceRoot, 
function() 
    local AllReports = executeSQLQuery("CREATE TABLE IF NOT EXISTS AllReports (PlrName, Subject, Memo)") 
    if AllReports then 
        outputDebugString("Sucsesfully Create SQL Table 'AllReports'") 
    end 
end) 
  
addEvent("INSERT",true) 
addEventHandler("INSERT", root, 
function(PlrName, tSubject, tMemo) 
    executeSQLQuery("INSERT INTO AllReports VALUES (?, ?, ?)", PlrName, tSubject, tMemo) 
    outputChatBox("#FFF000Sucsesfully Send Report [ #00FF00"..tSubject.."#FFF000 ] To Servre Owner", source, 255, 255, 255, true) 
end) 

Link to comment

Debugscript :

ERROR: MyTestMode\server.lua:12: Database query failed: table AllReports has no column named Memo 

My Code :

addEventHandler("onResourceStart", resourceRoot, 
function() 
    local AllReports = executeSQLQuery("CREATE TABLE IF NOT EXISTS AllReports (PlrName, Subject, Memo)") 
    if AllReports then 
        outputDebugString("Sucsesfully Create SQL Table 'AllReports'") 
    end 
end) 
  
addEvent("INSERT",true) 
addEventHandler("INSERT", root, 
function(PlrName, tSubject, tMemo) 
    executeSQLQuery("INSERT INTO AllReports (PlrName , Subject , Memo) VALUES (?, ?, ?)", PlrName, tSubject, tMemo) 
    outputChatBox("#FFF000Sucsesfully Send Report [ #00FF00"..tSubject.."#FFF000 ] To Servre Owner", source, 255, 255, 255, true) 
end) 
Link to comment
addEventHandler("onResourceStart", resourceRoot, 
function() 
    local AllReports = executeSQLQuery("CREATE TABLE IF NOT EXISTS AllReport (PlrName, Subject, Memo)") 
    if AllReports then 
        outputDebugString("Sucsesfully Create SQL Table 'AllReport'") 
    end 
end) 
  
addEvent("INSERT",true) 
addEventHandler("INSERT", root, 
function(PlrName, tSubject, tMemo) 
    executeSQLQuery("INSERT INTO AllReport VALUES (?, ?, ?)", PlrName, tSubject, tMemo) 
    outputChatBox("#FFF000Sucsesfully Send Report [ #00FF00"..tSubject.."#FFF000 ] To Servre Owner", source, 255, 255, 255, true) 
end) 

Link to comment

thank you TAPL :)

can i create table sql with name that i write it in edit ?

i mean like this

addEventHandler("onClientGUIClick",root, 
function() 
if ( source == Create ) then 
triggerServerEvent("CreateTable",localPlayer,guiGetText(Edit)) 
end 
end 
) 

addEvent("CreateTable",true) 
addEventHandler("CreateTable",root, 
function(Name) 
      executeSQLQuery("CREATE TABLE IF NOT EXISTS '".. Name .."' (PlayerAccount,PlayerName,Rank)") 
end 
) 
Link to comment

because i want to make clan system like group system

  
addEventHandler("onClientGUIClick",root, 
function() 
if ( source == Create ) then 
if ( guiGetText(EditClanNameToCreate) ~= "" or guiGetText(EditClanNameToCreate) ~= " ") then 
triggerServerEvent("Create",localPlayer,guiGetText(EditClanNameToCreate)) 
end 
end 
end 
) 
  
addEventHandler("onResourceStart",resourceRoot, 
function() 
local AllClansTable = executeSQLQuery ('CREATE TABLE IF NOT EXISTS  `AllClansTable` ( ClanName,Members) ') 
if ( AllClansTable ) then 
outputDebugString("Sucsesfully Create SQL Table AllClansTable") 
local CheckWhenLogin = executeSQLQuery("CREATE TABLE IF NOT EXISTS 'CheckHaveClan?' (Account,ClanName)") 
if ( CheckWhenLogin ) then 
outputDebugString("Sucsesfully Create SQL Table CheckHaveClan? !") 
end 
end 
end 
) 
  
addEvent("Create",true) 
addEventHandler("Create",root, 
    function ( ClanName ) 
    local Results = executeSQLQuery("SELECT * FROM `AllClansTable` WHERE ClanName=?",ClanName) 
     if ( type ( Results ) == "table" and #Results == 0 or not Results ) then  
     local TonumberMembers = 1 
      executeSQLQuery("CREATE TABLE IF NOT EXISTS '".. ClanName .."' (PlayerAccount,PlayerName,Rank)") 
        outputDebugString("Sucsesfully Create SQL Table Name : ".. ClanName .."") 
        executeSQLQuery ( "INSERT INTO `AllClansTable` ( ClanName , Members ) VALUES(?,?)",ClanName,tonumber(TonumberMembers)) 
        executeSQLQuery ( "INSERT INTO `'".. ClanName .."'` ( PlayerAccount,PlayerName,Rank ) VALUES(?,?,?)",getPlayerAccount(source),getPlayerName(source),"Clan Leader") 
        executeSQLQuery ( "INSERT INTO `CheckHaveClan?` ( Account , ClanName ) VALUES(?,?)",getPlayerAccount(source),ClanName) 
        setAccountData(getPlayerAccount(source),"HaveClan",true) 
        setAccountData(getPlayerAccount(source),"Leader",true) 
        outputChatBox("#FFF000Sucsesfully Created Clan [ #00FF00".. ClanName .."#FFF000 ]",source,255,255,255,true) 
        else 
        outputChatBox("*ERROR : THIS CLAN NAME IS ALREADY EXISTS !",source,255,0,0,true) 
end 
end 
) 
  
addEventHandler("onPlayerLogin",root, 
function(_,acc) 
if ( getAccountData(acc,"HaveClan",true) ) then 
local CheckResults = executeSQLQuery("SELECT * FROM `CheckHaveClan?` WHERE Account=?",getAccountName(acc)) 
     if ( type ( CheckResults ) == "table" and #CheckResults ~= 0 or CheckResults ) then 
     setElementData(source,"ClanName","".. CheckResults[1]['ClanName'] .."") 
     setElementData(source,"SendToClientHaveClan!",true) 
         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...