IsPlayerConnect inside the dialog not work
#1

i have this inside the dialog but IsPlayerConnect not work

PHP код:
if(dialogid == DIALOG_F_PANEL3)
    {
        if(
response)
        {
            new 
idfp,fpsendername[25],giveplayer[25],fpstring[256];
            if(
sscanf(inputtext"ui"idfp)) return SCM(playerid,COLOR_WHITE,"{FF0000}Error:{FFFFFF} Syntaxa trebuie sa fie [ID] [ 0 - Fara Faction Punish 1 - Cu Faction Punish ] !");
            if(
PlayerInfo[id][pLeader] >= 1) return SCM(playerid,COLOR_WHITE,"{FFB870}Acest player este lider.");
            {
                if(
IsPlayerConnected(id))
                {
                                 
//code here
                                
}
                                else return 
SCM(playeridCOLOR_WHITE"This player is not connected.");

Reply
#2

The sscanf specifier "u" has a internal IsPlayerConnected check. If the player is not connected it return INVALID_PLAYER_ID, then IsPlayerConnected won't work.
Reply
#3

You have to check if that player id is connected before using the id in any array:
pawn Код:
if(dialogid == DIALOG_F_PANEL3)
{
    if(response)
    {
        new id, fp,fpsendername[25],giveplayer[25],fpstring[256];
        if(sscanf(inputtext, "ui", id, fp)) return SCM(playerid,COLOR_WHITE,"{FF0000}Error:{FFFFFF} Syntaxa trebuie sa fie [ID] [ 0 - Fara Faction Punish 1 - Cu Faction Punish ] !");
        if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_WHITE, "This player is not connected.");
        if(PlayerInfo[id][pLeader] >= 1) return SCM(playerid,COLOR_WHITE,"{FFB870}Acest player este lider.");
......
}
Or, better, instead of !IsPlayerConnected(id) use id == INVALID_PLAYER_ID.
Reply
#4

And if i use id == INVALID_PLAYER_ID. i will not put the IsPlayerConnect ?
Reply
#5

Quote:
Originally Posted by Sn4ke2
Посмотреть сообщение
And if i use id == INVALID_PLAYER_ID. i will not put the IsPlayerConnect ?
pawn Код:
if(id == INVALID_PLAYER_ID) return SCM(playerid, COLOR_WHITE, "This player is not connected.");
is an alternative for
pawn Код:
if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_WHITE, "This player is not connected.");
when using sscanf "u" specifier.
Reply
#6

Not work
Reply
#7

Look how i made and dosen't work

PHP код:
if(dialogid == DIALOG_F_PANEL2)
    {
        if(
response)
        {
            new 
id,Fstring[100],giveplayer[30],Fsendername[30];
            if(
sscanf(inputtext"u"id))  return SCM(playerid,-1,"");
            new 
ftext[120];
            if(
PlayerInfo[id][pFpunish] != 0) return SCM(playerid,COLOR_WHITE,"{FFB870}You can not invite this player because it has faction punish");
            
            
            if(
id != INVALID_PLAYER_ID) return SCM(playerid,-1,"Acest jucator nu este conectat.");
            
            if(
PlayerInfo[id][pMember] == && PlayerInfo[id][pLeader] == 0)
            {
                if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 1)
                {
                    
PlayerInfo[id][pTeam] = 2;
                    
gTeam[id] = 2;
                    
ftext "LSPD";
                    
ChosenSkin[id] = 266;
                    
SetPlayerSkin(id266);
                }
                else if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 2)
                {
                    
PlayerInfo[id][pTeam] = 2;
                    
gTeam[id] = 2;
                    
ftext "Dillimore Police Departament";
                    
ChosenSkin[id] = 288;
                    
SetPlayerSkin(id288);
                }
                else if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 3)
                {
                    
PlayerInfo[id][pTeam] = 2;
                    
gTeam[id] = 2;
                    
ftext "Las Venturas Police Departament";
                    
ChosenSkin[id] = 71;
                    
SetPlayerSkin(id71);
                }
                else if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 4)
                {
                    
PlayerInfo[id][pTeam] = 5;
                    
gTeam[id] = 5;
                    
ftext "Ballas";
                    
ChosenSkin[id] = 104;
                    
SetPlayerSkin(id104);
                }
                else if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 5)
                {
                    
PlayerInfo[id][pTeam] = 5;
                    
gTeam[id] = 5;
                    
ftext "Los Aztecas";
                    
ChosenSkin[id] = 114;
                    
SetPlayerSkin(id114);
                }
                else if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 6)
                {
                    
PlayerInfo[id][pTeam] = 5;
                    
gTeam[id] = 5;
                    
ftext "Los Santos Vagos";
                    
ChosenSkin[id] = 108;
                    
SetPlayerSkin(id108);
                }
                else if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 7)
                {
                    
PlayerInfo[id][pTeam] = 2;
                    
gTeam[id] = 2;
                    
ftext "Factiunea Staffului";
                    
ChosenSkin[id] = 228;
                    
SetPlayerSkin(id228);
                }
                else if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 8)
                {
                    
PlayerInfo[id][pTeam] = 4;
                    
gTeam[id] = 4;
                    
ftext "Tow Car Co.";
                    
ChosenSkin[id] = 42;
                    
SetPlayerSkin(id42);
                }
                else if(
PlayerInfo[playerid][pLeader] == || PlayerInfo[playerid][pMember] == 9)
                {
                    
PlayerInfo[id][pTeam] = 4;
                    
gTeam[id] = 4;
                    
ftext "News Reporter";
                    
ChosenSkin[id] = 72;
                    
SetPlayerSkin(id72);
                }
                else if(
PlayerInfo[playerid][pLeader] == 10 || PlayerInfo[playerid][pMember] == 10)
                {
                    
PlayerInfo[id][pTeam] = 5;
                    
gTeam[id] = 5;
                    
ftext "Grove Street";
                    
ChosenSkin[id] = 107;
                    
SetPlayerSkin(id107);
                }
                else if(
PlayerInfo[playerid][pLeader] == 11 || PlayerInfo[playerid][pMember] == 11)
                {
                    
PlayerInfo[id][pTeam] = 11;
                    
gTeam[id] = 11;
                    
ftext "Hitman Agency";
                    
ChosenSkin[id] = 120;
                    
SetPlayerSkin(id120);
                }
                else if(
PlayerInfo[playerid][pLeader] == 12 || PlayerInfo[playerid][pMember] == 12)
                {
                    
PlayerInfo[id][pTeam] = 4;
                    
gTeam[id] = 4;
                    
ftext "School Instructor";
                    
ChosenSkin[id] = 101;
                    
SetPlayerSkin(id101);
                }
                else if(
PlayerInfo[playerid][pLeader] == 13 || PlayerInfo[playerid][pMember] == 13)
                {
                    
PlayerInfo[id][pTeam] = 4;
                    
gTeam[id] = 4;
                    
ftext "Taxi Company";
                    
ChosenSkin[id] = 261;
                    
SetPlayerSkin(id261);
                }
                else if(
PlayerInfo[playerid][pLeader] == 14 || PlayerInfo[playerid][pMember] == 14)
                {
                    
PlayerInfo[id][pTeam] = 4;
                    
gTeam[id] = 4;
                    
ftext "Paramedic Dep.";
                    
ChosenSkin[id] = 276;
                    
SetPlayerSkin(id276);
                }
                else { return 
1; }
                
