furruz Posted July 17, 2012 Share Posted July 17, 2012 Hi all. Saludos a todos. I'm using mabako's MTA Paradise. I have changed some codes to make new players team-free. I have added some teams. I've seen that there are some scripts to save team from any account, but i need to save every characters' team. Can someone help me? i'm trying to modify this code i found here in forums: executeSQLQuery [[ CREATE TABLE IF NOT EXISTS teams ( player TEXT, team TEXT ) ]] function addInfoToSQL() sourcename = getPlayerName ( source ) -- get the player's name sourceteam = getPlayerTeam (source) -- try to retrieve the player data from the db result = executeSQLSelect ( "teams", "player", "player = '" .. sourcename .. "'" ) if ( result == false ) then -- see if any data was found at all outputChatBox ( "This is your first time here! Welcome " .. sourcename .. "!", source ) executeSQLInsert ( "teams", "'team', '" .. sourcename .. "'" ) else outputChatBox ( "Welcome back " .. sourcename .. "!", source ) executeSQLUpdate ( "teams", "team = '.. sourceteam ..'", "player = '" .. sourcename .. "'" ) end end function save () sourcename = getPlayerName (source) executeSQLUpdate ( "teams", "team = '" .. sourceteam .. "'", "player = '" .. sourcename .. "'" ) end addEventHandler ( "onPlayerSpawn", getRootElement(), addInfoToSQL ) addEventHandler("onPlayerQuit", getRootElement(), save) -- saves team on quit Español: Saludos, disculpad mi mal inglés. Estoy utilizando MTA Paradise de Mabako y necesitaria crear un script que guardara el equipo de cada character en lugar de cada cuenta. He intentado modificar el codigo arriba citado pero por ahora no consigo que funcione. Podria alguien ayudarme? Muchas gracias Link to comment
TAPL Posted July 17, 2012 Share Posted July 17, 2012 executeSQLQuery [[ CREATE TABLE IF NOT EXISTS teams ( player TEXT, team TEXT ) ]] executeSQLCreateTable("teams", "player TEXT, team TEXT") Link to comment
furruz Posted July 17, 2012 Author Share Posted July 17, 2012 thx TAPL I have debugged a little the code and commented some lines to test. Now team is updated when u log out, now i need to debug the commented code executeSQLCreateTable("teams", "player TEXT, team TEXT") --function addInfoToSQL() --local sourcename = getPlayerName ( source ) -- get the player's name --local sourceteam = getPlayerTeam (source) --local teamname = getTeamName (sourceteam) -- try to retrieve the player data from the db --result = executeSQLSelect ( "teams", "player", "player = '" .. sourcename .. "'" ) --if ( result == false ) then -- see if any data was found at all --outputChatBox ( "This is your first time here! Welcome " .. sourcename .. "!", source ) --executeSQLInsert ( "teams", "'team', '" .. sourcename .. "'" ) --else --outputChatBox ( "Welcome back " .. sourcename .. "!", source ) --executeSQLUpdate ( "teams", "team = '.. teamname ..'", "player = '" .. sourcename .. "'" ) --end --end function teamsave () local sourcename = getPlayerName ( source ) -- get the player's name local sourceteam = getPlayerTeam (source) --get player's team local teamname = getTeamName (sourceteam) --get team's name executeSQLUpdate ( "teams", "team = '" .. teamname .. "'", "player = '" .. sourcename .. "'" ) end addEventHandler ( "onPlayerSpawn", getRootElement(), addInfoToSQL ) addEventHandler("onPlayerQuit", getRootElement(), teamsave) -- saves team on quit Link to comment
furruz Posted July 17, 2012 Author Share Posted July 17, 2012 executeSQLCreateTable("teams", "player TEXT, team TEXT") function addInfoToSQL() local sourcename = getPlayerName ( source ) -- get the player's name local sourceteam = getPlayerTeam (source) local teamname = getTeamName (source) local result2 = executeSQLSelect ( "teams", "team", "player = ' ".. sourcename .." '" ) local teamresult = getTeamFromName('"..result2.."') -- try to retrieve the player data from the db result = executeSQLSelect ( "teams", "player", "player = '" .. sourcename .. "'" ) if ( type( result ) == "table" and #result == 0 ) or not result then -- see if any data was found at all outputChatBox ( "Es tu primera vez con nosotros! Bienvenido " .. sourcename .. "!", source ) executeSQLInsert ( "teams", "'team','player'", " ".. sourcename .." ") else outputChatBox ( "Bienvenido de nuevo " .. sourcename .. "!", source ) setPlayerTeam ( source, "teamresult" ) end end function teamsave () local sourcename = getPlayerName ( source ) -- get the player's name local sourceteam = getPlayerTeam (source) --get player's team local teamname = getTeamName (sourceteam) --get team's name executeSQLUpdate ( "teams", "team = '" .. teamname .. "'", "player = '" .. sourcename .. "'" ) end addEventHandler ( "onPlayerSpawn", getRootElement(), addInfoToSQL ) addEventHandler("onPlayerQuit", getRootElement(), teamsave) -- saves team on quit Team is updated in sqllite. But on creating new character it does not create a new row. And an existing character in sqllite does not have its team when playerspawn I'm sorry for my bad english Link to comment
furruz Posted July 17, 2012 Author Share Posted July 17, 2012 still not working Can someone help me? thx 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