SA-MP Forums Archive
IsPlayerConnected don't work - 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 don't work (/showthread.php?tid=299489)



IsPlayerConnected don't work - Cole_Phelps - 26.11.2011

Hey,

Since yesterday i had a bug with IsPlayerConnected.
When i use it, it returns everytime 0.
Example: /givegun

Код:
dcmd_givegun(playerid,params[])
{
	if(IsPlayerSAdmin(playerid,2))
	{
		new pID, weap,mun;
		if(sscanf(params, "uii",pID,weap,mun)) {
			return SendClientMessage(playerid,COLOR_RED,"Verwende: /givegun [playerid] [Waffenid (Maximal 46)] [Munition]");
		}
		if(weap > 46) { return SendClientMessage(playerid,COLOR_RED,"Die WaffenID darf hцchstens 46 sein!"); }
		if(!IsPlayerConnected(pID)) {
		    return SendClientMessage(playerid,COLOR_RED,"Kein Spieler mit angegebener ID Online");
		}
		GivePlayerWeapon(pID,weap,mun);
		new str[128];
		format(str,128,"%s hat dir die Waffe %d mit %d Schuss gegeben.",SpielerInfo[playerid][pName],weap,mun);
		SendClientMessage(pID,COLOR_GREEN,str);
		format(str,128,"Du hast %s die Waffe %d mit %d Schuss gegeben.",SpielerInfo[pID][pName],weap,mun);
		SendClientMessage(playerid,COLOR_GREEN,str);
	}
	return 1;
}
at
Код:
		if(!IsPlayerConnected(pID)) {
		    return SendClientMessage(playerid,COLOR_RED,"Kein Spieler mit angegebener ID Online");
		}
it says, everytime i'm not at the server.

I don't do anything at this code, i write it before 4 months.
That problem is at all commands with IsPlayer Connected.
I use SA-MP 0.3c.

MfG


Re: IsPlayerConnected don't work - Dragony92 - 26.11.2011

Try this
pawn Код:
dcmd_givegun(playerid,params[])
{
    if(IsPlayerSAdmin(playerid,2))
    {
        new pID, weap,mun;
        if(sscanf(params, "uii",pID,weap,mun)) {
            return SendClientMessage(playerid,COLOR_RED,"Verwende: /givegun [playerid] [Waffenid (Maximal 46)] [Munition]");
        }
        if(weap > 46) { return SendClientMessage(playerid,COLOR_RED,"Die WaffenID darf hцchstens 46 sein!"); }
        if(IsPlayerConnected(pID))
        {
            GivePlayerWeapon(pID,weap,mun);
            new str[128];
            format(str,128,"%s hat dir die Waffe %d mit %d Schuss gegeben.",SpielerInfo[playerid][pName],weap,mun);
            SendClientMessage(pID,COLOR_GREEN,str);
            format(str,128,"Du hast %s die Waffe %d mit %d Schuss gegeben.",SpielerInfo[pID][pName],weap,mun);
            SendClientMessage(playerid,COLOR_GREEN,str);
        }
        else return SendClientMessage(playerid,COLOR_RED,"Kein Spieler mit angegebener ID Online");
    }
    return 1;
}



Re: IsPlayerConnected don't work - Kostas' - 26.11.2011

I use 0.3c and works fine.
Also, you have this with pID inside.
pawn Код:
if(!IsPlayerConnected(pID))
Try this.
pawn Код:
dcmd_givegun(playerid,params[])
{
    if(IsPlayerSAdmin(playerid,2))
    {
        new pID, weap,mun;
        if(sscanf(params, "uii",pID,weap,mun)) return SendClientMessage(playerid,COLOR_RED,"Verwende: /givegun [playerid] [Waffenid (Maximal 46)] [Munition]");
        else if(weap > 46) { return SendClientMessage(playerid,COLOR_RED,"Die WaffenID darf hцchstens 46 sein!"); }
        else if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_RED,"Kein Spieler mit angegebener ID Online");
        GivePlayerWeapon(pID,weap,mun);
        new str[128];
        format(str,128,"%s hat dir die Waffe %d mit %d Schuss gegeben.",SpielerInfo[playerid][pName],weap,mun);
        SendClientMessage(pID,COLOR_GREEN,str);
        format(str,128,"Du hast %s die Waffe %d mit %d Schuss gegeben.",SpielerInfo[pID][pName],weap,mun);
        SendClientMessage(playerid,COLOR_GREEN,str);
    }
    return 1;
}



Re: IsPlayerConnected don't work - Rob_Maate - 26.11.2011

That's because you haven't set pID correctly.

Try using your command while only specifying the ID, rather than the player's name.


AW: IsPlayerConnected don't work - Cole_Phelps - 26.11.2011

dont you see i use sscanf?

a week ago it works fine, and i dont change anything


Re: IsPlayerConnected don't work - Dragony92 - 26.11.2011

Did you changed server version to 0.3d?


AW: IsPlayerConnected don't work - Cole_Phelps - 26.11.2011

No. 0.3c, said already in first post.


AW: IsPlayerConnected don't work - Cole_Phelps - 26.11.2011

Works now. I download the new Version from sscanf.