pawn Код:
if(!strcmp(cmdtext, "/dg17", true))
{
ShowPlayerDialog(playerid,67,DIALOG_STYLE_INPUT,"Drift Grove Teleportes ID","DG1 1\nDG2 2\nDG3 3\nDG4 4\nDG5 5\nDG6 6\nDG7 7\nDG8 8\nDG9 9\nDG10 0","Ok","Fechar");
return 1 ;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 67 && response == 1)
{
if(strlen(inputtext) >= 1)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),-364.7623,1532.6614,75.3594);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 256.9824);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,-364.7623,1532.6614,75.3594);
SetPlayerFacingAngle(playerid, 256.9824);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,-364.7623,1532.6614,75.3594);
SetPlayerFacingAngle(playerid, 256.9824);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(strlen(inputtext) >= 2)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),1255.3643,-2033.8282,59.5524);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 268.9283);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,1255.3643,-2033.8282,59.5524);
SetPlayerFacingAngle(playerid, 268.9283);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,1255.3643,-2033.8282,59.5524);
SetPlayerFacingAngle(playerid, 268.9283);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(strlen(inputtext) >= 3)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),2262.9102,1398.5728,42.8203);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 267.6750);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,2262.9102,1398.5728,42.8203);
SetPlayerFacingAngle(playerid, 267.6750);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,2262.9102,1398.5728,42.8203);
SetPlayerFacingAngle(playerid, 267.6750);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
}
if(strlen(inputtext) >= 4)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),2226.2451,1978.7045,31.7797);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 180.9042);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,2226.2451,1978.7045,31.7797);
SetPlayerFacingAngle(playerid, 180.9042);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,2226.2451,1978.7045,31.7797);
SetPlayerFacingAngle(playerid, 180.9042);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(strlen(inputtext) >= 5)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),2072.4153,2376.2625,49.5234);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 4.1825);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,2072.4153,2376.2625,49.5234);
SetPlayerFacingAngle(playerid, 4.1825);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,2072.4153,2376.2625,49.5234);
SetPlayerFacingAngle(playerid, 4.1825);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(strlen(inputtext) >= 6)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),-3117.3823,1700.6478,47.0650);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 359.4200);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,-3117.3823,1700.6478,47.0650);
SetPlayerFacingAngle(playerid, 359.4200);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,-3117.3823,1700.6478,47.0650);
SetPlayerFacingAngle(playerid, 359.4200);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(strlen(inputtext) >= 7)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),-1896.7239,-146.0107,38.2422);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 179.2673);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,-1896.7239,-146.0107,38.2422);
SetPlayerFacingAngle(playerid, 179.2673);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,-1896.7239,-146.0107,38.2422);
SetPlayerFacingAngle(playerid, 179.2673);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(strlen(inputtext) >= 8)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),2220.4492,2773.7100,10.7359);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 269.4442);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,2220.4492,2773.7100,10.7359);
SetPlayerFacingAngle(playerid, 269.4442);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,2220.4492,2773.7100,10.7359);
SetPlayerFacingAngle(playerid, 269.4442);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(strlen(inputtext) >= 9)
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),2041.7954,1889.9043,11.9546);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 4.8026);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,2041.7954,1889.9043,11.9546);
SetPlayerFacingAngle(playerid, 4.8026);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,2041.7954,1889.9043,11.9546);
SetPlayerFacingAngle(playerid, 4.8026);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
}
Ou seja, se o nъmero for 5, ele vai satisfazer a condiзгo " strlen(inputtext) >= 1 "
e vai executar o primeiro bloco de comando.
Depois disso, vai executar todos os blocos em que o nъmero seja maior ou igual a 5.
Supondo que vocк tenha 9 condiзхes, todas utilizando apenas if .
Todas as vezes que elas forem satisfeitas, ocorrerб a leitura do cуdigo.
Se vocк utilizar else if, somente o conteъdo da primeira condiзгo satisfeita serб executada.
pawn Код:
new teste = 3;
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 67 && response == 1)
{
if(Teste >= 1) // Serб executado
print("1");
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),-364.7623,1532.6614,75.3594);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 256.9824);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,-364.7623,1532.6614,75.3594);
SetPlayerFacingAngle(playerid, 256.9824);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,-364.7623,1532.6614,75.3594);
SetPlayerFacingAngle(playerid, 256.9824);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(Teste >= 2) // Serб executado
print("2");
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),1255.3643,-2033.8282,59.5524);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 268.9283);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,1255.3643,-2033.8282,59.5524);
SetPlayerFacingAngle(playerid, 268.9283);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,1255.3643,-2033.8282,59.5524);
SetPlayerFacingAngle(playerid, 268.9283);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
if(Teste >= 3) // Serб executado
print("3");
{
if(IsPlayerInAnyVehicle(playerid) == 1) {
SetPlayerInterior(playerid, 0);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
SetVehiclePos(GetPlayerVehicleID(playerid),2262.9102,1398.5728,42.8203);
SetVehicleZAngle(GetPlayerVehicleID(playerid), 267.6750);
LinkVehicleToInterior(GetPlayerVehicleID(playerid), 0);
} else {
RemovePlayerFromVehicle(playerid);
SetPlayerPos(playerid,2262.9102,1398.5728,42.8203);
SetPlayerFacingAngle(playerid, 267.6750);
SetCameraBehindPlayer(playerid);
}
} else {
SetPlayerPos(playerid,2262.9102,1398.5728,42.8203);
SetPlayerFacingAngle(playerid, 267.6750);
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid, 0);
new pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
ResetPlayerWeapons(playerid);
}
}