I am using kongregate to fetch a users username
var username = kongregate.services.getUsername()
Now using this username I would like a way for players to send money they have to other users but im not exactly sure how my entire game is written in javascript and at this point theres absolutly no way I could switch over to PHP and use ajax so can this be done with javascript for example heres a little relevant code
var playerName = document.getElementById("username").value;
var moneyAmt = document.getElementById("money").value;
var submitBtn = document.getElementById("sendMoney");
submitBtn.onclick = function(){
if(Game.Player.money >= moneyAmt){
Game.Player.money -= moneyAmt;
//Send Money along with playerName
}
}
//User recieving
if(kongregate.services.getUsername() == playerName){
Game.Player.money += moneyAmt;
}
//Form for sending
<form>
<input type="text" id="username" placeholder="Enter players username"><br>
<input type="number" id="money" placeholder="Enter amount to send">
<input type="submit" id="sendMoney" value="Send">
</form>
I know this is kinda difficult especially with javascript but I am out of options