[Ajuda] Com pequeno script
#1

To tentando fazer aquelas mensagem tipo: Arakuta tб querendo virar serial-killer, jб levou 2 pra cova.

Mas ta retornando esse warning e eu nгo testei o script

Em OnPlayerDeath:
pawn Код:
if (GetPlayerScore(killerid) == 2)
    {
    SendClientMessageToAll(COLOR_RED,"%s tб querendo virar serial-killer, ja levou 2 pra cova",killerid);
    }
Reply
#2

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{

    if (GetPlayerScore(killerid) > 0)
    {
        new serialkiller[MAX_PLAYER_NAME], string[100]; GetPlayerName(killerid, serialkiller, sizeof serialkiller) ;
        if(GetPlayerScore(killerid) == 2) {
            format(string, sizeof(string), "%s tб querendo virar serial-killer, ja levou 2 pra cova", serialkiller);
            SendClientMessageToAll(-1, string);
        }
        if(GetPlayerScore(killerid) == 3) {
            format(string, sizeof(string), "%s tб querendo virar serial-killer, ja levou 3 pra cova", serialkiller);
            SendClientMessageToAll(-1, string);
        }
        if(GetPlayerScore(killerid) == 4) {
            format(string, sizeof(string), "%s tб querendo virar serial-killer, ja levou 4 pra cova", serialkiller);
            SendClientMessageToAll(-1, string);
        }

    }
    return true;
}
Sу ir mudando as mensagem x)

Reputaзгo <~? valeu


Quote:
Originally Posted by crush_
Посмотреть сообщение
Bro, sempre que for usar strings em uma mensagem, tem que formata-lб!

pawn Код:
if(GetPlayerScore(killerid) == 2)
    {
        new Str[80], pName[24];
        GetPlayerName(killerid, pName, 24);
        format(Str, 80, "%s tб querendo virar serial-killer, ja levou 2 pra cova", pName);
        SendClientMessageToAll(COLOR_RED, Str);
    }
Й isso ai que ele falou
Reply
#3

Bro, sempre que for usar strings em uma mensagem, tem que formata-lб!

pawn Код:
if(GetPlayerScore(killerid) == 2)
    {
        new Str[80], pName[24];
        GetPlayerName(killerid, pName, 24);
        format(Str, 80, "%s tб querendo virar serial-killer, ja levou 2 pra cova", pName);
        SendClientMessageToAll(COLOR_RED, Str);
    }
Reply
#4

Ricoop522, seu script ta retornando warnings tambйm (nгo testei)
pawn Код:
if (GetPlayerScore(killerid) > 0)
    {
        new serialkiller[MAX_PLAYER_NAME]; GetPlayerName(killerid, serialkiller, sizeof serialkiller) ;
        if(GetPlayerScore(killerid) == 1) SendClientMessageToAll(COLOR_RED,"%s tб querendo virar serial-killer, ja levou 2 pra cova", serialkiller);
        if(GetPlayerScore(killerid) == 2) SendClientMessageToAll(COLOR_RED,"%s tб querendo virar serial-killer, ja levou 2 pra cova", serialkiller);
        if(GetPlayerScore(killerid) == 3) SendClientMessageToAll(COLOR_RED,"%s tб querendo virar serial-killer, ja levou 2 pra cova", serialkiller);
        if(GetPlayerScore(killerid) == 4) SendClientMessageToAll(COLOR_RED,"%s tб querendo virar serial-killer, ja levou 2 pra cova", serialkiller);
        if(GetPlayerScore(killerid) == 5) SendClientMessageToAll(COLOR_RED,"%s tб querendo virar serial-killer, ja levou 2 pra cova", serialkiller);
        if(GetPlayerScore(killerid) == 6) SendClientMessageToAll(COLOR_RED,"%s tб querendo virar serial-killer, ja levou 2 pra cova", serialkiller);
    }
Ta retornando o erro em cada linha que pega o score e da e mensagem
pawn Код:
G:\Projeto Samp\gamemodes\lvdm.pwn(455) : warning 202: number of arguments does not match definition
Reply
#5

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{

    if (GetPlayerScore(killerid) > 0)
    {
        new serialkiller[MAX_PLAYER_NAME], string[100]; GetPlayerName(killerid, serialkiller, sizeof serialkiller) ;
        if(GetPlayerScore(killerid) == 2) {
            format(string, sizeof(string), "%s tб querendo virar serial-killer, ja levou 2 pra cova", serialkiller);
            SendClientMessageToAll(-1, string);
        }
        if(GetPlayerScore(killerid) == 3) {
            format(string, sizeof(string), "%s tб querendo virar serial-killer, ja levou 3 pra cova", serialkiller);
            SendClientMessageToAll(-1, string);
        }
        if(GetPlayerScore(killerid) == 4) {
            format(string, sizeof(string), "%s tб querendo virar serial-killer, ja levou 4 pra cova", serialkiller);
            SendClientMessageToAll(-1, string);
        }

    }
    return true;
}
Olha lб denovo : p

pawn Код:
// Mensagens que contenham o nome, id, dinheiro ou algo do tipo, sempre devem ser formatadas.
// ex
format(string, sizeof(string), "Meu ID й %i", playerid); //formatei a string
SendClientMessage(playerid, cor, string); //msg enviada para o jogador

//Nunca se usa
SendClientMessage(playerid, -1, "Meu ID й %i", playerid);
Reply
#6

Sem warnings 8D vou testar
Reply
#7

PHP код:
public OnPlayerDeathplayeridkilleridreason )
{
   new 
bScore GetPlayerScorekillerid ); //Em vez de usar GetPlayerScore( killerid ) todas as vezes, uso apenas bScore
   
static
         
bNameMAX_PLAYER_NAME ], //Array que serб usada para checkar o nome do jogador
         
sStr128 ]; //Serб usada para criar a format da mensagem
   
GetPlayerNamekilleridbNamesizeofbName ) ); //Captura o nome do jogador
   
if( bScore == /*Numero*/ //Altere o Numero para o nъmero que deseja... captura se as matanзas que ele fez sгo iguais (=) a esse valor
   
{
      
formatsStrsizeofsStr ), "%s estб a reoluvionar-se, matou ?? pessoas"bName ); //Aletere o ?? pelo Numero que substituiu em cima, no "bScore == /*Numero*/"
      
SendClientMessageToAll/*Cor*/sStr ); //Enviarб uma mensagem para todos os jogadores conectados
   
}
   else if( 
bScore == /*Numero*/ //Altere o Numero para o nъmero que deseja... captura se as matanзas que ele fez sгo iguais (=) a esse valor
   
{
      
formatsStrsizeofsStr ), "%s estб a reoluvionar-se, matou ?? pessoas"bName ); //Aletere o ?? pelo Numero que substituiu em cima, no "bScore == /*Numero*/"
      
SendClientMessageToAll/*Cor*/sStr ); //Enviarб uma mensagem para todos os jogadores conectados
   
}
   return 
true;

Caso for acrescentando, usa else if e sу deixe if no primeiro.
Reply
#8

Nгo hб necessidade de criar um new para esse caso, sem ultilizar new й mais uma optimizaзгo que vocк pode fazer : P
Reply
#9

@Ricop522
No nosso ponto de vista (que jб temos experiкncia a programar) nгo hб necessidade de usar, mas se vocк reparar mais do que metade dos iniciantes usam arrays para facilitar as coisas, daн a maneira de como eu postei.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)