Shop cmd doesn't work -
#1

Server Files : California Cops And robbers from this forum..
https://sampforum.blast.hk/showthread.php?tid=573762

Code :
Код:
COMMAND:shop(playerid, params[])
{
	if(GetPlayerInterior(playerid) == 182)
	{
		new supaSave[750];
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$1,000      {FFFFFF}1x Rope {FFBF00}(Saves)", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$9,000      {FFFFFF}10x Ropes {FFBF00}(Saves)", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$2,500      {FFFFFF}1x Scissor {FFBF00}(Saves)", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$20,00      {FFFFFF}10x Scissors {FFBF00}(Saves)", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$2,000      {FFFFFF}1x Bobby Pins {FFBF00}(Saves)", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$18,00      {FFFFFF}10x Bobby Pins {FFBF00}(Saves)", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$15,000     {FFFFFF}Backpack {FFBF00}(Saves)", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Bigger Pocket", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Secure Wallet", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Butt Plug", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$25,000     {FFFFFF}Lucky Charm", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$10,000     {FFFFFF}Bomb Defusal Kit", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Escapists Guide", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}1 Token     {FFFFFF}XP Booster", supaSave);
		format(supaSave, sizeof(supaSave), "%s\n{D87C3E}$250,0000   {FFFFFF}Buy Toys", supaSave);
		if(Player[playerid][english])
			ShowPlayerDialog(playerid, DIALOG_SUPA, DIALOG_STYLE_LIST, "Supa Save", supaSave, "Buy", "Cancel");
		else
			ShowPlayerDialog(playerid, DIALOG_SUPA, DIALOG_STYLE_LIST, "Supa Save", supaSave, "Beli", "Batal");
	}
	return 1;
}
Reply
#2

You need to use strcat with an another string.
Actually, your are formating each time the array so the dialog will show the last array formated. c:
Reply
#3

Here you go:-

