SA-MP Forums Archive
IsPlayerConnected Sometimes Bug Help - 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: IsPlayerConnected Sometimes Bug Help (/showthread.php?tid=407288)



IsPlayerConnected Sometimes Bug Help - PRoleplay - 13.01.2013

why my IsPlayerConnected Sometimes bug there's a time for example i use /pay or /whisper to player sometimes it says that invalid palyer but when the player relog its ok again
anyone encounter this?
sorry for bad english


Re: IsPlayerConnected Sometimes Bug Help - u3ber - 13.01.2013

can you show some code?

Quote:
Originally Posted by annoyance
This forum requires that you wait 120 seconds between posts. Please try again in 42 seconds.
ok.


Re: IsPlayerConnected Sometimes Bug Help - PRoleplay - 13.01.2013

for example
pawn Code:
CMD:w(playerid, params[])
{
    new giveplayerid, whisper[128];

    if (IsPlayerConnected(giveplayerid))
    {
              //resutl here
        }
       else
        {
            SendClientMessage(playerid, COLOR_WHITE, "Invalid player specified.");
        }
}



Re: IsPlayerConnected Sometimes Bug Help - u3ber - 13.01.2013

we can't help with portions of the code...


Re: IsPlayerConnected Sometimes Bug Help - PRoleplay - 13.01.2013

my problem is i think my IsPLayerconnected is malfunction coz sometimes its ok but some times got bugs
there's a time that when i try to /w any player it says invalid player specified.
that's my prob


Re: IsPlayerConnected Sometimes Bug Help - u3ber - 13.01.2013

Quote:
Originally Posted by PRoleplay
View Post
my problem is i think my IsPLayerconnected is malfunction coz sometimes its ok but some times got bugs
sorry, i don't think that's your problem.

Quote:

there's a time that when i try to /w any player it says invalid player specified.
that's my prob

problem solved?


Re: IsPlayerConnected Sometimes Bug Help - PRoleplay - 13.01.2013

here;s my code and i noticed that all command that using giveplayerid is sometimes bug
like /pay, /kick,/give so on all commands
need some help
pawn Code:
CMD:w(playerid, params[])
{
    new giveplayerid, whisper[128];

    if(sscanf(params, "us[128]", giveplayerid, whisper))
    {
        SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: (/w)hisper [playerid] [text]");
        return 1;
    }
    if (IsPlayerConnected(giveplayerid))
    {
 giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], string[128];
        sendername = GetPlayerNameEx(playerid);
        giveplayer = GetPlayerNameEx(giveplayerid);
        if(giveplayerid == playerid)
        {
            if(PlayerInfo[playerid][pSex] == 1) format(string, sizeof(string), "* %s mutters something to himself.", GetPlayerNameEx(playerid));
            else format(string, sizeof(string), "* %s mutters something to herself.", GetPlayerNameEx(playerid));
            return ProxDetector(5.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
        }
        if(ProxDetectorS(5.0, playerid, giveplayerid) || PlayerInfo[playerid][pAdmin] >= 2)
        {

            if(strlen(string) > 92)
            {
                new firstline[128], secondline[128];
                strmid(firstline, string, 0, 88);
                strmid(secondline, string, 88, 128);
                format(firstline, sizeof(firstline), "%s ...", firstline);
                SendClientMessageEx(giveplayerid, COLOR_YELLOW, firstline);
                SendClientMessageEx(giveplayerid, COLOR_YELLOW, secondline);
            }
            else SendClientMessageEx(giveplayerid,COLOR_YELLOW, string);

            if(strlen(string) > 92)
            {
                new firstline[128], secondline[128];
                strmid(firstline, string, 0, 88);
                strmid(secondline, string, 88, 128);
                format(firstline, sizeof(firstline), "%s ...", firstline);
                SendClientMessageEx(playerid, COLOR_YELLOW, firstline);
                SendClientMessageEx(playerid, COLOR_YELLOW, secondline);
            }
            else SendClientMessageEx(playerid,COLOR_YELLOW, string);
            return 1;
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GREY, "That player isn't near you.");
        }
        return 1;
    }
    else
    {
        SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    }
    return 1;
}



Re: IsPlayerConnected Sometimes Bug Help - Konstantinos - 13.01.2013

Ok, I guess it was example above, but you use sscanf.
Use
pawn Code:
if( giveplayerid == INVALID_PLAYER_ID ) return SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
instead.


Re: IsPlayerConnected Sometimes Bug Help - PRoleplay - 14.01.2013

i will try it thanks for the reply