[Pedido] Reformular esse cуdigo
#1

Olб pessoa, bom isso й um PEDIDO como estб escrito lб em cima, se nгo for para ajudar, nгo precisar nem comentar por favor, porque enche de mensagens desnecessбrias. E ajudar mesmo, poucos ajudam... Enfim.

Bom, consegui arrumar um comando aqui para multar, porem estб MUITO complicado ( pelo menos para mim que nгo sou bom em pawno ) andei tentando reformular aqui, mais sempre dava erros, entгo desisti de tentar e vim pedir a vocкs.

O pedido й o seguinte, pegar este cуdigo:
PHP код:
    if(strcmp(cmd"/multar"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(!
IsACop(playerid))
            {
                
SendClientMessage(playeridCOLOR_GREY"   Vocк nгo й um policial!");
                return 
true;
            }
            if(
OnDuty[playerid] != 1)
            {
                
SendClientMessage(playeridCOLOR_GREY"   Vocк nгo Bateu o cartгo!");
                return 
true;
            }
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"USE: /multar [ID] [Custo] [Razao]");
                return 
true;
            }
            
giveplayerid ReturnUser(tmp);
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp))
            {
                
SendClientMessage(playeridCOLOR_GRAD2"USE: /multar [ID] [Custo] [Razao]");
                return 
true;
            }
            
moneys strval(tmp);
            if(
moneys 1000 || moneys 30000) { SendClientMessage(playeridCOLOR_GREY"Custo entre 1000 e 30000 !"); return true; }
            if(
IsPlayerConnected(giveplayerid))
            {
                if(
IsACop(giveplayerid))
                {
                    
SendClientMessage(playeridCOLOR_GRAD1"Vocк nгo pode multar Policiais!");
                    return 
true;
                }
                if(
PlayerInfo[giveplayerid][pJailed] > 0)
                {
                    
SendClientMessage(playeridCOLOR_GRAD1"Vocк nгo pode multar jogadores que estejam presos!");
                    return 
true;
                }
                if(
giveplayerid != INVALID_PLAYER_ID)
                {
                    if (
ProxDetectorS(25.0playeridgiveplayerid))
                    {
                        
GetPlayerName(giveplayeridgiveplayersizeof(giveplayer));
                        
GetPlayerName(playeridsendernamesizeof(sendername));
                        new 
length strlen(cmdtext);
                        while ((
idx length) && (cmdtext[idx] <= ' '))
                        {
                            
idx++;
                        }
                        new 
offset idx;
                        new 
result[64];
                        while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                        {
                            
result[idx offset] = cmdtext[idx];
                            
idx++;
                        }
                        
result[idx offset] = EOS;
                        if(!
strlen(result))
                        {
                            
SendClientMessage(playeridCOLOR_GRAD2"USE: /multar [ID] [Custo] [Razao]");
                            return 
true;
                        }
                        
format(stringsizeof(string), "* Vocк multou %s por R$%d, Razao: %s"giveplayermoneys, (result));
                        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring);
                        
format(stringsizeof(string), "* Oficial %s lhe aplicou uma multa no valor de R$%d, Razao: %s"sendernamemoneys, (result));
                        
SendClientMessage(giveplayeridCOLOR_LIGHTBLUEstring);
                        
SendClientMessage(giveplayeridCOLOR_LIGHTRED"* Use /aceitar multa, para aceita-la.");
                        
//SendClientMessage(giveplayerid, COLOR_LIGHTRED, "* Se em 5 minutos vocк nгo pagar, irб preso!");
                        
TicketOffer[giveplayerid] = playerid;
                        
TicketMoney[giveplayerid] = moneys;
                        
//SetTimerEx("PresoMulta", 300000, false, "i", giveplayerid);
                        
return true;
                    }
                    else
                    {
                        
SendClientMessage(playeridCOLOR_GREY"O jogador estб longe !");
                        return 
true;
                    }
                }
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GREY"O jogador estб Offline !");
                return 
true;
            }
        }
        return 
true;
    } 
E reformular para +- igual a este:

