mjau Posted March 4, 2012 Share Posted March 4, 2012 Hi how does executeSQLUpdate work ? function newClothes(acc, clothes) if executeSQLUpdate(acc, "clothes = 'clothes'") == true then return true else return false end end i trigger that function with agument for the clothes i wana set, wil that do it im just wondering since the variable is in a string on executeSQLUpdate function btw the table is right i have made a table for every acc in server Link to comment
Castillo Posted March 4, 2012 Share Posted March 4, 2012 function newClothes(acc, clothes) return executeSQLUpdate("clothes", "clothes = '".. clothes .."'", "acc = '".. acc .."'" ) end Link to comment
mjau Posted March 4, 2012 Author Share Posted March 4, 2012 Eh solidsnake every player whp logs in gets a table created with their acc name so acc would be right as argument for tablename i think function createPrivateSQLTableOnJoin(prevAcc, currentAcc) local accName = getAccountName(currentAcc) executeSQLCreateTable(accName, "bankMoney, clothes") end addEventHandler("onPlayerLogin", rootElement, createPrivateSQLTableOnJoin) function getCurrentClothes(acc) clothes = executeSQLSelect(acc, "clothes") return clothes end function newClothes(acc, clothes) if executeSQLUpdate(acc, "clothes = '"..clothes.."'") == true then return true else return false end end would this be right ? Link to comment
Castillo Posted March 4, 2012 Share Posted March 4, 2012 I guess so, but why you create a table for each player? Link to comment
mjau Posted March 4, 2012 Author Share Posted March 4, 2012 really idk... new to SQL scripting and found it the easiest way Link to comment
Kenix Posted March 4, 2012 Share Posted March 4, 2012 Not tested. function getCurrentClothes( uPlayer ) if isElement( uPlayer ) then local uAccount = getPlayerAccount( uPlayer ) if uAccount and not isGuestAccount( uAccount ) then local sAccount = getAccountName( uAccount ) local tClothes = { } for i = 0,12 do local tResult = executeSQLQuery( "SELECT * FROM clothes WHERE user = '" .. sAccount .. "'" ) if tResult and #tResult > 0 then table.insert( tClothes, { tResult[i].txd, tResult[i].model } ) end end return tClothes end return false end return false end function updateClothes( uPlayer, txd, model ) if isElement( uPlayer ) and type( txd ) == 'string' and type( model ) == 'string' then local uAccount = getPlayerAccount( uPlayer ) if uAccount and not isGuestAccount( uAccount ) then local sAccount = getAccountName( uAccount ) for i = 0,12 do local tRequest = executeSQLQuery( "SELECT * FROM clothes WHERE user = '" .. sAccount .. "'" ) if tRequest and #tRequest > 0 then executeSQLQuery( "UPDATE clothes SET txd = '" .. txd .. "', model = '" .. model .. "' WHERE user = '" .. sAccount .. "'" ) end end return true end return false end return false end addEventHandler( 'onResourceStart', resourceRoot, function( ) executeSQLQuery 'CREATE TABLE IF NOT EXISTS clothes ( user TEXT, txd TEXT, model TEXT )' end ) addEventHandler( 'onPlayerLogin', root, function( _, uAccount ) local tRequest = executeSQLQuery( "SELECT * FROM clothes WHERE user = '" .. getAccountName( uAccount ) .. "'" ) if tRequest and #tRequest > 0 then for i = 0,17 do if tRequest[i].txd and tRequest[i].model then addPedClothes( source, tRequest[i].txd, tRequest[i].model, i ) end end end end ) addEventHandler( 'onPlayerQuit', root, function( ) local uAccount = getPlayerAccount( source ) if uAccount and not isGuestAccount( uAccount ) then local sAccount = getAccountName( uAccount ) for i = 0,17 do local tRequest = executeSQLQuery( "SELECT * FROM clothes WHERE user = '" .. sAccount .. "'" ) local sTxd,sModel = getPedClothes( source, i ) if sTxd and sModel then if tRequest and #tRequest > 0 then executeSQLQuery( "UPDATE clothes SET txd = '" .. txd .. "', model = '" .. model .. "' WHERE user = '" .. sAccount .. "'" ) else executeSQLQuery( "INSERT INTO clothes VALUES ( '" .. sAccount .. "', '" .. txd .. "', '" .. model .. "')" ) end end end end end ) Link to comment
mjau Posted March 4, 2012 Author Share Posted March 4, 2012 oh i think u misunderstood i just meant saving skin i call them clothes since im scripting a clothes shop(skin shop) Link to comment
mjau Posted March 4, 2012 Author Share Posted March 4, 2012 if i store a number in SQL and iw ant to add example 100 to it like 0 + 100 would this thing below work ? executeSQLUpdate("players", "test + '"..testnumberVariable.."'", "accName = '"..accountName.."'") Link to comment
Castillo Posted March 4, 2012 Share Posted March 4, 2012 Just get the value and do what you want, and then update the SQL value. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now