SA-MP Forums Archive
help Dialog list - 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: help Dialog list (/showthread.php?tid=571790)



help Dialog list - Azula - 22.04.2015

hello i' tryed to make dialog list compile fine but IG dosent send the text and ID's'

apparently the problem is here

PHP код:
 cPM[ Rec[playerid] ] ++;
aPM[ Rec[playerid] ] [ cPM[ Rec[playerid] ]  ] [PMID]  = cPM[ Rec[playerid] ];
format(aPM[ Rec[playerid] ]  [ cPM[ Rec[playerid] ]  ] [FromName], 10, GetName(playerid));
aPM[ Rec[playerid] ]  [ cPM[ Rec[playerid] ]  ] [FromID] = playerid;
format(aPM[ Rec[playerid] ]  [ cPM[ Rec[playerid] ]  ] [Text] ,200, inputtext); 
the PMID and player id work but Text,playerName dont work

recuperate info code

PHP код:
for(new i = 0 ; i < MAX_PM; i++) {
        
format(text,sizeof text, "{FCF80B}azPM ID : {FC0B2F}%i {FCF80B}from {FC0B2F}'%s' ID: {FC0B2F}[%i] {FF2EE1}TEXT : %s\n "
        
,aPM[ Rec[playerid] ] [i] [PMID] , aPM[ Rec[playerid] ]  [i] [FromName],aPM[ Rec[playerid] ]  [i] [FromID],aPM[ Rec[playerid] ]  [i] [Text]);
    }
    
strcat(s,text);
    
ShowPlayerDialog(playerid, 22, DIALOG_STYLE_LIST, "{FF2EE1}[Az-Pm] PMS :", s, "Reply", "Close"); 
help me plz and
Thanks !

Edit : i tryed this
PHP код:
          cPM[ Rec[playerid] ] ++;
               for(new 
i=0; i< MAX_PM; i++)
            {
                
aPM[ Rec[playerid]][i][PMID]  = cPM[ Rec[playerid] ];
                
format(aPM[ Rec[playerid]][i] [FromName], 10, GetName(playerid));
                
aPM[ Rec[playerid]][i][FromID] = playerid;
                
format(aPM[ Rec[playerid]][i][Text] ,200, inputtext);
            } 
result it give me just the last message i'woulde like make it to give me all messages


how to made that and thanks again


Re: help Dialog list - fuckingcruse - 22.04.2015

Show us aPM , cPM and other codes..


Re: help Dialog list - Konstantinos - 22.04.2015

You used strcat outside of the loop so it actually shows the last item. No need of using strcat though, format is just fine:
PHP код:
s[0] = EOS;
for(new 
i = 0 ; i < MAX_PM; i++) 
{
    
format(s,sizeof s, "%s{FCF80B}azPM ID : {FC0B2F}%i {FCF80B}from {FC0B2F}'%s' ID: {FC0B2F}[%i] {FF2EE1}TEXT : %s\n",
    
s, aPM[ Rec[playerid] ] [i] [PMID] , aPM[ Rec[playerid] ]  [i] [FromName],aPM[ Rec[playerid] ]  [i] [FromID],aPM[ Rec[playerid] ]  [i] [Text]);
}
ShowPlayerDialog(playerid, 22, DIALOG_STYLE_LIST, "{FF2EE1}[Az-Pm] PMS :", s, "Reply", "Close"); 



Re: help Dialog list - Azula - 22.04.2015

PHP код:
enum AzPmInfo
{
    
PMID,
    
FromName[10],
    
FromID,
    
Text[200],
}
new 
aPM[MAX_PLAYERS][MAX_PM][AzPmInfo]; 
PHP код:
new Rec[MAX_PLAYERS],PlayerText:Az[3][MAX_PLAYERS],
    
cPM[MAX_PLAYERS]
; 
PHP код:
Rec[playerid] = clickedplayerid; // the id of Rec[playerid] 
EDIT :

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You used strcat outside of the loop so it actually shows the last item. No need of using strcat though, format is just fine:
PHP код:
s[0] = EOS;
for(new 
i = 0 ; i < MAX_PM; i++) 
{
    
format(s,sizeof s, "%s{FCF80B}azPM ID : {FC0B2F}%i {FCF80B}from {FC0B2F}'%s' ID: {FC0B2F}[%i] {FF2EE1}TEXT : %s\n",
    
s, aPM[ Rec[playerid] ] [i] [PMID] , aPM[ Rec[playerid] ]  [i] [FromName],aPM[ Rec[playerid] ]  [i] [FromID],aPM[ Rec[playerid] ]  [i] [Text]);
}
ShowPlayerDialog(playerid, 22, DIALOG_STYLE_LIST, "{FF2EE1}[Az-Pm] PMS :", s, "Reply", "Close"); 
thank you but now i have a lot off message lol




Re: help Dialog list - Konstantinos - 22.04.2015

On player connecting you reset variables (to INVALID_PLAYER_ID, -1 or whatever you have written). Check inside the loop if the other's playerid is valid and use format, otherwise skip the loop with continue;

About the same messages, it'd print what you've stored to those arrays so make sure you reset and you set them correctly.


Re: help Dialog list - Azula - 22.04.2015

Reset varaibles like this ?

PHP код:
public OnPlayerConnect(playerid)
{
    for(new 
i=0; i< MAX_PM; i++)
    {
        
aPM[ playerid ][i][PMID]  = -1;
        
aPM[ playerid ][i][FromID] = -1;
    }
    
Rec[playerid] = -1;
    
cPM[playerid]= 0;
    return 
1;
} 



Re: help Dialog list - Konstantinos - 22.04.2015

Yes and you need to reset the strings too.

You can then check if PMID is not -1 and continue formatting the text.


Re: help Dialog list - Azula - 22.04.2015

thank you now i have just the first msg

PHP код:
for(new i=0; i< MAX_PM; i++)
            {
                if(
aPM[ Rec[playerid]][i][PMID] != -1 ) continue;
                if(
aPM[ Rec[playerid]][i][FromName] != -1 ) continue;
                if(
aPM[ Rec[playerid]][i][FromID] != -1 ) continue;
                if(
aPM[ Rec[playerid]][i][Text] != -1 ) continue;
                
aPM[ Rec[playerid]][i][PMID]  = cPM[ Rec[playerid] ];
                
format(aPM[ Rec[playerid]][i] [FromName], 10, GetName(playerid));
                
aPM[ Rec[playerid]][i][FromID] = playerid;
                
format(aPM[ Rec[playerid]][i][Text] ,200, inputtext);
            } 



Re: help Dialog list - fuckingcruse - 22.04.2015

MAX_PM = how many?


Re: help Dialog list - Konstantinos - 22.04.2015

You set the data for the first free slot and then you have to stop the loop using break; at the end of it (in the loop though). You just need to check if PMID is not -1 and skip it, the rest are not necessary so remove them (plus, strings cannot be checked as integeres - you'd need to check if it's null).