PHP код:
    if( !strcmpcmd"/algemar"true ))
    {
        if( 
pInfoplayerid ][ Prof ] == POL_CIVIL || pInfoplayerid ][ Prof ] == POL_MILITAR || pInfoplayerid ][ Prof ] == DELEGADO || pInfoplayerid ][ Prof ] == SWAT || pInfoplayerid ][ Prof ] == EXERCITO || pInfoplayerid ][ Prof ] == POL_RODOVIARIA || aInfoplayerid ][ Patrao ] == || aInfoplayerid ][ Admin ] == )
        {
            if( 
pInfoplayerid ][ fardado ] == && aInfoplayerid ][ Patrao ] == && aInfoplayerid ][ Admin ] == )
            {
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк nгo estб fardado(a) !" );
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк precisa estб fardado(a) para algemar um(a) jogador(a) !" );
                return 
1;
            }
            
tmp strtokcmdtextidx );
             if( !
strlentmp ))
            {
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Uso correto: /Algemar [ ID ] [ Motivo ]" );
                return 
1;
             }
              new
                  
id strvaltmp )
              ;
            new 
length strlencmdtext );
            while (( 
idx length ) && ( cmdtextidx ] <= ' ' ))
            {
                
idx++;
            }
            new 
offset idx;
            new 
result64 ];
            while (( 
idx length ) && (( idx offset ) < ( sizeofresult ) - )) )
            {
                
resultidx offset ] = cmdtextidx ];
                
idx++;
            }
            
resultidx offset ] = EOS;
              if( !
strlenresult ))
            {
                 
SendClientMessageplayeridCOLOR_ERRO"[ x ] Uso correto: /Algemar [ ID ] [ Motivo ]" );
                 return 
1;
             }
             if( !
IsPlayerConnectedid ))
             {
                  
SendClientMessageplayeridCOLOR_ERRO"[ x ] Ninguйm online com esse ID !" );
                  return 
1;
              }
            if( 
Algemouplayerid ] == )
               {
                     
SendClientMessageplayeridCOLOR_ERRO"[ x ] Aguarde 1 minuto para algemar novamente !" );
                     return 
1;
              }
              if( 
Algemouplayerid ] > gettime( ))
            {
                
formatgStrsizeofgStr ), "[ x ] Aguarde %d segundos para poder algemar um(a) jogador(a) !"Algemouplayerid ] - gettime( ));
                
SendClientMessageplayeridCOLOR_ERROgStr );
                return 
1;
            }
                 if( 
playerid == id )
              {
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк nгo pode algemar vocк mesmo !" );
                return 
1;
              }
             if( 
Algemadoid ] == )
             {
                
MensagemFormatadaplayeridCOLOR_SISTEMA"[ x ] O(A) jogador(a) %s jб estб algemado(a) !"PlayerNameid ));
                return 
1;
             }
             if( 
IsPlayerInAnyVehicleplayerid ))
            {
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк nгo pode algemar de dentro de um veнculo !" );
                return 
1;
            }
            if( 
IsPlayerInAnyVehicleid ))
            {
                
MensagemFormatadaplayeridCOLOR_ERRO"[ x ] Vocк nгo pode algemar %s pois ele(a) estб dentro de um veнculo !"PlayerNameid ));
                return 
1;
            }
              if( 
GetDistanceBetweenPlayersplayeridid ) > 15 )
            {
                 
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк estб muito longe, chegue mais perto !" );
                return 
1;
             }
             
TogglePlayerControllableidfalse );
              
GameTextForPlayerid"~w~ALGEMADO!"3000);
              
formatgStrsizeofgStr ), "[ ALGEMAS ] %s algemou vocк pelo Motivo: {FFFFFF}%s"PlayerNameplayerid ), result );
            
SendClientMessageid0x3366FFAAgStr );
            
formatgstringsizeofgstring ), "[ ALGEMAS ] Vocк algemou o jogador(a) %s pelo Motivo: {FFFFFF}%s"PlayerNameid ), result );
            
SendClientMessageplayerid0x33CCFFAAgStr );
             
Algemouplayerid ] = gettime() + 60;
              
Algemadoid ] = 1;
             
P_Liberadoid ] = SetTimerEx"LiberadoParaAndar"30000false"d"id );
        }
        else
        {
            
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк nгo tem permissгo !" );
        }
        return 
1;
    } 
Bom, textos, essas coisas, vocкs nгo precisam se preocupar nгo, pode deixar qualquer coisa eu arrumo depois, mais й na бrea de organizaзгo mesmo que nгo consegui, Obrigado
Reply
#2

UP !!
Reply
#3

O que seria a reformulaзгo de um cуdigo? Se for pra diminuir linhas, vocк pode fazer desta maneira.

