SA-MP Forums Archive
Inventory item on the same line. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Inventory item on the same line. (/showthread.php?tid=624467)



Inventory item on the same line. - SukMathcuck - 17.12.2016

So, I'm doing an inventory system and would like to know how I do to show the intens in the same line, for example, I have a cell phone and money, and I would not like to skip a line to show by yesterday in each line, Look what I did:

PHP код:
if(GetPlayerMoney(playerid) >= 1format(strglobalsizeof(strglobal), "[Itens]: Dinheiro:[$%d]"GetPlayerMoney(playerid)); //linha 1
if(PlayerData[playerid][pCelular] == 1format(strglobalsizeof(strglobal), "[Itens 2]: Celular"GetPlayerMoney(playerid)); //linha 2
                
SendClientMessage(playerid, -1strglobal); 
So, the logic would be right, but it would not be the way I wanted it to be, how can I do to show the item on the same line?


Re: Inventory item on the same line. - Runn3R - 17.12.2016

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


Re: Inventory item on the same line. - coool - 17.12.2016

Create another format and mix the two sentences then show them.
Create each line with another variable.I only think that it can work not sure..

Also try to mix these sentences with + sign like SendClientMessage(playerid, -1, str1 + str2); OR By this method SendClientMessage(playerid, -1, str1 " " str2);


Re: Inventory item on the same line. - SukMathcuck - 17.12.2016

PHP код:
new marijuana[32] = "Marijuana";
new 
cocaina[32] = "Marijuana";
if(
PlayerData[playerid][pMarijuana] == 1)
{
strcat(marijuana" :[%d]"PlayerData[playerid][pMarijuana]);
}
if(
PlayerData[playerid][pCocaina] == 1)
{
strcat(cocaina" :[%d]"PlayerData[playerid][pCocaina]);
}
SendClientMessage(playeridCOLOR_SEAGREENstrglobal); 
I did not understand anything, look what I did, I got angry at it, did not have the logic I wanted, I do not think you understood, I want everything in the same line. Example;

Quote:

Marijuana: [1] Cocaнna: [3]

You are understanding like this;
Quote:

Marijuana: [1]
Cocaнna: [3]

If it does not have only shows what it has, in a single line.


Re: Inventory item on the same line. - oMa37 - 17.12.2016

PHP код:
new mar PlayerData[playerid][pMarijuana], coc PlayerData[playerid][pCocaina];
if(
mar == && coc == 1) {
    
format(strglobalsizeof(strglobal), "Cocaine: [%i] Marijuana: [%i]"cocmar);
    return 
SendClientMessage(playeridCOLOR_SEAGREENstrglobal);  

I think that's what you meant?


Re: Inventory item on the same line. - SukMathcuck - 17.12.2016

Quote:
Originally Posted by oMa37
Посмотреть сообщение
PHP код:
new mar PlayerData[playerid][pMarijuana], coc PlayerData[playerid][pCocaina];
if(
mar == && coc == 1) {
    
format(strglobalsizeof(strglobal), "Cocaine: [%i] Marijuana: [%i]"cocmar);
    return 
SendClientMessage(playeridCOLOR_SEAGREENstrglobal);  

I think that's what you meant?
No, this logic I had already thought, I want to put the definitions in the same line, and if you do not have no shows and if you have the same line, everything in the same line, I tried to do no one else support me,...


Re: Inventory item on the same line. - Pearson - 17.12.2016

Is your inventory on textdraws? OR its on dialogs.


Re: Inventory item on the same line. - SukMathcuck - 17.12.2016

In SendClientMessage your inventory.


Re: Inventory item on the same line. - Logic_ - 18.12.2016

Use strcat, it's faster than format and you can use it without using format in another line. (Thanks to Gammix & SickAttack for the tip)

How to use strcat properly:
PHP код:
new str[40];
strcat(str"Marijuana: [");
strcat(strMarijuana_Variable);
strcat(str"] Cocaine: [");
strcat(strCocaine_Variable);
strcat(str"].");
SendClientMessage(playerid0x828282FFstr); 
How strcat is used:
PHP код:
new str[40];
strcat(str"Marijuana: [%d] Cocaine: [%d].");
format(strsizeof(str), strMarijuana_VariableCocaine_Variable);
SendClientMessage(playerid0x828282FFstr); 
EDIT: Changed the variable size, thanks oMa37.


Re: Inventory item on the same line. - oMa37 - 18.12.2016

Don't you think size 75 is a bit too much? :c
It's not even 40.