SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 29/12/2019, 12:09 PM   #1
Hatiro
Big Clucker
 
Join Date: Mar 2019
Posts: 175
Reputation: 2
Talking cache_get_value_int & for

bem quero fazer alguma coisa assim
Code:
for(new I; I < 8; I ++) {
 
    cache_get_value_int(0, "Slot%i", I, PlayerInventario[playerid][iSlot][I]);
}
tem como?
Hatiro is offline   Reply With Quote
Old 29/12/2019, 12:52 PM   #2
RiqueP
Gangsta
 
RiqueP's Avatar
 
Join Date: Jan 2014
Posts: 853
Reputation: 58
Default Re: cache_get_value_int & for

Não. Você tem que formatar o Slot%i antes usando a função format.
__________________
Discord: RiqueP#1666
RiqueP is offline   Reply With Quote
Old 29/12/2019, 01:06 PM   #3
Hatiro
Big Clucker
 
Join Date: Mar 2019
Posts: 175
Reputation: 2
Default Re: cache_get_value_int & for

RiqueP
Code:
  cache_get_value_int(0, format(gstring, sizeof(gstring), "iSlot%i", I), PlayerInventario[playerid][iSlot][I]);
edit: ta setando o da primeira iSlot como de todas variável
Hatiro is offline   Reply With Quote
Old 29/12/2019, 01:24 PM   #4
RiqueP
Gangsta
 
RiqueP's Avatar
 
Join Date: Jan 2014
Posts: 853
Reputation: 58
Default Re: cache_get_value_int & for

PHP Code:
new gstring[10];

for(new 
I8++) {
    
format(gstringsizeof(10), "Slot%i"I);
    
cache_get_value_int(0gstringPlayerInventario[playerid][iSlot][I]);

__________________
Discord: RiqueP#1666
RiqueP is offline   Reply With Quote
Old 29/12/2019, 01:33 PM   #5
Hatiro
Big Clucker
 
Join Date: Mar 2019
Posts: 175
Reputation: 2
Default Re: cache_get_value_int & for

dando erro
Code:
new jk[10];

for(new I; I < 8; I ++) {
    format(jk, sizeof(10), "Slot%i", I);
    cache_get_value_int(0, jk, PlayerInventario[playerid][iSlot][I]);
}
error 020: invalid symbol name ""
error 029: invalid expression, assumed zero
warning 215: expression has no effect
erro da linha do format
agora na linha do cache
error 035: argument type mismatch (argument 2)
Hatiro is offline   Reply With Quote
Old 29/12/2019, 01:39 PM   #6
RiqueP
Gangsta
 
RiqueP's Avatar
 
Join Date: Jan 2014
Posts: 853
Reputation: 58
Default Re: cache_get_value_int & for

Não é sizeof(10). Seria: sizeof(jk) ou apenas 10.
__________________
Discord: RiqueP#1666
RiqueP is offline   Reply With Quote
Old 29/12/2019, 01:42 PM   #7
Hatiro
Big Clucker
 
Join Date: Mar 2019
Posts: 175
Reputation: 2
Default Re: cache_get_value_int & for

continua repetindo colocando
Code:
new jk[10];

for(new I; I < 8; I ++) {
    cache_get_value_int(0, format(jk, sizeof(jk), "Slot%i", I), PlayerInventario[playerid][iSlot][I]);
}
Hatiro is offline   Reply With Quote
Old 29/12/2019, 01:52 PM   #8
Malandrin
Huge Clucker
 
Malandrin's Avatar
 
Join Date: Jun 2018
Posts: 406
Reputation: 23
Default Re: cache_get_value_int & for

Cara, não use o format assim. Vou te dar um exemplo da maneira certa:

PHP Code:

new 
    
str[10];

for(new 
i200i++){
    
format(strsizeof(str), "Slot_%d"i);
    
cache_get_value_name_int(0strVariavel_Qualquer); 

Use cache_get_value_name_int ao invés de cache_get_value_int e provavelmente irá dar certo.
Malandrin is offline   Reply With Quote
Old 29/12/2019, 01:58 PM   #9
Hassel
Little Clucker
 
Join Date: Dec 2019
Posts: 35
Reputation: 12
Default Re: cache_get_value_int & for

Code:
cache_get_value_int(0, (format(jk, sizeof(jk), "Slot%i", I), jk), PlayerInventario[playerid][iSlot][I]);
Hassel is offline   Reply With Quote
Old 29/12/2019, 02:05 PM   #10
Hatiro
Big Clucker
 
Join Date: Mar 2019
Posts: 175
Reputation: 2
Default Re: cache_get_value_int & for

Hassel
Code:
	new 
    jk[10];

cache_get_value_int(0, (format(jk, sizeof(jk), "Slot%i", i), jk), PlayerInventario[playerid][iSlot][i]);
error 035: argument type mismatch (argument 3)
Malandrin pego quase não vi o _ kkk
edit: RiqueP devo ter feito alguma coisa errada
Hatiro is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 09:37 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.