PHP код:
CMD:me_kick(playerid) {
    if(!
IsPlayerAdmin(playerid && Dados[playerid][Admin] == 0)) return SendClientMessage(playerid, -1"Vocк nгo й administrador.");
    
SendClientMessage(playerid, -1"Vocк se auto kickou.") && Kick(playerid));
    return 
1;

Reply
#4

Se for para diminuir linhas faзa como o luan disse aproposito vocк com este tutorial consegue fazer tudo isso em poucas linhas
https://sampforum.blast.hk/showthread.php?tid=277842
Reply
#5

Vocк tem 115 mensagens no fуrum... As 115 sгo pedindo ajuda.
Cуdigo no MEU GAMEMODE.

Код:
	if(strcmp(cmd,"/multar", true) == 0)
	{
		if( pInfo[ playerid ][ Prof ] == POL_CIVIL || pInfo[ playerid ][ Prof ] == POL_MILITAR || pInfo[ playerid ][ Prof ] == DELEGADO || pInfo[ playerid ][ Prof ] == SWAT || pInfo[ playerid ][ Prof ] == EXERCITO || aInfo[ playerid ][ Admin ] == 1 || aInfo[ playerid ][ Gerente ] == 1 || !strcmp( playerClan[ playerid ], "F.B.I", true ) )
		{
			if( pInfo[ playerid ][ fardado ] == 0 && aInfo[ playerid ][ Admin ] == 0 && aInfo[ playerid ][ Gerente ] == 0 && !strcmp( playerClan[ playerid ], "F.B.I", true ) )
			{
				SendClientMessage( playerid, COLOR_ERRO, "[ x ] Vocк nгo estб fardado(a) !" );
				SendClientMessage( playerid, COLOR_ERRO, "[ x ] Vocк precisa estб fardado(a) para adicionar um(a) jogador(a) na lista de perseguiзхes!" );
				return 1;
			}
  	 		new
			   	id = strval( tmp )
	   		;
			new msg[256];
			new plid,tempo;
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp)) {
				SendClientMessage(playerid, COLOR_ERRO,"[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
				return 1;
			}
			plid = strval(tmp);
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp)){
				SendClientMessage(playerid, COLOR_ERRO,"[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
				return 1;
			}
			tempo = strval(tmp);
			msg = strrest(cmdtext, idx);
			if(!strlen(msg)){
				SendClientMessage(playerid, COLOR_ERRO,"[[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
				return 1;
			}
			if(tempo > 5000 || tempo < 100){
				SendClientMessage(playerid, COLOR_ERRO,"[ x ] Multa mбxima de R$5.000 e minima de R$100!");
				return 1;
			}
        	if(Multou[ playerid ] == 1)
       		{
           	  	SendClientMessage(playerid, COLOR_ERRO, "[ x ] Aguarde '1 minuto' para multar novamente!");
           	  	return 1;
      		}
			if( playerid == id && aInfo[ playerid ][ Admin ] == 0 )
			{
				SendClientMessage( playerid, COLOR_ERRO, "[ x ] Vocк nгo pode se multar !" );
				return 1;
			}
      		if(Multou[ playerid ] > gettime())
			{
			    format(gStr, sizeof(gStr), "[ x ] Aguarde %d segundos para poder multar um(a) jogador(a)!", Multou[playerid] - gettime());
			    SendClientMessage(playerid, COLOR_ERRO, gStr);
				return 1;
			}
          	if( GetDistanceBetweenPlayers( playerid, id ) > 15 )
     		{
             	SendClientMessage( playerid, COLOR_ERRO, "[ x ] Vocк estб muito longe, chegue mais perto !" );
				return 1;
          	}
			if(IsPlayerConnected(plid)){
				new pname[ MAX_PLAYER_NAME ];
				GetPlayerName(plid, pname, MAX_PLAYER_NAME);
				format(string, sizeof(string),"O(A) Policial(a) %s multou vocк em R$ %d ( Motivo: %s.)", PlayerName( playerid ),tempo, msg);
				SendClientMessage(plid,0x33AAFFFF, string);
				SendClientMessage(playerid, 0x33AAFFFF, "[ > ] Vocк multou o(a) jogador(a) com sucesso!");
				GivePlayerCash( plid, -tempo );
				Multou[playerid] = gettime() + 60;
				format(string, sizeof(string),"[ MULTA ] O(A) Policial(a) %s multou o(a) jogador(a) %s no valor de R$ %d. ( Motivo: %s. )", PlayerName( playerid ),pname, tempo, msg);
				SendClientMessageToAll(0x33AAFFFF, string);
				return 1;
			}
			else
			{
				SendClientMessage(playerid, COLOR_ERRO,"[ x ] Ninguйm online com esse ID");
				return 1;
			}
		}
	}
