26.02.2019, 15:16
Problem:
OnDialogResponse code
I have used this filterscript which spikes bug OnDialogResponse
Код:
[17:14:41] [debug] Run time error 3: "Stack/heap collision (insufficient stack size)" [17:14:41] [debug] Stack pointer (STK) is 0x48AEC, heap pointer (HEA) is 0x48B84 [17:14:41] [debug] AMX backtrace: [17:14:41] [debug] #0 000270f8 in public OnDialogResponse (0, 32100, 1, 0, 297764) from g_casinogames.amx
PHP код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_CGAMESADMINMENU)
{
if(response) {
switch(listitem)
{
case 0:
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSELECTPOKER);
}
case 1:
{
}
case 2:
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESCREDITS);
}
}
}
}
if(dialogid == DIALOG_CGAMESSELECTPOKER)
{
if(response) {
SetPVarInt(playerid, "tmpEditPokerTableID", listitem+1);
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPOKER);
} else {
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESADMINMENU);
}
}
if(dialogid == DIALOG_CGAMESSETUPPOKER)
{
if(response) {
new tableid = GetPVarInt(playerid, "tmpEditPokerTableID")-1;
if(PokerTable[tableid][pkrPlaced] == 0) {
switch(listitem)
{
case 0: // Place Poker Table
{
new szString[128];
format(szString, sizeof(szString), "Press '{3399FF}~k~~PED_SPRINT~{FFFFFF}' to place poker table.");
SendClientMessage(playerid, COLOR_WHITE, szString);
SetPVarInt(playerid, "tmpPlacePokerTable", 1);
}
}
} else {
switch(listitem)
{
case 0: // Edit Poker Table
{
SetPVarFloat(playerid, "tmpPkrX", PokerTable[tableid][pkrX]);
SetPVarFloat(playerid, "tmpPkrY", PokerTable[tableid][pkrY]);
SetPVarFloat(playerid, "tmpPkrZ", PokerTable[tableid][pkrZ]);
SetPVarFloat(playerid, "tmpPkrRX", PokerTable[tableid][pkrRX]);
SetPVarFloat(playerid, "tmpPkrRY", PokerTable[tableid][pkrRY]);
SetPVarFloat(playerid, "tmpPkrRZ", PokerTable[tableid][pkrRZ]);
EditObject(playerid, PokerTable[tableid][pkrObjectID]);
new szString[128];
format(szString, sizeof(szString), "You have selected Poker Table %d, You may now customize it's position/rotation.", tableid);
SendClientMessage(playerid, COLOR_WHITE, szString);
}
case 1: // Destroy Poker Table
{
DestroyPokerTable(tableid);
new szString[64];
format(szString, sizeof(szString), "You have deleted Poker Table %d.", tableid);
SendClientMessage(playerid, COLOR_WHITE, szString);
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSELECTPOKER);
}
}
}
} else {
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSELECTPOKER);
}
}
if(dialogid == DIALOG_CGAMESCREDITS)
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESADMINMENU);
}
if(dialogid == DIALOG_CGAMESSETUPPGAME)
{
if(response) {
switch(listitem)
{
case 0: // Buy-In Max
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME2);
}
case 1: // Buy-In Min
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME3);
}
case 2: // Blind
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME4);
}
case 3: // Limit
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME5);
}
case 4: // Password
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME6);
}
case 5: // Round Delay
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME7);
}
case 6: // Start Game
{
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESBUYINPOKER);
}
}
} else {
LeavePokerTable(playerid);
}
}
if(dialogid == DIALOG_CGAMESSETUPPGAME2)
{
if(response) {
if(strval(inputtext) < 1 || strval(inputtext) > 1000000000) {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME2);
}
if(strval(inputtext) <= PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBuyInMin]) {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME2);
}
PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBuyInMax] = strval(inputtext);
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
} else {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
}
}
if(dialogid == DIALOG_CGAMESSETUPPGAME3)
{
if(response) {
if(strval(inputtext) < 1 || strval(inputtext) > 1000000000) {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME3);
}
if(strval(inputtext) >= PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBuyInMax]) {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME3);
}
PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBuyInMin] = strval(inputtext);
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
} else {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
}
}
if(dialogid == DIALOG_CGAMESSETUPPGAME4)
{
if(response) {
if(strval(inputtext) < 1 || strval(inputtext) > 1000000000) {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME4);
}
PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBlind] = strval(inputtext);
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
} else {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
}
}
if(dialogid == DIALOG_CGAMESSETUPPGAME5)
{
if(response) {
if(strval(inputtext) < 2 || strval(inputtext) > 6) {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME5);
}
PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrLimit] = strval(inputtext);
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
} else {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
}
}
if(dialogid == DIALOG_CGAMESSETUPPGAME6)
{
if(response) {
new tableid = GetPVarInt(playerid, "pkrTableID")-1;
strmid(PokerTable[tableid][pkrPass], inputtext, 0, strlen(inputtext), 32);
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
} else {
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
}
}
if(dialogid == DIALOG_CGAMESSETUPPGAME7)
{
if(response) {
if(strval(inputtext) < 15 || strval(inputtext) > 120) {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME7);
}
PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrSetDelay] = strval(inputtext);
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
} else {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESSETUPPGAME);
}
}
if(dialogid == DIALOG_CGAMESBUYINPOKER)
{
if(response) {
if(strval(inputtext) < PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBuyInMin] || strval(inputtext) > PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrBuyInMax] || strval(inputtext) > GetPVarInt(playerid, "cgChips")) {
return ShowCasinoGamesMenu(playerid, DIALOG_CGAMESBUYINPOKER);
}
PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrActivePlayers]++;
SetPVarInt(playerid, "pkrChips", GetPVarInt(playerid, "pkrChips")+strval(inputtext));
SetPVarInt(playerid, "cgChips", GetPVarInt(playerid, "cgChips")-strval(inputtext));
if(PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrActive] == 3 && PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrRound] == 0 && PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrDelay] >= 6) {
SetPVarInt(playerid, "pkrStatus", 1);
}
else if(PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrActive] < 3) {
SetPVarInt(playerid, "pkrStatus", 1);
}
if(PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrActive] == 1 && GetPVarInt(playerid, "pkrRoomLeader")) {
PokerTable[GetPVarInt(playerid, "pkrTableID")-1][pkrActive] = 2;
SelectTextDraw(playerid, COLOR_GOLD);
}
} else {
return LeavePokerTable(playerid);
}
}
if(dialogid == DIALOG_CGAMESCALLPOKER)
{
if(response) {
new tableid = GetPVarInt(playerid, "pkrTableID")-1;
new actualBet = PokerTable[tableid][pkrActiveBet]-GetPVarInt(playerid, "pkrCurrentBet");
if(actualBet > GetPVarInt(playerid, "pkrChips")) {
PokerTable[tableid][pkrPot] += GetPVarInt(playerid, "pkrChips");
SetPVarInt(playerid, "pkrChips", 0);
SetPVarInt(playerid, "pkrCurrentBet", PokerTable[tableid][pkrActiveBet]);
} else {
PokerTable[tableid][pkrPot] += actualBet;
SetPVarInt(playerid, "pkrChips", GetPVarInt(playerid, "pkrChips")-actualBet);
SetPVarInt(playerid, "pkrCurrentBet", PokerTable[tableid][pkrActiveBet]);
}
SetPVarString(playerid, "pkrStatusString", "Call");
PokerRotateActivePlayer(tableid);
ApplyAnimation(playerid, "CASINO", "cards_raise", 4.1, 0, 1, 1, 1, 1, 1);
}
DeletePVar(playerid, "pkrActionChoice");
}
if(dialogid == DIALOG_CGAMESRAISEPOKER)
{
if(response) {
new tableid = GetPVarInt(playerid, "pkrTableID")-1;
new actualRaise = strval(inputtext)-GetPVarInt(playerid, "pkrCurrentBet");
if(strval(inputtext) >= PokerTable[tableid][pkrActiveBet]+PokerTable[tableid][pkrBlind]/2 && strval(inputtext) <= GetPVarInt(playerid, "pkrCurrentBet")+GetPVarInt(playerid, "pkrChips")) {
PokerTable[tableid][pkrPot] += actualRaise;
PokerTable[tableid][pkrActiveBet] = strval(inputtext);
SetPVarInt(playerid, "pkrChips", GetPVarInt(playerid, "pkrChips")-actualRaise);
SetPVarInt(playerid, "pkrCurrentBet", PokerTable[tableid][pkrActiveBet]);
SetPVarString(playerid, "pkrStatusString", "Raise");
PokerTable[tableid][pkrRotations] = 0;
PokerRotateActivePlayer(tableid);
ApplyAnimation(playerid, "CASINO", "cards_raise", 4.1, 0, 1, 1, 1, 1, 1);
} else {
ShowCasinoGamesMenu(playerid, DIALOG_CGAMESRAISEPOKER);
}
}
DeletePVar(playerid, "pkrActionChoice");
}
return 0;
}