xArgonx Posted July 10, 2009 Share Posted July 10, 2009 i have problem with the script from knash 94, i changed it a bit because i got many errors, but now i get this errors: after login out: line 45: attemp to concatenate global 'playerTeam' after login: line 21: attemp to index field '?' (here i think is a argument wrong, but which?) here the script: function createSQLOnStart(player, commandName) executeSQLCreateTable ( "players", "Geld INTERGER, WandetLevel INTERGER, Skin INTERGER, Team TEXT, Player TEXT" ) end addEventHandler ("onResourceStart",getRootElement(), createSQLOnStart) function updatedb ( sourcePlayer, theTeam ) sourcename = getPlayerName ( sourcePlayer ) Player = executeSQLSelect ( "players", "Player", "Player = '" .. sourcename .. "'" ) if ( Player == false ) then outputChatBox("Du hast keinen Account zum updaten", sourcePlayer) else executeSQLUpdate ( "players", "Geld = '5000', WandetLevel = '0', Skin = '0', Team = 'Arbeitsloser'", "Player = '" .. sourcename .. "'" ) end end addCommandHandler ("updatedb", updatedb) function onjoindb () local sourcename = getPlayerName (source) player = executeSQLSelect ( "players", "Player", "Player = '" .. sourcename .. "'" ) if ( player == false ) then executeSQLInsert ( "players", "'5000', '0', '0', 'Arbeitsloser'" .. sourcename .. "'" ) else money = executeSQLSelect ( "players", "Geld", "Player = '" .. sourcename .. "'" ) setPlayerMoney(source, money[1][1] ) local WantedLevel = executeSQLSelect ( "players", "WantedLevel", "Player = '" .. sourcename .. "'" ) setPlayerWantedLevel (source, WantedLevel[1][1] ) local Skin = executeSQLSelect ( "players", "Skin", "Player = '" .. sourcename .. "'" ) setElementModel (source, Skin[1][1] ) local Team = executeSQLSelect ( "players", "Team", "Player = '" .. sourcename .. "'" ) setPlayerTeam( source, getTeamFromName( Team[1][1] ) ) end end addEventHandler ( "onPlayerJoin", getRootElement(), onjoindb ) function onquitdb () local sourcename = getPlayerName ( source ) getmoney = getPlayerMoney ( source ) playerTeam = getPlayerTeam ( source ) wanted = getPlayerWantedLevel( source ) skin = getElementModel ( source ) executeSQLUpdate ( "players", "Geld = '" .. getmoney .. "' WandetLevel = '" .. wanted .. "', Skin = '" .. skin .. "', Team = '" .. playerTeam .. "', Player = '" .. sourcename .. "'" ) end addEventHandler ( "onPlayerQuit", getRootElement(), onquitdb ) Link to comment
Dark Dragon Posted July 10, 2009 Share Posted July 10, 2009 not 21 nor 45 contain anything. Link to comment
Cazomino05 Posted July 10, 2009 Share Posted July 10, 2009 function onquitdb () local sourcename = getPlayerName ( source ) getmoney = getPlayerMoney ( source ) playerTeam = getPlayerTeam ( source ) wanted = getPlayerWantedLevel( source ) skin = getElementModel ( source ) executeSQLUpdate ( "players", "Geld = '" .. getmoney .. "' WandetLevel = '" .. wanted .. "', Skin = '" .. skin .. "', Team = '" .. playerTeam .. "', Player = '" .. sourcename .. "'" ) end the problem there is your using getPlayerTeam which returns a team element, you'l want to use getTeamName on the team element so you can get a string which can be used in executeSQLUpdate to output the desired result: playerTeam = getTeamName ( getPlayerTeam ( source ) ) You also might want to declare the other variables your using in that block as local since they obviously aren't needed after the code is executed Also to speed up your query's you might want to select more than one column in the table and only use one executeSQLSelect for the code from lines 28-38 Oh as for the other error it seems you want to change line 31 to local WantedLevel = executeSQLSelect ( "players", "WandetLevel", "Player = '" .. sourcename .. "'" ) since the column isn't called WantedLevel Link to comment
xArgonx Posted July 10, 2009 Author Share Posted July 10, 2009 now i get on quit the error message bad argument line 56 executeSQLUpdate ( "players", "Geld = '" .. getmoney .. "' WantedLevel = '" .. wanted .. "', Skin = '" .. skin .. "', Team = '" .. playerTeam .. "', Player = '" .. sourcename .. "'" ) and on login gives the local 'money' a bolean value, line 29: else local money = executeSQLSelect ( "players", "Geld", "Player = '" .. sourcename .. "'" ) 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