Reply
#6

Luan, e FS, era tipo fazer que nem o THUG, deixar o comando parecido com o de algemar tendeu...

Thug, deu esses erros:

PHP код:
(598) : error 017undefined symbol "Multou"
(12941) : error 001expected token";"but found "]"
(12941) : error 029invalid expressionassumed zero
(12941) : fatal error 107too many error messages on one line 
Cуdigo:
PHP код:
        if(strcmp(cmd,"/multar"true) == 0)
    {
       if( 
pInfoplayerid ][ Prof ] == POL_RODOVIARIA || aInfoplayerid ][ Dono ] == || aInfoplayerid ][ Admin ] == )
        {
             if( 
pInfoplayerid ][ fardado ] == && aInfoplayerid ][ Dono ] == && aInfoplayerid ][ Admin ] == )
            {
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк nгo estб fardado(a) !" );
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк precisa estб fardado(a) para adicionar um(a) jogador(a) na lista de perseguiзхes!" );
                return 
1;
            }
               new
                   
id strvaltmp )
               ;
            new 
msg[256];
            new 
plid,tempo;
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp)) {
                
SendClientMessage(playeridCOLOR_ERRO,"[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
                return 
1;
            }
            
plid strval(tmp);
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp)){
                
SendClientMessage(playeridCOLOR_ERRO,"[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
                return 
1;
            }
            
tempo strval(tmp);
            
msg strrest(cmdtextidx);
            if(!
strlen(msg)){
                
SendClientMessage(playeridCOLOR_ERRO,"[[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
                return 
1;
            }
            if(
tempo 5000 || tempo 100){
                
SendClientMessage(playeridCOLOR_ERRO,"[ x ] Multa mбxima de R$5.000 e minima de R$100!");
                return 
1;
            }
            if(
Multouplayerid ] == 1)
               {
                     
SendClientMessage(playeridCOLOR_ERRO"[ x ] Aguarde '1 minuto' para multar novamente!");
                     return 
1;
              }
            if( 
playerid == id && aInfoplayerid ][ Admin ] == )
            {
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк nгo pode se multar !" );
                return 
1;
            }
              if(
Multouplayerid ] > gettime())
            {
                
format(gStrsizeof(gStr), "[ x ] Aguarde %d segundos para poder multar um(a) jogador(a)!"Multou[playerid] - gettime());
                
SendClientMessage(playeridCOLOR_ERROgStr);
                return 
1;
            }
              if( 
GetDistanceBetweenPlayersplayeridid ) > 15 )
             {
                 
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк estб muito longe, chegue mais perto !" );
                return 
1;
              }
            if(
IsPlayerConnected(plid)){
                new 
pnameMAX_PLAYER_NAME ];
                
GetPlayerName(plidpnameMAX_PLAYER_NAME);
                
format(stringsizeof(string),"O(A) Policial(a) %s multou vocк em R$ %d ( Motivo: %s.)"PlayerNameplayerid ),tempomsg);
                
SendClientMessage(plid,0x33AAFFFFstring);
                
SendClientMessage(playerid0x33AAFFFF"[ > ] Vocк multou o(a) jogador(a) com sucesso!");
                
GivePlayerCashplid, -tempo );
                
Multou[playerid] = gettime() + 60;
                
format(stringsizeof(string),"[ MULTA ] O(A) Policial(a) %s multou o(a) jogador(a) %s no valor de R$ %d. ( Motivo: %s. )"PlayerNameplayerid ),pnametempomsg);
                
SendClientMessageToAll(0x33AAFFFFstring);
                return 
1;
            }
            else
            {
                
SendClientMessage(playeridCOLOR_ERRO,"[ x ] Ninguйm online com esse ID");
                return 
1;
            }
        }
    } 
Reply
#7

Quote:
Originally Posted by MarlboroBr
Посмотреть сообщение
Luan, e FS, era tipo fazer que nem o THUG, deixar o comando parecido com o de algemar tendeu...

Thug, deu esses erros:

