Dialogs not showing an interger!
#1

Heres my dialog code:
PHP код:
CMD:bphelp(playeridparams[])
{
    new 
string[1024];
    
strcat(string"{FF0000}Small Backpack Information:{FFFFFF}\n");
    
strcat(string"{00FF00}Narcotics Storage:{FFFFFF}\t\t\t\t\t %d Grams\n"BP_NARC);
    
strcat(string"{00FF00}Firearms Storage:{FFFFFF}\t\t\t\t\t 40 Grams\n");
    
ShowPlayerDialog(playerid,DIALOG_BACKPACKHELP,DIALOG_STYLE_MSGBOX"{FFFF00}Information:{FFFFFF} Backpacks"string"Close""");
    return 
1;

Only the Firearms storage is showing in the Dialog but not the narcotics and the Narcotics define is:
PHP код:
#define BP_NARC 40 
Any help? I want it to show the 40 in the dialog
Reply
#2

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

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

They are two different functions, you can't 'format' a string using strcat.
Reply
#3

Oh, now I understand it much better, thanks tho'
Reply
#4

Quote:

CMD:bphelp(playerid, params[])
{
new string[1024];
strcat(string, "{FF0000}Small Backpack Information:{FFFFFF}\n");
strcat(string, "{00FF00}Narcotics Storage:{FFFFFF}\t\t\t\t\t %d Grams\n", BP_NARC);
strcat(string, "{00FF00}Firearms Storage:{FFFFFF}\t\t\t\t\t 40 Grams\n");
ShowPlayerDialog(playerid,DIALOG_BACKPACKHELP,DIAL OG_STYLE_MSGBOX, "{FFFF00}Information:{FFFFFF} Backpacks", string, "Close", "");
return 1;
}

Just a simple re-write of your code, you shouldn't be using strcat like that, it's only for copying from one char array to another, instead you should use format, then may be use strcat to concatenate the strings.

Checkout the below modified code,

PHP код:
CMD:bphelp(playeridparams[]) 

    new 
string[1024], new tmp[500]; 
    
strcpy(string"{FF0000}Small Backpack Information:{FFFFFF}\n"); 
    
format(tmp"{00FF00}Narcotics Storage:{FFFFFF}\t\t\t\t\t %d Grams\n"BP_NARC); 
    
strcat(stringtmp);
    
strcpy(tmp"{00FF00}Firearms Storage:{FFFFFF}\t\t\t\t\t 40 Grams\n"); 
    
strcat(stringtmp);
    
ShowPlayerDialog(playerid,DIALOG_BACKPACKHELP,DIALOG_STYLE_MSGBOX"{FFFF00}Information:{FFFFFF} Backpacks"string"Close"""); 
    return 
1

Hope it helped out
Reply
#5

Heres my code now:
PHP код:
CMD:backpackhelp(playeridparams[])
{
    new 
string[1024];
    
format(string,sizeof(string), "{FF0000}Small Backpack Information:{FFFFFF}\n");
    
format(string,sizeof(string), "Narcotics Storage:{FFFFFF}\t\t\t\t\t %i Grams\n"SMALL_NARCOTICS);
    
format(string,sizeof(string), "Firearms Storage:{FFFFFF}\t\t\t\t\t %i Grams\n"SMALL_FIREARMS);
    
ShowPlayerDialog(playerid,DIALOG_BACKPACKHELP,DIALOG_STYLE_MSGBOX"{FFFF00}Information:{FFFFFF} Backpacks"string"Close""");
    return 
1;

But its only showing the last which is Firearms storage!

EDIT: Didnt see ur message @ShihabSoft ill check it out
Reply
#6

Quote:

But its only showing the last which is Firearms storage!

Checkout my previous reply bud.
Reply
#7

Ye, u made a small mistake there:

new string[1024], new tmp[500];

suppose to be:

new string[1024], tmp[500];
Reply
#8

Heres my code:
PHP код:
CMD:backpackhelp(playeridparams[])
{
    new 
string[1024], tmp[500];
    
strcpy(string"{FF0000}Small Backpack Information:{FFFFFF}\n");
    
format(tmp"{00FF00}Narcotics Storage:{FFFFFF}\t\t\t\t\t %d Grams\n"SMALL_NARCOTICS); // Line 35585
    
strcat(stringtmp);
    
strcpy(tmp"{00FF00}Firearms Storage:{FFFFFF}\t\t\t\t\t %d Grams\n"SMALL_FIREARMS);
    
strcat(stringtmp);
    
ShowPlayerDialog(playerid,DIALOG_BACKPACKHELP,DIALOG_STYLE_MSGBOX"{FFFF00}Information:{FFFFFF} Backpacks"string"Close""");
    return 
1;

Error:
PHP код:
UCRP.pwn(35585) : error 035argument type mismatch (argument 2)
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
1 Error

Reply
#9

Oops I started from declaring that array, so gradually and subconciously my fingers typed new keyword

Just remove it, and do let me know if the code works.
Reply
#10

Quote:

format(tmp, "{00FF00}Narcotics Storage:{FFFFFF}\t\t\t\t\t %d Grams\n", SMALL_NARCOTICS); // Line 35585

Forgot to add the size of the array, just change every format lines to

PHP код:
format(tmpsizeof(tmp), "{00FF00}Narcotics Storage:{FFFFFF}\t\t\t\t\t %d Grams\n"SMALL_NARCOTICS); // Line 35585 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)