PHP код:
CMD:shop(playeridparmas[])
{
if(
GetPlayerInterior(playerid) == 182
    { 
        new 
supaSave[750]; 
        
strcat(supaSave"%s\n{D87C3E}$1,000      {FFFFFF}1x Rope {FFBF00}(Saves)"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$9,000      {FFFFFF}10x Ropes {FFBF00}(Saves)"sizeof(supaSave)); 
        
strcat(supaSave"%s\n{D87C3E}$2,500      {FFFFFF}1x Scissor {FFBF00}(Saves)"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$20,00      {FFFFFF}10x Scissors {FFBF00}(Saves)"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$2,000      {FFFFFF}1x Bobby Pins {FFBF00}(Saves)"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$18,00      {FFFFFF}10x Bobby Pins {FFBF00}(Saves)"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$15,000     {FFFFFF}Backpack {FFBF00}(Saves)"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$5,000      {FFFFFF}Bigger Pocket"sizeof(supaSave)); 
        
strcat(supaSave"%s\n{D87C3E}$5,000      {FFFFFF}Secure Wallet"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$5,000      {FFFFFF}Butt Plug"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$25,000     {FFFFFF}Lucky Charm"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$10,000     {FFFFFF}Bomb Defusal Kit"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$5,000      {FFFFFF}Escapists Guide"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}1 Token     {FFFFFF}XP Booster"sizeof(supaSave)); 
        
strcat(supaSave,  "%s\n{D87C3E}$250,0000   {FFFFFF}Buy Toys"sizeof(supaSave)); 
        if(
Player[playerid][english]) 
           { 
            
ShowPlayerDialog(playeridDIALOG_SUPADIALOG_STYLE_LIST"Supa Save"supaSave"Buy""Cancel"); 
           } 
        else 
ShowPlayerDialog(playeridDIALOG_SUPADIALOG_STYLE_LIST"Supa Save"supaSave"Beli""Batal"); 
    } 
    return 
1
Reply
#4

PHP код:
format(supaSavesizeof(supaSave), "{D87C3E}$1,000      {FFFFFF}1x Rope {FFBF00}(Saves)");
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$9,000      {FFFFFF}10x Ropes {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$2,500      {FFFFFF}1x Scissor {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$20,00      {FFFFFF}10x Scissors {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$2,000      {FFFFFF}1x Bobby Pins {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$18,00      {FFFFFF}10x Bobby Pins {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$15,000     {FFFFFF}Backpack {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Bigger Pocket"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Secure Wallet"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Butt Plug"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$25,000     {FFFFFF}Lucky Charm"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$10,000     {FFFFFF}Bomb Defusal Kit"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Escapists Guide"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}1 Token     {FFFFFF}XP Booster"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$250,0000   {FFFFFF}Buy Toys"supaSave); 
You don't need to add specifier and a new line for the first thing because initially the string is empty.

EDIT: Try it. It should work now.
Reply
#5

Quote:
Originally Posted by DarkSkull
Посмотреть сообщение
PHP код:
format(supaSavesizeof(supaSave), "{D87C3E}$1,000      {FFFFFF}1x Rope {FFBF00}(Saves)");
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$9,000      {FFFFFF}10x Ropes {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$2,500      {FFFFFF}1x Scissor {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$20,00      {FFFFFF}10x Scissors {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$2,000      {FFFFFF}1x Bobby Pins {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$18,00      {FFFFFF}10x Bobby Pins {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$15,000     {FFFFFF}Backpack {FFBF00}(Saves)"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Bigger Pocket"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Secure Wallet"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Butt Plug"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$25,000     {FFFFFF}Lucky Charm"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$10,000     {FFFFFF}Bomb Defusal Kit"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$5,000      {FFFFFF}Escapists Guide"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}1 Token     {FFFFFF}XP Booster"supaSave);
        
format(supaSavesizeof(supaSave), "%s\n{D87C3E}$250,0000   {FFFFFF}Buy Toys"supaSave); 
You don't need to add specifier and a new line for the first thing because initially the string is empty.

EDIT: Try it. It should work now.
That's really slow, use strcat.
Reply
#6

The problem isn't on formating the problem is he is not in 24/7 supa shop also the command doesn't have error message so he didn't realize that.

just add error message for player in case he is not in interior 182 and you will see its working fine >>

PHP код:
COMMAND:shop(playeridparams[])
{
    if(
GetPlayerInterior(playerid) == 182)
    {
        new 
supaSave[750];
        
strcat(supaSave"\n{D87C3E}$1,000      {FFFFFF}1x Rope {FFBF00}(Saves)");
        
strcat(supaSave"\n{D87C3E}$9,000      {FFFFFF}10x Ropes {FFBF00}(Saves)");
        
strcat(supaSave"\n{D87C3E}$2,500      {FFFFFF}1x Scissor {FFBF00}(Saves)");
        
strcat(supaSave"\n{D87C3E}$20,00      {FFFFFF}10x Scissors {FFBF00}(Saves)");
        
strcat(supaSave"\n{D87C3E}$2,000      {FFFFFF}1x Bobby Pins {FFBF00}(Saves)");
        
strcat(supaSave"\n{D87C3E}$18,00      {FFFFFF}10x Bobby Pins {FFBF00}(Saves)");
        
strcat(supaSave"\n{D87C3E}$15,000     {FFFFFF}Backpack {FFBF00}(Saves)");
        
strcat(supaSave"\n{D87C3E}$5,000      {FFFFFF}Bigger Pocket");
        
strcat(supaSave"\n{D87C3E}$5,000      {FFFFFF}Secure Wallet");
        
strcat(supaSave"\n{D87C3E}$5,000      {FFFFFF}Butt Plug");
        
strcat(supaSave"\n{D87C3E}$25,000     {FFFFFF}Lucky Charm");
        
strcat(supaSave"\n{D87C3E}$10,000     {FFFFFF}Bomb Defusal Kit");
        
strcat(supaSave"\n{D87C3E}$5,000      {FFFFFF}Escapists Guide");
        
strcat(supaSave"\n{D87C3E}1 Token     {FFFFFF}XP Booster");
        
strcat(supaSave"\n{D87C3E}$250,0000   {FFFFFF}Buy Toys");
        if(
Player[playerid][english])
            
ShowPlayerDialog(playeridDIALOG_SUPADIALOG_STYLE_LIST"Supa Save"supaSave"Buy""Cancel");
        else
            
ShowPlayerDialog(playeridDIALOG_SUPADIALOG_STYLE_LIST"Supa Save"supaSave"Beli""Batal");
    }
    else
    {
        
SendClientMessage(playeridCOLOR_RED,"ERROR: You need to be on 24/7 supa shop to use this command");
    }
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)