GetPlayerName(idgiveplayersizeof(giveplayer));
                
GetPlayerName(playeridFsendernamesizeof(Fsendername));
                
PlayerInfo[id][pMember] = PlayerInfo[playerid][pMember];
                
PlayerInfo[id][pRank] = 1;
                
printf("AdmCmd: %s has invited %s to join %s."Fsendernamegiveplayerftext);
                
format(Fstringsizeof(Fstring), "Ai fost invitat de catre liderul %s in factiunea %s!"Fsendername,ftext);
                
SCM(idCOLOR_LIGHTBLUEFstring);
                
format(Fstringsizeof(Fstring), "L-ai invitat pe %s in factiunea ta."giveplayer);
                
SCM(playeridCOLOR_LIGHTBLUEFstring);
                
SetPlayerHealthEx(id0);
                new 
wakaname[25],str[128];
                
GetPlayerName(id,wakaname,sizeof(wakaname));
                
format(str,sizeof(str),"UPDATE users SET `Team`='%d',`Member`='%d',`Rank`='1' WHERE `name`='%s'",PlayerInfo[id][pTeam],PlayerInfo[id][pMember],wakaname);
                
mysql_query(SQL,str);
                
Factionlog(PlayerInfo[id][pMember],PlayerInfo[id][pSQLID],"Joined the Faction.");
            }
            else
            {
                
SCM(playerid0xFFB870FF"Acest player are wanted sau este intr-o factiune.");
                return 
1;
            }
        }
        else return 
ShowPlayerDialog(playeridDIALOG_F_PANELDIALOG_STYLE_LIST"Panel liderii:""Invita un jucator\nScoate un jucator afara\nSeteaza rank-ul unui jucator\nSeteaza jobul\nAdvertisment jucator\nScoate advertisment\n""Select""Cancel");
    } 
Reply
#8

Quote:
Originally Posted by IstuntmanI
Посмотреть сообщение
You have to check if that player id is connected before using the id in any array:
Put
pawn Код:
if(id != INVALID_PLAYER_ID) return SCM(playerid,-1,"Acest jucator nu este conectat.");
before
pawn Код:
new ftext[120];
Reply
#9

@IstuntmanI Thank you i give you REP ! :*
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)