i have found 2 codes, i feel like they are autorun files, can you take a look and tell me if this is 1. somthing to place in lua/autorun and 2. if this will give me what i need if i get the site to call the information from “money”.
Code 1
function tables_exist()
if (sql.TableExists("player_info") && sql.TableExists("player_skills")) then
Msg("Both tables already exist !")
else
if (!sql.TableExists("player_info")) then
query = "CREATE TABLE player_info ( unique_id varchar(255), money int )"
result = sql.Query(query)
if (sql.TableExists("player_info")) then
Msg("Succes ! table 1 created
")
else
Msg("Somthing went wrong with the player_info query !
")
Msg( sql.LastError( result ) .. "
" )
end
end
if (!sql.TableExists("player_skills")) then
query = "CREATE TABLE player_skills ( unique_id varchar(255), speech int, fish int, farm int )"
result = sql.Query(query)
if (sql.TableExists("player_skills")) then
Msg("Succes ! table 2 created
")
else
Msg("Somthing went wrong with the player_skills query !
")
Msg( sql.LastError( result ) .. "
" )
end
end
end
end
function new_player( SteamID, ply )
steamID = SteamID
sql.Query( "INSERT INTO player_info (`unique_id`, `money`)VALUES ('"..steamID.."', '100')" )
result = sql.Query( "SELECT unique_id, money FROM player_info WHERE unique_id = '"..steamID.."'" )
if (result) then
sql.Query( "INSERT INTO player_skills (`unique_id`, `speech`, `fish`, `farm`)VALUES ('"..steamID.."', '1', '1', '1')" )
result = sql.Query( "SELECT unique_id, speech, fish, farm FROM player_skills WHERE unique_id = '"..steamID.."'" )
if (result) then
Msg("Player account created !
")
sql_value_stats( ply )
sql_value_skills( ply )
else
Msg("Something went wrong with creating a players skills !
")
end
else
Msg("Something went wrong with creating a players info !
")
end
end
function player_exists( ply )
steamID = ply:GetNWString("SteamID")
result = sql.Query("SELECT unique_id, money FROM player_info WHERE unique_id = '"..steamID.."'")
if (result) then
sql_value_stats( ply ) -- We will call this to retrieve the stats
sql_value_skills( ply ) -- We will call this to retrieve the skills
else
new_player( steamID, ply ) -- Create a new player :D
end
end
function Initialize()
tables_exist()
end
function PlayerInitialSpawn( ply )
timer.Create("Steam_id_delay", 1, 1, function()
SteamID = ply:SteamID()
ply:SetNWString("SteamID", SteamID)
timer.Create("SaveStat", 10, 0, function() saveStat( ply ) end)
player_exists( ply )
end)
end
hook.Add( "PlayerInitialSpawn", "PlayerInitialSpawn", PlayerInitialSpawn )
hook.Add( "Initialize", "Initialize", Initialize )
Next
Code 2
function sql_value_stats ( ply )
unique_id = sql.QueryValue("SELECT unique_id FROM player_info WHERE unique_id = '"..steamID.."'")
money = sql.QueryValue("SELECT money FROM player_info WHERE unique_id = '"..steamID.."'")
ply:SetNWString("unique_id", unique_id)
ply:SetNWInt("money", money)
end
function sql_value_skills ( ply )
unique_id = sql.QueryValue("SELECT unique_id FROM player_skills WHERE unique_id = '"..steamID.."'")
speech = sql.QueryValue("SELECT speech FROM player_skills WHERE unique_id = '"..steamID.."'")
fish = sql.QueryValue("SELECT fish FROM player_skills WHERE unique_id = '"..steamID.."'")
farm = sql.QueryValue("SELECT farm FROM player_skills WHERE unique_id = '"..steamID.."'")
ply:SetNWString("unique_id", unique_id)
ply:SetNWInt("speech", speech)
ply:SetNWInt("fish", fish)
ply:SetNWInt("farm", farm)
end
function saveStat ( ply )
money = ply:GetNWInt("money")
unique_id = ply:GetNWString ("SteamID")
speech = ply:GetNWInt("speech")
fish = ply:GetNWInt("fish")
farm = ply:GetNWInt("farm")
sql.Query("UPDATE player_skills SET speech = "..speech..", fish = "..fish..", farm = "..farm.." WHERE unique_id = '"..unique_id.."'")
sql.Query("UPDATE player_info SET money = "..money.." WHERE unique_id = '"..unique_id.."'")
ply:ChatPrint("Stats updated !")
end
function tables_exist()
if (sql.TableExists("player_info") && sql.TableExists("player_skills")) then
Msg("Both tables already exist !")
else
if (!sql.TableExists("player_info")) then
query = "CREATE TABLE player_info ( unique_id varchar(255), money int )"
result = sql.Query(query)
if (sql.TableExists("player_info")) then
Msg("Succes ! table 1 created
")
else
Msg("Somthing went wrong with the player_info query !
")
Msg( sql.LastError( result ) .. "
" )
end
end
if (!sql.TableExists("player_skills")) then
query = "CREATE TABLE player_skills ( unique_id varchar(255), speech int, fish int, farm int )"
result = sql.Query(query)
if (sql.TableExists("player_skills")) then
Msg("Succes ! table 2 created
")
else
Msg("Somthing went wrong with the player_skills query !
")
Msg( sql.LastError( result ) .. "
" )
end
end
end
end
function new_player( SteamID, ply )
steamID = SteamID
sql.Query( "INSERT INTO player_info (`unique_id`, `money`)VALUES ('"..steamID.."', '100')" )
result = sql.Query( "SELECT unique_id, money FROM player_info WHERE unique_id = '"..steamID.."'" )
if (result) then
sql.Query( "INSERT INTO player_skills (`unique_id`, `speech`, `fish`, `farm`)VALUES ('"..steamID.."', '1', '1', '1')" )
result = sql.Query( "SELECT unique_id, speech, fish, farm FROM player_skills WHERE unique_id = '"..steamID.."'" )
if (result) then
Msg("Player account created !
")
sql_value_stats( ply )
sql_value_skills( ply )
else
Msg("Something went wrong with creating a players skills !
")
end
else
Msg("Something went wrong with creating a players info !
")
end
end
function player_exists( ply )
steamID = ply:GetNWString("SteamID")
result = sql.Query("SELECT unique_id, money FROM player_info WHERE unique_id = '"..steamID.."'")
if (result) then
sql_value_stats( ply ) -- We will call this to retrieve the stats
sql_value_skills( ply ) -- We will call this to retrieve the skills
else
new_player( steamID, ply ) -- Create a new player :D
end
end
function Initialize()
tables_exist()
end
function PlayerInitialSpawn( ply )
timer.Create("Steam_id_delay", 1, 1, function()
SteamID = ply:SteamID()
ply:SetNWString("SteamID", SteamID)
timer.Create("SaveStat", 10, 0, function() saveStat( ply ) end)
player_exists( ply )
end)
end
hook.Add( "PlayerInitialSpawn", "PlayerInitialSpawn", PlayerInitialSpawn )
hook.Add( "Initialize", "Initialize", Initialize )
[editline]24th October 2014[/editline]
also an idea of mine.
if (isset($_GET['steamid'])) {
$data = 'http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=07D591DD50614036689A5E33AC63A041&steamids='.$_GET['steamid'];
$f = file_get_contents($data);
$arr = json_decode($f, true);
if (isset($arr['response']['players'][0]['personaname']))
$plname = $arr['response']['players'][0]['personaname'];
if (isset($arr['response']['players'][0]['avatar']))
$avatar = $arr['response']['players'][0]['avatar'];
if (isset ($arr['response']['players'][0]['money']))
$money = $arr['response']['players'][0]['money'];
}
Your balance: $<b><?php echo $money?><br>