C
C#2y ago
Gamer On

✅ Google Sheets API Randomized value

Im trying to use the value of a string to assign a value to an int, however whatever I have done doesnt work and it assumes the default value 0, can someone please help me
static readonly string[] Scopes = { SheetsService.Scope.Spreadsheets };
static readonly string ApplicationName = "Database";
static readonly string SpreadsheetID = "1jDzM7s1xYTREZnCEL3U-BEeEPY6vQI3TR0D8fItX_-Y";
static readonly string sheet = "Attacks";
public static int rowCount;
public static string[] moveList;

public static void PlayerMoveLookup(Player player, string attack)
{
var range = $"{sheet}!A1:F10";
var request = Program.service.Spreadsheets.Values.Get(SpreadsheetID, range);

var response = request.Execute();
var values = response.Values;

if (values != null && values.Count > 0)
{
foreach (var row in values)
{
if (row[0].Equals(attack))
{
player.attack1.dmg = (int)row[1];

}
}
}
}
static readonly string[] Scopes = { SheetsService.Scope.Spreadsheets };
static readonly string ApplicationName = "Database";
static readonly string SpreadsheetID = "1jDzM7s1xYTREZnCEL3U-BEeEPY6vQI3TR0D8fItX_-Y";
static readonly string sheet = "Attacks";
public static int rowCount;
public static string[] moveList;

public static void PlayerMoveLookup(Player player, string attack)
{
var range = $"{sheet}!A1:F10";
var request = Program.service.Spreadsheets.Values.Get(SpreadsheetID, range);

var response = request.Execute();
var values = response.Values;

if (values != null && values.Count > 0)
{
foreach (var row in values)
{
if (row[0].Equals(attack))
{
player.attack1.dmg = (int)row[1];

}
}
}
}
7 Replies
cap5lut
cap5lut2y ago
did u try debugging it yet to check where its actually going wrong?
Gamer On
Gamer OnOP2y ago
Yeah I figured out the problem 1. I was converting it into an int the wrong way because I thought it was a different Item type 2.The place where i called it had the parameters interchanged So do I keep this thread open for the next time I need help or is there a way to resolve it?
cap5lut
cap5lut2y ago
this way u can $close it:
MODiX
MODiX2y ago
Use the /close command to mark a forum thread as answered
Gamer On
Gamer OnOP2y ago
ok but i actually have another problem which is the reason for the title not making sense
cap5lut
cap5lut2y ago
then simply open another thread one thread per issue ;p
Gamer On
Gamer OnOP2y ago
k, i think ill try troubleshooting it a bit more tho thx uh there are three different /close
Want results from more Discord servers?
Add your server