[AJUDA] Variavel String
#1

Pessoal, й o seguinte, eu to querendo criar 3 strings:

-Vencedor1
-Vencedor2
-Vencedor3

Esses sгo de um evento de corrida.
Eles devem comeзar com uma letra qualquer como por exemplo 'a'. (pra servir como comparaзгo)

E Como eu faзo pras variaveis receberem o nome do player

Ex: if(Vencedor1 == 'A') Vencedor1=NomeDoPlayer ----- Ai saberemos quem chegou em primeiro lugar

Ex: if(Vencedor1 != 'A') Vencedor2=NomeDoPlayer ----- Ai saberemos quem chegou em segundo lugar

Ex: if(Vencedor1 != 'A' && Vencedor2 != 'A') Vencedor3=NomeDoPlayer ----- Ai saberemos quem chegou em terceiro lugar

So que eu nao sei como declarar essas variaveis e nem acrescentar o nome do player a elas. me ajudem ae =D
Reply
#2

pawn Код:
new Corriada;

// QUando INICIAR A CORRIDA
Corrida = 0;

// Quando o Player Ganhar:
// 1:
static Nom[24], Str[30];
GetPlayerName(playerid, Nom, 24);
if(Corrida == 0){
    format(Str, sizeof(Str), "[A]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;
}

if(Corrida == 1){
    format(Str, sizeof(Str), "[B]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;
}
if(Corrida == 2){

    format(Str, sizeof(Str), "[C]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;
}
Reply
#3

pawn Код:
new Corrida;
So pra corrigir
Reply
#4

Quote:
Originally Posted by ViictorDaay-
Посмотреть сообщение
pawn Код:
new Corrida;
So pra corrigir
Thx por corrigir, eu estava destraido quando eu havia criado.
Reply
#5

pawn Код:
SetPlayerName(playerid, Str); // Pra Corrigir tambem
Vou testar aki e ver se ta certo
Reply
#6

Quote:
Originally Posted by [Full]Garfield[XDB]
Посмотреть сообщение
pawn Код:
new Corriada;

// QUando INICIAR A CORRIDA
Corrida = 0;

// Quando o Player Ganhar:
// 1:
static Nom[24], Str[30];
GetPlayerName(playerid, Nom, 24);
if(Corrida == 0){
    format(Str, sizeof(Str), "[A]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;
}

if(Corrida == 1){
    format(Str, sizeof(Str), "[B]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;
}
if(Corrida == 2){

    format(Str, sizeof(Str), "[C]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;
}
Cara, sabia que nao ia funcionar
pawn Код:
if(Corrida == 0){
    format(Str, sizeof(Str), "[A]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;//aqui ta o problema, pois o se o player ficar em primeiro lugar, os proximos ifs nao deverao funcionar!
}

if(Corrida == 1){
    format(Str, sizeof(Str), "[B]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;
}
if(Corrida == 2){

    format(Str, sizeof(Str), "[C]%s", Nom);
    SetPlayerNome(playerid, Str);
    Corrida ++;
}
Reply
#7

Tente isto:
pawn Код:
new str[100], Nom[24];
GetPlayerName(playerid, Nom, 24);

switch(Corrida)
{
    case 0: format(str, sizeof(str),"[A]%s", Nom);
    case 1: format(str, sizeof(str),"[B]%s", Nom);
    case 2: format(str, sizeof(str),"[C]%s", Nom);
}

SetPlayerNome(playerid, str);
Corrida++;
Reply
#8

ta funcionado sim, mas nao entendi o porque desse GetPlayerName '-'
Reply
#9

pawn Код:
// Cria as arrays necessбrias
new str[100], Nom[24];

// Pegamos o nome do player para depois renomea-lo
GetPlayerName(playerid, Nom, 24);

switch(Corrida)
{
    // De acordo com a posiзгo, ele formata a string
    case 0: format(str, sizeof(str),"[A]%s", Nom);
    case 1: format(str, sizeof(str),"[B]%s", Nom);
    case 2: format(str, sizeof(str),"[C]%s", Nom);
}

// A string formatada й colocado como nome do player
SetPlayerNome(playerid, str);


// Variбvel para incrementar +1.
Corrida++;
=)
Reply
#10

A entendi, mas eu nao queria mudar o nome do player, intao nem vai precisar disso, ja consegui aqui, deu certo o sisteminha, valeu por tudo ae =D
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)