[Ajuda] Como separar cуdigo Public
#1

Galera como eu faзo para separar um cуdigo eu ja fiz isso uma vez mais eu eskeci como faz..
Eu tenho esse Public
pawn Код:
public OnPlayerText(playerid, text[])
{
  // Block the player's text if he has been muted
    if (APlayerData[playerid][Muted] == true)
    {
        // Let the player know he's still muted
        SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF0000}[ERRO] {FF0000}Vocк ainda estб mudo.");
        // Don't allow his text to be sent to the chatbox
        return 0;
    }

 new string[256];
 format(string,sizeof(string),"{FFFFFF}(ID: %d) %s",playerid,text);
 SendPlayerMessageToAll(playerid,string);
 return 0;
}
Se eu quiser adicionar um cуd. como eu faзo para colocar ele sem erros.. Se eu nгo me engano na ъltima vez que eu fiz isso teque tirar o ultimo return e fechar } e colocar o cуd. ?
Reply
#2

Um code
PHP код:
if (APlayerData[playerid][Muted] == true)
    {
        
// Let the player know he's still muted
        
SendClientMessage(playerid0xFFFFFFFF"{FFFF0000}[ERRO] {FF0000}Vocк ainda estб mudo.");
        
// Don't allow his text to be sent to the chatbox
        
return 0;
    } 
Outro code
PHP код:
 new string[256];
 
format(string,sizeof(string),"{FFFFFF}(ID: %d) %s",playerid,text);
 
SendPlayerMessageToAll(playerid,string); 
Unica ligaзгo entre ambos e que se vocк estiver multadado (mudo) o segundo code nгo terб efeito.
Reply
#3

Quote:
Originally Posted by Don_Speed
Посмотреть сообщение
Um code
PHP код:
if (APlayerData[playerid][Muted] == true)
    {
        
// Let the player know he's still muted
        
SendClientMessage(playerid0xFFFFFFFF"{FFFF0000}[ERRO] {FF0000}Vocк ainda estб mudo.");
        
// Don't allow his text to be sent to the chatbox
        
return 0;
    } 
Outro code
PHP код:
 new string[256];
 
format(string,sizeof(string),"{FFFFFF}(ID: %d) %s",playerid,text);
 
SendPlayerMessageToAll(playerid,string); 
Unica ligaзгo entre ambos e que se vocк estiver multadado (mudo) o segundo code nгo terб efeito.
Eu quero colocar mais um cod na Public Onplayertext mais eu coloem primeiro da um monte de erros e no final e pior ainda e quando eu coloco em fs nao da nada.. Como eu faco para colocar o codigo na pulic sem erros?
Reply
#4

Se tu postar os erros fica mais fбcil pra gente te ajudar.

Sobre nгo funcionar num FS, quando a public OnPlayerText (e outras) retorna 0 no GM ela nгo й executada no FS.
Reply
#5

PHP код:
public OnPlayerText(playeridtext[])
{
    new 
string[256];
    
format(string,sizeof(string),"{FFFFFF}(ID: %d) %s",playerid,text);
    
SendPlayerMessageToAll(playerid,string);
    if (
APlayerData[playerid][Muted] == true)
    {
        
SendClientMessage(playerid0xFFFFFFFF"{FFFF0000}[ERRO] {FF0000}Vocк ainda estб mudo.");
        return 
0;
    }
   
//SEU CODE AQUI! 
    
return 0;

Reply
#6

Quote:
Originally Posted by DiiMeNoR
Посмотреть сообщение
PHP код:
public OnPlayerText(playeridtext[])
{
    new 
string[256];
    
format(string,sizeof(string),"{FFFFFF}(ID: %d) %s",playerid,text);
    
SendPlayerMessageToAll(playerid,string);
    if (
APlayerData[playerid][Muted] == true)
    {
        
SendClientMessage(playerid0xFFFFFFFF"{FFFF0000}[ERRO] {FF0000}Vocк ainda estб mudo.");
        return 
0;
    }
   
//SEU CODE AQUI! 
    
return 0;

seguindo a logica do code, vc ta fazendo isso da forma errada..
Reply
#7

Quote:
Originally Posted by PT
Посмотреть сообщение
seguindo a logica do code, vc ta fazendo isso da forma errada..
O cod dele deu certo mais ele nгo explicou nada '-'
Reply
#8

Quote:
Originally Posted by ThiagoMK
Посмотреть сообщение
O cod dele deu certo mais ele nгo explicou nada '-'
hum, o que vc quer saber?
Reply
#9

Por que toda callback deve retornar alguma coisa, por exemplo, OnPlayerText retorna 0 para que a mensagem padrгo do sa-mp nгo seja exibida.

Entгo isso acusarб este warning

pawn Код:
public OnPlayerText(playerid,text[])
{
    if(playerid == 0)
        return 0;
}
Mesmo tendo um return, esse return sу й executado caso passe na condiзгo, caso nгo passe a callback nгo teria um return.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)