29.04.2012, 00:05
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(1) { case 1: { if(!response) { SendClientMessage(playerid, 0xFF0000FF, "Use Again"); return 1; // We processed it } switch(listitem) // This is far more efficient than using an if-elseif-else structure { case 0: { if (GetPlayerMoney(playerid) >= 50) { GivePlayerWeapon(playerid,22,50); GivePlayerMoney(playerid,-50); GameTextForPlayer(playerid,"~r~-$50",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 1: { if (GetPlayerMoney(playerid) >= 3000) { GivePlayerWeapon(playerid,24,50); GivePlayerMoney(playerid,-3000); GameTextForPlayer(playerid,"~r~-$3000",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 2: { if (GetPlayerMoney(playerid) >= 750) { GivePlayerWeapon(playerid,25,50); GivePlayerMoney(playerid,-750); GameTextForPlayer(playerid,"~r~-$750",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 3: { if (GetPlayerMoney(playerid) >= 3500) { GivePlayerWeapon(playerid,26,50); GivePlayerMoney(playerid,-3500); GameTextForPlayer(playerid,"~r~-$3500",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 4: { if (GetPlayerMoney(playerid) >= 10000) { GivePlayerWeapon(playerid,27,100); GivePlayerMoney(playerid,-10000); GameTextForPlayer(playerid,"~r~-$10000",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 5: { if (GetPlayerMoney(playerid) >= 2000) { GivePlayerWeapon(playerid,29,150); GivePlayerMoney(playerid,-2000); GameTextForPlayer(playerid,"~r~-$2000",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 6: { if (GetPlayerMoney(playerid) >= 5000) { GivePlayerWeapon(playerid,16,5); GivePlayerMoney(playerid,-5000); GameTextForPlayer(playerid,"~r~-$5000",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 7: { if (GetPlayerMoney(playerid) >= 15000) { GivePlayerWeapon(playerid,30,300); GivePlayerMoney(playerid,-15000); GameTextForPlayer(playerid,"~r~-$15000",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 8: { if (GetPlayerMoney(playerid) >= 25000) { GivePlayerWeapon(playerid,31,300); GivePlayerMoney(playerid,-25000); GameTextForPlayer(playerid,"~r~-$25000",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } switch(listitem) // This is far more efficient than using an if-elseif-else structure { { case 0: { //tec 1000 crack 3500 knife 75 if (GetPlayerMoney(playerid) >= 100) { GivePlayerWeapon(playerid,23,50); GivePlayerMoney(playerid,-100); GameTextForPlayer(playerid,"~r~-$100",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 1: { if (GetPlayerMoney(playerid) >= 300) { GivePlayerWeapon(playerid,25,50); GivePlayerMoney(playerid,-300); GameTextForPlayer(playerid,"~r~-$300",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 2: { if (GetPlayerMoney(playerid) >= 1000) { GivePlayerWeapon(playerid,32,100); GivePlayerMoney(playerid,-1000); GameTextForPlayer(playerid,"~r~-$1000",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 3: { if (GetPlayerMoney(playerid) >= 3500) { SetPlayerHealth(playerid,17); GivePlayerMoney(playerid,-3500); GameTextForPlayer(playerid,"~r~-$3500",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } case 4: { if (GetPlayerMoney(playerid) >= 75) { GivePlayerWeapon(playerid,4,1); GivePlayerMoney(playerid,-75); GameTextForPlayer(playerid,"~r~-$75",3000,1); PlayerPlaySound(playerid, 1052, 0.0, 0.0, 10.0); } else { SendClientMessage(playerid,red,"You do not have the cash."); } } return 0; // If you put return 1 here the callback will not continue to be called in other scripts (filterscripts, etc.). }