[Off] Qual melhor modo de uso???
#1

Qual melhor modo de uso destes 2 exemplos

Код:
YCMD:smoke(playerid, params[],help) {
  #pragma unused help
  if(sscanf(params, "s", anims)) {
  SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /smoke [1-4]"); }
  else {
  if(strcmp(anims, "0", true) == 0) {
  SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /smoke [1-4]"); }
  if(strcmp(anims, "1", true) == 0) {
  ApplyAnimation(playerid,"SMOKING", "F_smklean_loop", 4.0, 1, 0, 0, 0, 0); }
  if(strcmp(anims, "2", true) == 0) {
  ApplyAnimation(playerid,"SMOKING", "M_smklean_loop", 4.0, 1, 0, 0, 0, 0); }
  if(strcmp(anims, "3", true) == 0) {
  ApplyAnimation(playerid,"SMOKING","M_smkstnd_loop", 4.0, 1, 0, 0, 0, 0); }
  if(strcmp(anims, "4", true) == 0) {
  ApplyAnimation(playerid,"SMOKING","M_smk_out", 4.0, 1, 0, 0, 0, 0); } }
  return 1;
}
Код:
YCMD:smoke(playerid, params[],help) 
{
  #pragma unused help
  if(sscanf(params,"s", anims)) return SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /smoke [1-4]");

  switch(anims)
  {
  case 1: ApplyAnimation(playerid,"SMOKING", "F_smklean_loop", 4.0, 1, 0, 0, 0, 0);
  case 2: ApplyAnimation(playerid,"SMOKING", "M_smklean_loop", 4.0, 1, 0, 0, 0, 0);
  case 3: ApplyAnimation(playerid,"SMOKING","M_smkstnd_loop", 4.0, 1, 0, 0, 0, 0);
  case 4: ApplyAnimation(playerid,"SMOKING","M_smk_out", 4.0, 1, 0, 0, 0, 0);
  }
  return 1;
}
Abraзos
Reply
#2

O segundo modo!
Reply
#3

PHP код:
YCMD:smoke(playeridparams[],help)
{
  
#pragma unused help
  
    
if(sscanf(params,"s"anims))
        return 
SendClientMessage(playerid0x33AA33AA"Uso correto: /smoke [1-4]");
        
        
    switch(
anims)
    {
        case 
1ApplyAnimation(playerid"SMOKING""F_smklean_loop"4.010000);
        case 
2ApplyAnimation(playerid"SMOKING""M_smklean_loop"4.010000);
        case 
3ApplyAnimation(playerid"SMOKING","M_smkstnd_loop"4.010000);
        case 
4ApplyAnimation(playerid"SMOKING","M_smk_out"4.010000);
    }
    return 
1;

Agora estб melhor identado..

E este seria o melhor !
Reply
#4

Obrigado, pela opiniгo.
haha, valeu gatus .-.
Reply
#5

pawn Код:
YCMD:smoke(playerid, params[]) {

    if (isnull(params)) return SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /smoke [1-4]");

    switch( strval(params) ) {
   
        case 1: ApplyAnimation(playerid, "SMOKING", "F_smklean_loop", 4.0, 1, 0, 0, 0, 0);
        case 2: ApplyAnimation(playerid, "SMOKING", "M_smklean_loop", 4.0, 1, 0, 0, 0, 0);
        case 3: ApplyAnimation(playerid, "SMOKING","M_smkstnd_loop", 4.0, 1, 0, 0, 0, 0);
        case 4: ApplyAnimation(playerid, "SMOKING","M_smk_out", 4.0, 1, 0, 0, 0, 0);
        default: SendClientMessage(playerid, 0x33AA33AA, "Animaзгo desconhecida!");
    }
    return true;
}
Insisto e vou continuar a insistir, quando se usa apenas um parвmetro nгo tem necessidade de usar sscanf!

Quote:
Originally Posted by @LucasVinicius
Посмотреть сообщение
Код:
YCMD:smoke(playerid, params[],help) 
{
  #pragma unused help
  if(sscanf(params,"s", anims)) return SendClientMessage(playerid, 0x33AA33AA, "Uso correto: /smoke [1-4]");

  switch(anims)
  {
  case 1: ApplyAnimation(playerid,"SMOKING", "F_smklean_loop", 4.0, 1, 0, 0, 0, 0);
  case 2: ApplyAnimation(playerid,"SMOKING", "M_smklean_loop", 4.0, 1, 0, 0, 0, 0);
  case 3: ApplyAnimation(playerid,"SMOKING","M_smkstnd_loop", 4.0, 1, 0, 0, 0, 0);
  case 4: ApplyAnimation(playerid,"SMOKING","M_smk_out", 4.0, 1, 0, 0, 0, 0);
  }
  return 1;
}
Sem falar que anims й do tipo inteiro e no seu cуdigo esta bem diferente!
Outra coisa quando se usar alguma string deve sempre seguir este formato "s[tamanho]".
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)