SA-MP Forums Archive
Is this right? - 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: Is this right? (/showthread.php?tid=299351)



Is this right? - HondaCBR - 25.11.2011

I didnt test this yet, I want to find out if this is going to work or not, if you have 500 dollars or more phone price comes up in green, otherwisde it will come up in red, is the code for it right? Thx

pawn Код:
if(GetPlayerMoney(playerid) >= 500))
            {
                format(option1,sizeof(option1),"Phone {GREEN}$500");
            }
            if(GetPlayerMoney(playerid) < 500))
            {
                format(option1,sizeof(option1),"Phone {RED}$500");
            }
            format(text,sizoef(text),"%s\n%s",option1,option2);

            ShowPlayerDialog(playerid, 247, DIALOG_STYLE_LIST, "Shop:", text, "Buy", "Cancel");



Re: Is this right? - Tanush123 - 25.11.2011

pawn Код:
if(GetPlayerMoney(playerid) >= 500)
            {
                format(option1,sizeof(option1),"Phone {GREEN}$500");
            }
            if(GetPlayerMoney(playerid) < 500)
            {
                format(option1,sizeof(option1),"Phone {RED}$500");
            }
            format(text,sizoef(text),"%s\n%s",option1,option2);

            ShowPlayerDialog(playerid, 247, DIALOG_STYLE_LIST, "Shop:", text, "Buy", "Cancel");



Re: Is this right? - Ash. - 25.11.2011

The code is correct, however the colours won't show.

I'm guessing "GREEN" and "RED" are definitions.
You should place a quotation mark before the define name, then add a "#" (without quotation marks) at the start of the name.Then place a quotation mark where you want the text to start again (After the definition name).

Like so:
pawn Код:
if(GetPlayerMoney(playerid) >= 500)
            {
                format(option1,sizeof(option1),"Phone "#GREEN"$500");
            }
            if(GetPlayerMoney(playerid) < 500) //You also had an extra bracket here.
            {
                format(option1,sizeof(option1),"Phone "#RED"$500");
            }
            format(text,sizoef(text),"%s\n%s",option1,option2);

            ShowPlayerDialog(playerid, 247, DIALOG_STYLE_LIST, "Shop:", text, "Buy", "Cancel");
You should also ensure that your in-string colour definitions look like:
pawn Код:
#define RED {FF0000}



Re: Is this right? - Tanush123 - 25.11.2011

funky edit the one you just post, on the first getplayermoney it has another extra


Re: Is this right? - Ash. - 25.11.2011

Quote:
Originally Posted by Tanush123
Посмотреть сообщение
funky edit the one you just post, on the first getplayermoney it has another extra
Just noticed that - I was looking at the less obvious things haha.


Re: Is this right? - HondaCBR - 25.11.2011

error 029: invalid expression, assumed zero
error 017: undefined symbol "option1"
error 017: undefined symbol "option1"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line


Re: Is this right? - Ash. - 25.11.2011

Quote:
Originally Posted by HondaCBR
Посмотреть сообщение
error 029: invalid expression, assumed zero
error 017: undefined symbol "option1"
error 017: undefined symbol "option1"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
pawn Код:
if(GetPlayerMoney(playerid) >= 500)
            {
                format(option1,sizeof(option1),"Phone "#GREEN"$500");
            }
            if(GetPlayerMoney(playerid) < 500) //You also had an extra bracket here.
            {
                format(option1,sizeof(option1),"Phone "#RED"$500");
            }
            format(text,sizeof(text),"%s\n%s",option1,option2);

            ShowPlayerDialog(playerid, 247, DIALOG_STYLE_LIST, "Shop:", text, "Buy", "Cancel");
Try that, just noticed you had another 'extra' bracket. You also spelt sizeof wrong...


Re: Is this right? - HondaCBR - 25.11.2011

pawn Код:
if(GetPlayerMoney(playerid) >= 100)
            {
                format(option1,sizeof(option1),"Telefon Komurkowy {00FC11}$100");
            }
            if(GetPlayerMoney(playerid) < 100)
            {
                format(option1,sizeof(option1),"Telefon Komurkowy {FF0000}$100");
            }
            if(GetPlayerMoney(playerid) >= 100)
            {
                format(option2,sizeof(option2),"Telefon Komurkowy {00FC11}$100");
            }
            if(GetPlayerMoney(playerid) < 100)
            {
                format(option2,sizeof(option2),"Telefon Komurkowy {FF0000}$100");
            }
            format(text,sizeof(text),"%s\n%s",option1,option2);

            ShowPlayerDialog(playerid, 247, DIALOG_STYLE_LIST, "Sklep:", text, "Kup", "Anuluj");
Код:
 error 017: undefined symbol "option1"
 error 017: undefined symbol "option1"
 error 029: invalid expression, assumed zero
 fatal error 107: too many error messages on one line



Re: Is this right? - Ash. - 25.11.2011

Could you show us the lines where the errors occur?

Thanks


Re: Is this right? - HondaCBR - 25.11.2011

pawn Код:
format(option1,sizeof(option1),"Telefon Komurkowy {00FC11}$100");
all errors are there and the last error is fatal error, therefore i think thesame errors will come up on all the format(option... lines.

any ideas?