[Ajuda] Como Funciona o switch e o break no dialog
#1

Este Codigo ta no fs e ta dando a volta de um dialog no inicio do gamemode, quando e enviado a resposta,
este e quando chega em um checkpoint e showdialog aonde vai o break ai..

Код HTML:
public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[]){
new dinheiro;
dinheiro=GetPlayerMoney(playerid);
if(dialogid==BOMBA_RELOGIO_CARRO){
if(response){
switch(listitem){
case 0:{
if(dinheiro>=5000){
p[playerid][BOMBA] +=1;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,dinheiro-5000);
}else{
SendClientMessage(playerid,-1,"vc nao tem dinheiro suficiente");
}

}
case:1{
if(dinheiro>5000){
p[playerid][ALARME]=1;
}else{
SendClientMessage(playerid,-1,"vc nao tem dinheiro suficiente");}
}
}


}
}
return 1;
}
Ass.. rapaz q podia ta roubando ,matando,mas so ta tentando aprender..
Reply
#2

Nгo entendi seu codigo,

Ele reseta o dinheiro e ainda tira -5000? wtf?
Reply
#3

O Switch no dialog com a utilizaзгo do listitem faz a checagem de qual opзгo foi selecionada e dependendo de sua opзгo (com seus ID's) ele retorna alguma funзгo.

Exemplo usando uma Include de Dialogs.


Код:
Dialog_Show(playerid, Skins, DIALOG_STYLE_LIST, "Skins", "Skin 1\nSkin 2\nSkin 3", "Selecionar", "Cancelar"
No cуdigo acima as opзхes (listitem) seriam o Skin 1, Skin 2 e Skin 3. No DIALOG_STYLE_LIST (https://sampwiki.blast.hk/wiki/Dialog_Styles) O listitem diferencia utilizando o switch para cada ID. A primeira opзгo й sempre a ID 0, e conforme as outras vгo subindo de 0 atй seu nъmero.

Код:
Dialog:Skins(playerid, response, listitem, inputtext[])
{
	if (response)
	{
		switch(listitem)
		{
		    case 0:
		    {
		            SendClientMessage(playerid, COLOR_GREEN, "Vocк escolheu a Skin 1.");
      		        }
			case 1:
			{
                            SendClientMessage(playerid, COLOR_GREEN, "Vocк escolheu a Skin 2.");
			}
			case 2:
			{
			    SendClientMessage(playerid, COLOR_GREEN, "Vocк escolheu a Skin 3.");
			}
		}
	}
	return 1;
Na funзгo acima o switch(listitem) identifica qual foi a opзгo clicada pelo jogador, se foi a primeira opзгo (ID 0) ele retorna que o jogador escolheu a Skin 1, e assim vai.

Para compreender o seu cуdigo, peзo que mande o ShowPlayerDialog do DIALOGID = BOMBA_RELOGIO_CARRO do comando ou da funзгo, para ver as opзхes do dialog. O Switch estб explicado, o break nгo consigo te ajudar assim.
Reply
#4

tenho aki o meu fs "pickupseicones"
Код HTML:
  This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

#include <a_samp>
#include <streamer>
#include <zcmd>
new checkpointcarrobomba;// checkpoin do carro bomba

static Float: PosVeiculo[3];
enum itemcheckbomba{
BOMBA_RELOGIO_CARRO,
ALARME_CARRO,
BOMBA
}
#define BOMBA_RELOGIO_CARRO 0
#define AlARME_CARRO 1
new bomba[itemcheckbomba];
new bool:bombaplantada[MAX_VEHICLES];
//new v[MAX_VEHICLES];
new p[MAX_PLAYERS][itemcheckbomba];

main(){}

public OnFilterScriptInit()
{
CreatePickup(1242,2,1094.3517, -2036.9635, 83.0081,0); //pickup colete ls casa da mafia
CreatePickup(1242,2,2096.5164, 1288.7668, 10.8778,0); //pickup colete 2 lv
CreatePickup(1242,2,-2651.5046,1446.0918,41.8295,0);  //pickup 3 colete sf
CreatePickup(1242,2,-365.9436,-1419.6281,29.6406,0);
print("\fs PickupseIcones Carregados com Sucesso.!");

return 1;
}

public OnPlayerConnect(playerid){
//icone delegacia pol ls
CreateDynamicMapIcon(1555.5026,-1676.4065,16.1953, /*type*/ 30, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icon casa loterica ls
CreateDynamicMapIcon(1633.5430,-1172.1062,24.0781, /*type*/ 52, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);

//icone hospita 1 ls
CreateDynamicMapIcon(2030.1973,-1406.3088,17.2118, /*type*/ 22, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icone hospital 2 ls
CreateDynamicMapIcon(1172.3802,-1323.1125,15.4025, /*type*/ 22, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);

//icone aviao LS
CreateDynamicMapIcon(1968.9130,-2278.2305,13.1718, /*type*/ 5, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);

//icone posto de gasolina 1 ls
CreateDynamicMapIcon(1939.1776,-1773.9315,13.0115, /*type*/ 27, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icone posto de gasolina 2 fora ls
CreateDynamicMapIcon(-91.9749,-1167.7186,2.4579, /*type*/ 27, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);

//icone loja de armas 1 ls
CreateDynamicMapIcon(1367.0548,-1283.0552,13.5469, /*type*/ 6, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icone loje de armas 2 LS
CreateDynamicMapIcon(2402.5376,-1981.9576,13.5469, /*type*/ 6, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);


//icone spray 1 LS
CreateDynamicMapIcon(487.2725,-1740.3353,10.7523, /*type*/ 63, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icone spray 2 LS
CreateDynamicMapIcon(2062.5542,-1831.2405,13.5469, /*type*/ 63, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icon spray 3 LS
CreateDynamicMapIcon(1025.3251,-1025.8120,31.7266, /*type*/ 63, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);

//pizzaria 1 LS
CreateDynamicMapIcon(2105.3057,-1807.7158,13.5547, /*type*/ 29, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icone bebibas 1 LS
CreateDynamicMapIcon(2310.0806,-1645.4645,18.3848, /*type*/ 49, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);

//icone cluckin bell 1 LS
CreateDynamicMapIcon(926.8762,-1354.7477,13.3781, /*type*/ 14, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icone cluckin bell 2 LS
CreateDynamicMapIcon(2419.7986,-1507.2156,24.0000, /*type*/ 14, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icone cluckin bell 3 LS
CreateDynamicMapIcon(2399.3621,-1899.1456,13.5469, /*type*/ 14, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);



//icon burger 1 LS
CreateDynamicMapIcon(1198.9440,-918.9012,47.2839, /*type*/ 10, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);
//icon burger 2 LS
CreateDynamicMapIcon(810.6855,-1613.7380,13.5469, /*type*/ 10, /*color*/ 0, /*worldid = */0, /*interiorid = */0, playerid, /*Float:streamdistance = STREAMER_MAP_ICON_SD*/280.0, /*style = */MAPICON_LOCAL/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1*//* priority = 0*/);


//checkpoint carro bomba 1
checkpointcarrobomba=CreateDynamicCP(-72.2521,-1183.1500,1.3749, 4, 0, 0, playerid , 280.0/* STREAMER_TAG_AREA areaid = STREAMER_TAG_AREA -1,*/ /*priority = 0*/);
return 1;
}

public OnFilterScriptExit()
{
	return 1;
}
public OnPlayerSpawn(playerid){
p[playerid][BOMBA]=0;

return 1;
}

public OnPlayerUpdate(playerid){


return 1;
}

public OnPlayerEnterDynamicCP(playerid, STREAMER_TAG_CP checkpointid){

if(checkpointid==checkpointcarrobomba && IsPlayerInAnyVehicle(playerid)){
ShowPlayerDialog(playerid,BOMBA_RELOGIO_CARRO,DIALOG_STYLE_TABLIST_HEADERS,"{000FFF}COMPRAR ITEMS MOD:","Item\tPreco\n Bomba Relogio\t $5000\n Alarme\t $1000","Selec","Cancel");


}
else{
SendClientMessage(playerid,-1,"{FF2800}Mensage:{ffffff} Voce Precisa esta em um Carro Para Comprar Aqui!");
}
return 1;
}

public OnDialogResponse(playerid,dialogid,response,listitem,inputtext[]){
new dinheiro;
dinheiro=GetPlayerMoney(playerid);
if(dialogid==BOMBA_RELOGIO_CARRO){
if(response){
switch(listitem){
case 0:
if(dinheiro>=5000){
p[playerid][BOMBA] +=1;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,dinheiro-5000);
}else{
SendClientMessage(playerid,-1,"vc nao tem dinheiro suficiente");


}
case 1:
if(dinheiro>=250){
p[playerid][ALARME_CARRO] +=1;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid,dinheiro-250);
}else{
SendClientMessage(playerid,-1,"vc nao tem dinheiro suficiente");


}
}


}
}
return 1;
}
forward ExplodirBomba(playerid);//call back

public OnPlayerStateChange(playerid,newstate,oldstate){
if(oldstate==PLAYER_STATE_ONFOOT && newstate==PLAYER_STATE_DRIVER){
if(bombaplantada[GetPlayerVehicleID(playerid)]==true){
SetTimerEx("ExplodirBomba", 5000, false, "i", playerid);
SendClientMessage(playerid, -1, "Voce entrou em um carro com bomba plantada, e ira explodir em 5 segundos");
SendClientMessage(playerid, -1, "Corra!");
SetVehicleHealth(GetPlayerVehicleID(playerid), 0);
GetVehiclePos(GetPlayerVehicleID(playerid),PosVeiculo[0], PosVeiculo[1],PosVeiculo[2]);
}
}
return 1;
}

public ExplodirBomba(playerid) //call back
{
    CreateExplosion(PosVeiculo[0]+1,PosVeiculo[1]+0.5, PosVeiculo[2],10,30.0);
    CreateExplosion(PosVeiculo[0]+5,PosVeiculo[1]+4, PosVeiculo[2],10,30.0);
    CreateExplosion(PosVeiculo[0]+7,PosVeiculo[1]+6, PosVeiculo[2]+4,10,30.0);
    return 1;
}

public OnPlayerEnterVehicle(playerid,vehicleid,ispassenger){

return 1;
}

public OnPlayerExitVehicle(playerid,vehicleid){


return 1;
}

public OnVehicleDeath(vehicleid,killerid){
if(bombaplantada[vehicleid]==true){
bombaplantada[vehicleid]=false;
}

return 1;
}

CMD:plantarbomba(playerid,params[]){
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "Voce deve estб em um veiculo para plantar a bomba");
if(p[playerid][BOMBA]>0){
bombaplantada[GetPlayerVehicleID(playerid)] = true;
SendClientMessage(playerid,-1,"{0A00FF}Mensagem: {ffffff}Bomba Plantada Com Sucesso!");
p[playerid][BOMBA] -=1;
} else{
SendClientMessage(playerid,-1,"{0A00FF}Mensagem: {ffffff}Voce nao Tem Nenhuma Bomba!");
}
return 1;

}
tem algo errado com script acima?? ,me explica pq ele chama um dialog que nao ta nele,tipo eu escolho o item 0 do player dialog aih aparece outro depois,sem sentido,
Reply
#5

resolvir ja galera vlw..

error script 1 gamemode= base.pwn
#define exemplo1 0 //dialogid
#define exemplo2 1 //dialogid

script 2= fs pickupseicones.pwn
#define exemplo1 0 //dialogid
#define exemplo2 1 //dialogid
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)