Jump to content

save values


xArgonx

Recommended Posts

Posted

I'm searching for, how i can save values in variables in .xml files.

I have already searched in the forum but i could not find any way.

Posted

SQLite is the fastest. You can also use MySQL module to use MySQL. Saving variables is silly in my opinion...

Posted

Check the executeSQLCreateTable. You can name columns only when you create a table.

Posted
function dbadd () 
        executeSQLCreateTable ( "ppplayers", "money INTEGER, health INTEGER, armour INTEGER, job TEXT, wanted INTEGER, player TEXT" ) 
end 
addCommandHandler ("dbadd", dbadd) 
  
  
function updatedb ( sourcePlayer, theTeam )  
    sourcename = getPlayerName ( sourcePlayer ) 
    player = executeSQLSelect ( "ppplayers", "player", "player = '" .. sourcename .. "'" ) 
        if ( player == false ) then 
            outputChatBox("You have no account to update", sourcePlayer) 
        else     
            executeSQLUpdate ( "ppplayers", "money = '800', health = '50', armour = '100', job = 'Police', wanted = '1'", "player = '" .. sourcename .. "'" ) 
            outputChatBox ("Update finished", sourcePlayer) 
        end 
end 
addCommandHandler ("updatedb", updatedb) 
  
  
  
  
function onjoindb ()  
local sourcename = getPlayerName ( source )  
        player = executeSQLQuery("SELECT money FROM ppplayers WHERE player=?", sourcename) 
        if(#player == 0) then   
                executeSQLInsert ( "ppplayers", "'600', '100', '0', 'Civillian', '0', '" .. sourcename .. "'" ) 
                outputChatBox ( "This is your first time here! Welcome " .. sourcename .. "!", source ) 
        else 
                setPlayerMoney( source, player[1].money ) 
                -- 
                wanted = executeSQLQuery("SELECT wanted FROM ppplayers WHERE player=?", sourcename) 
                setPlayerWantedLevel ( source, wanted[1].wanted ) 
                -- 
                job = executeSQLQuery("SELECT job FROM ppplayers WHERE player=?", sourcename) 
        end      
         
end 
  
addEventHandler ( "onPlayerJoin", getRootElement(), onjoindb ) 
  
function onquitdb () 
local sourcename = getPlayerName ( source ) 
        getmoney = getPlayerMoney ( source ) 
        getplayerTeam = getPlayerTeam ( source )  
        wanted = getPlayerWantedLevel( source ) 
        playerTeam = getTeamName ( getplayerTeam ) 
        executeSQLUpdate ( "ppplayers", "money = '" .. getmoney .. "', health = '50', armour = '100', job = '" .. playerTeam .. "', wanted = '" .. wanted .. "'", "player = '" .. sourcename .. "'" ) 
end 
addEventHandler ( "onPlayerQuit", getRootElement(), onquitdb )     

Not all the functions work but you can easily change/fix it :)

Posted

ok your right sry, i was a bit busy since i read your post first^^

i do not get any error messages now, but if i use /dbadd or updatedb nothing happens

and nothing is saved

Posted

Well the server your using does it have teams on it? It dont work without teams and updateDB doesnt need to be used.. It was to test it before. ( And its outdated )

Posted

actually i tried to go on whith the script i postet before now it is:

function dbadd (commandName)
       executeSQLCreateTable ( "Players", "Money INTEGER, Skin INTERGER, Team TEXT, Wanted INTEGER, Player TEXT" )
end
addCommandHandler ("dbadd", dbadd)
 
 
function onjoindb ()
local sourcename = getPlayerName ( source )
       player = executeSQLQuery("SELECT Money FROM eVo_Players WHERE Player=?", sourcename)
       if(#player == 0) then  
               executeSQLInsert ( "Players", "'5000',  '0', 'Arbeitsloser', '0', '" .. sourcename .. "'" )
       else
money = executeSQLQuery ("SELECT Money FROM Players WHERE Player=?", sourcename)
               setPlayerMoney( source, player[1].money )
               --
               wanted = executeSQLQuery("SELECT Wanted FROM Players WHERE Player=?", sourcename)
               setPlayerWantedLevel ( source, wanted[1].wanted )
               --
               team = executeSQLQuery("SELECT Team FROM Players WHERE Player=?", sourcename)
setPlayerTeam (source, team[1].team)
--
	skin = executeSQLQuery ("SELECT Skin FROM Players WHERE Player=?", sourcename)
setElementModel (source, skin[1].skin)
       end    
 
end
 
addEventHandler ( "onPlayerJoin", getRootElement(), onjoindb )
 
function onquitdb ()
local sourcename = getPlayerName ( source )
       getmoney = getPlayerMoney ( source )
       playerskin = getElementModel ( source )
       getwanted = getPlayerWantedLevel( source )
       playerTeam = getTeamName(playersTeam)
      playersTeam =  getplayerTeam (source)
       executeSQLUpdate ( "Players", "Money = '" .. getmoney .. "', Skin = ' "..playerskin.. " ', Team = '" .. playerTeam .. "', Wanted = '" .. 
 
getwanted .. "'", "Player = '" .. sourcename .. "'" )
end
addEventHandler ( "onPlayerQuit", getRootElement(), onquitdb )

i get theses error messages:

line 35: attemp to global 'getPlayerTeam' [this error could be thata i did not be in a team while testing, but i already change the team every time i tried to get the script working)

i think the problem is that the executeSQLInsert does not start...

hope you can help me

Posted
line 35: attemp to global 'getPlayerTeam'

Yet in the code, I find this:

getplayerTeam (source)

getplayerTeam and getPlayerTeam are quite different.

Posted

ok that's right the other problem is that i think the executeSQLInsert does to start, so there is nothing to update or to get from because there is no row for a player in the sql data table

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...