PHP код:
(598) : error 017undefined symbol "Multou"
(12941) : error 001expected token";"but found "]"
(12941) : error 029invalid expressionassumed zero
(12941) : fatal error 107too many error messages on one line 
Cуdigo:
PHP код:
        if(strcmp(cmd,"/multar"true) == 0)
    {
       if( 
pInfoplayerid ][ Prof ] == POL_RODOVIARIA || aInfoplayerid ][ Dono ] == || aInfoplayerid ][ Admin ] == )
        {
             if( 
pInfoplayerid ][ fardado ] == && aInfoplayerid ][ Dono ] == && aInfoplayerid ][ Admin ] == )
            {
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк nгo estб fardado(a) !" );
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк precisa estб fardado(a) para adicionar um(a) jogador(a) na lista de perseguiзхes!" );
                return 
1;
            }
               new
                   
id strvaltmp )
               ;
            new 
msg[256];
            new 
plid,tempo;
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp)) {
                
SendClientMessage(playeridCOLOR_ERRO,"[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
                return 
1;
            }
            
plid strval(tmp);
            
tmp strtok(cmdtextidx);
            if(!
strlen(tmp)){
                
SendClientMessage(playeridCOLOR_ERRO,"[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
                return 
1;
            }
            
tempo strval(tmp);
            
msg strrest(cmdtextidx);
            if(!
strlen(msg)){
                
SendClientMessage(playeridCOLOR_ERRO,"[[ x ] Use /Multar [ ID ] [ Quantia ] [ Motivo ]");
                return 
1;
            }
            if(
tempo 5000 || tempo 100){
                
SendClientMessage(playeridCOLOR_ERRO,"[ x ] Multa mбxima de R$5.000 e minima de R$100!");
                return 
1;
            }
            if(
Multouplayerid ] == 1)
               {
                     
SendClientMessage(playeridCOLOR_ERRO"[ x ] Aguarde '1 minuto' para multar novamente!");
                     return 
1;
              }
            if( 
playerid == id && aInfoplayerid ][ Admin ] == )
            {
                
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк nгo pode se multar !" );
                return 
1;
            }
              if(
Multouplayerid ] > gettime())
            {
                
format(gStrsizeof(gStr), "[ x ] Aguarde %d segundos para poder multar um(a) jogador(a)!"Multou[playerid] - gettime());
                
SendClientMessage(playeridCOLOR_ERROgStr);
                return 
1;
            }
              if( 
GetDistanceBetweenPlayersplayeridid ) > 15 )
             {
                 
SendClientMessageplayeridCOLOR_ERRO"[ x ] Vocк estб muito longe, chegue mais perto !" );
                return 
1;
              }
            if(
IsPlayerConnected(plid)){
                new 
pnameMAX_PLAYER_NAME ];
                
GetPlayerName(plidpnameMAX_PLAYER_NAME);
                
format(stringsizeof(string),"O(A) Policial(a) %s multou vocк em R$ %d ( Motivo: %s.)"PlayerNameplayerid ),tempomsg);
                
SendClientMessage(plid,0x33AAFFFFstring);
                
SendClientMessage(playerid0x33AAFFFF"[ > ] Vocк multou o(a) jogador(a) com sucesso!");
                
GivePlayerCashplid, -tempo );
                
Multou[playerid] = gettime() + 60;
                
format(stringsizeof(string),"[ MULTA ] O(A) Policial(a) %s multou o(a) jogador(a) %s no valor de R$ %d. ( Motivo: %s. )"PlayerNameplayerid ),pnametempomsg);
                
SendClientMessageToAll(0x33AAFFFFstring);
                return 
1;
            }
            else
            {
                
SendClientMessage(playeridCOLOR_ERRO,"[ x ] Ninguйm online com esse ID");
                return 
1;
            }
        }
    } 
Topo do GameMode .

pawn Код:
new Multou[MAX_PLAYERS];
Reply
#8

Quote:
Originally Posted by Jimmmy
Посмотреть сообщение
Topo do GameMode .

pawn Код:
new Multou[MAX_PLAYERS];
Nгo sabe resolver pelo menos isso?
"SEMPRE FALE A VERDADE, ESSE GM Й O DA NWD."

@Jimmy
Obrigado por lembrar.. nгo tinha visto o tуpico.
Reply
#9

Reformular vocк quer dizer coloca espaзos ? tipo
pawn Код:
new tipo[MAX_PLAYERS];

// para

new tipo[ MAX_PLAYERS ];
??
Reply
#10

Bom, o cуdigo acima que foi postado pelo Thug e Jimmy, esta dando um bug. Quando vou multar fala "[ x ] Vocк estб muito longe, chegue mais perto !"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)