SA-MP Forums Archive
[Ajuda] Como manter mais de um valor na variбvel - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Ajuda] Como manter mais de um valor na variбvel (/showthread.php?tid=655252)



Como manter mais de um valor na variбvel - GasparzinhoXD - 16.06.2018

Olб, gostaria de saber o seguinte... vamos supor que eu tenho uma variбvel, ai eu faзo o seguinte:

PHP код:
new varTest;
CMD:test(playerid)
{
    new 
result[128];
    
varTest ++;
    
format(resultsizeof(result), "%d"varTest);
    
SendClientMessageToAll(-1result);
    return 
1;

Vocк concorda que quando eu digitar o comando /test a variбvel "varTest" vai comeзar a subir o valor dela. 1.. 2.. 3.. ou seja, ela vai somando e assim por diante. O que eu queria fazer й o seguinte... ao invйs de ir somando, ir adicionando o valor, como assim? quando eu digitar /test a "varTest" ficarб 1 quando eu digitar novamente, ela ficarб 11 e assim vai adicionando, ao invйs de somar.

OBS: A forma que eu fiz ali pode nгo estar correta para ir adicionando 111... mas queria sу pra ter uma base entende?


Re: Como manter mais de um valor na variбvel - Minerva - 16.06.2018

Leia isso: https://sampwiki.blast.hk/wiki/Strcat

eu fiz isto pelo celular...

PHP код:
new valor[15] = "";
new 
qt;

CMD:teste()
{
    new 
str[10];
    
qt++;
    
format(strsizeof str"%d"qt);
    
strcat(valorstr);
    
SendClientMessageToAll(-1str);
    return 
valor;




Re: Como manter mais de um valor na variбvel - 1sbedx - 16.06.2018

Quote:
Originally Posted by Minerva
Посмотреть сообщение
Leia isso: https://sampwiki.blast.hk/wiki/Strcat

eu fiz isto pelo celular...

PHP код:
new valor[15] = "";
new 
qt;
CMD:teste()
{
    new 
str[10];
    
qt++;
    
format(strsizeof str"%d"qt);
    
strcat(valorstr);
    
SendClientMessageToAll(-1str);
    return 
valor;

Й a mesma coisa que ele fez...

PHP код:
return valor
Isso vai dar um erro...

GasparzinhoXD, dк uma olhada, talvez seja o que vocк quer: https://sampwiki.blast.hk/wiki/Scripting_Basics#Setting


Re: Como manter mais de um valor na variбvel - XandyMello - 17.06.2018

PHP код:
#include <a_samp>
main() {}
public 
OnGameModeInit()
{
    for(new 
010i++)
    {
        static
            Var[
30] = 1;
            
        
strins(Var, "1"0);
        
printf("%d"strval(Var));
    }
    return 
true;

pawn Код:
[20:59:59] 1
[20:59:59] 11
[20:59:59] 111
[20:59:59] 1111
[20:59:59] 11111
[20:59:59] 111111
[20:59:59] 1111111
[20:59:59] 11111111
[20:59:59] 111111111
[20:59:59] 1111111111

Seu comando:
PHP код:
new varTest[30];
CMD:test(playerid)
{
    new 
result[128];
    
strins(varTest"1"0);
    
format(resultsizeof(result), "%d"strval(varTest));
    
SendClientMessageToAll(-1result);
    return 
1;