System.IndexOutOfRangeException : clientside js to serverside c#

ساخت وبلاگ

Vote count: 0

I'm trying to send some output from a client side Javascript code to a server side C# code.

But my current problem is, when i try to pass multiple parameters back to the server, then i receive the error:

System.IndexOutOfRangeException: The index was outside the array range. What could cause this problem?

Javascript part where I send the variables back to the server:

var tempStorage = { 0: atmlist[index][i][0], 1: betrag
};
API.triggerServerEvent(responseName, tempStorage);

The complete Javascript function:

atmSubMenus[index].OnItemSelect.connect(function (sender, item, i)
{ if (atmlist[index][i][0] === 0) { API.triggerServerEvent(responseName, atmlist[index][i][0]); atmSubMenus[index].Visible = false; API.showCursor(false); } else if (atmlist[index][i][0] === 1) { var betrag = API.getUserInput("", 10); var tempStorage = { 0: atmlist[index][i][0], 1: betrag }; API.triggerServerEvent(responseName, tempStorage); atmSubMenus[index].Visible = false; API.showCursor(false); } else if (atmlist[index][i][0] === 2) { } else if (atmlist[index][i][0] === 3) { }
});

And here's the C# part, which causes the error:

int betrag = (int)args[0];
sender.sendChatMessage("~y~[BANK]:~w~ Betrag: " + betrag);

And the complete function:

public void onClientEventTrigger(Client sender, string name, object[] args)
{ if (name == "ATM_SELECTED") { int function = (int)args[0]; if (function == 0) { int money = database.playerDatabase.getBankAmount(sender); if (money == 0) { sender.sendChatMessage("~y~[BANK]:~w~ Du hast kein Bank guthaben."); } else { sender.sendChatMessage("~y~[BANK]:~w~ Dein Bankguthaben beträgt: $" + money); } } else if (function == 1) { int betrag = (int)args[1]; sender.sendChatMessage("~y~[BANK]:~w~ Betrag: " + betrag); } else if (function == 2) { sender.sendChatMessage("~y~[BANK]:~w~ Event 3 wurde getriggert"); } else if (function == 3) { } }
}

I appreciate any kind of help.

asked 38 secs ago

back soft...
ما را در سایت back soft دنبال می کنید

برچسب : نویسنده : استخدام کار backsoft بازدید : 277 تاريخ : جمعه 8 ارديبهشت 1396 ساعت: 20:28